feat(lib/flash): 添加C++支持,定义了FLASH设备表格式

 feat(lib/font): 增加中文字体数据结构,扩展字形数组大小
 chore(.gitignore): 添加构建目录到忽略列表
 chore(CMakeLists): 优化CMake配置,修复库链接顺序
 feat(sim/key): 实现模拟按键功能,包括上下左右及确认、设置、重置键
 fix(main): 移除未使用的SDL实例,调整任务和OLED测试的执行顺序
main
JiXieShi 2024-12-14 23:33:32 +08:00
parent d93df1d303
commit 7dd4268210
6 changed files with 181 additions and 63 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/cmake-build-debug/
/build/
/.idea/
/.venv/
/lvgl/

View File

@ -19,6 +19,7 @@ foreach (SIM_SUBDIR ${SIM_SUBDIRS})
endforeach ()
set(LVGL_ROOT_DIR lvgl)
include(lvgl/env_support/cmake/custom.cmake)
include_directories(easyx/include)
@ -31,10 +32,12 @@ add_subdirectory(SDL3 EXCLUDE_FROM_ALL)
link_libraries(SDL3::SDL3)
link_libraries(libeasyx.a libgdi32.a libole32.a)
add_executable(HW_Lib main.c ${SOURCES})
#
add_subdirectory(lib)
target_link_libraries(HW_Lib HW_LIB_List HW_LIB_Task HW_LIB_Printf HW_LIB_Utils HW_LIB_Iic
HW_LIB_Spi HW_LIB_Key HW_LIB_Oled HW_LIB_Font HW_LIB_Tft lvgl::lvgl lvgl::examples lvgl::demos
)

View File

@ -5,6 +5,10 @@
#ifndef HW_LIB_FLASH_CFG_H
#define HW_LIB_FLASH_CFG_H
#ifdef __cplusplus
extern "C" {
#endif
#define FLASH_DEBUG_MODE
#define FLASH_USING_SFDP
@ -19,9 +23,12 @@ enum {
#define FLASH_FLASH_DEVICE_TABLE \
{ \
[FLASH_XXXX_DEVICE_INDEX] = {.name = "XXXX", .spi.name = "SPIX"}, \
[FLASH_XXXX_DEVICE_INDEX] = {.name = "XXXX", .spi={.name = "SPIX"}, }, \
}
#define FLASH_USING_QSPI
#ifdef __cplusplus
}
#endif
#endif //HW_LIB_FLASH_CFG_H

View File

@ -5,71 +5,71 @@
typedef struct {
uint8_t unicode[2];
uint8_t data[32];
uint8_t data[128];
} Chinese_t;
static uint8_t Hzk_size = 16;
static uint8_t Hzk_size=32;
static Chinese_t Hzk[] = {
{
// Original: ÐÇ
{0x66, 0x1F},
{ 0x66, 0x1F },
{
0x00, 0x08, 0x3F, 0xFC, 0x20, 0x08, 0x3F, 0xF8, 0x20, 0x08, 0x3F, 0xF8, 0x01, 0x00, 0x21, 0x08,
0x3F, 0xFC, 0x21, 0x00, 0x41, 0x10, 0xBF, 0xF8, 0x01, 0x00, 0x01, 0x04, 0xFF, 0xFE, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x03, 0xFF, 0xFF, 0xC0, 0x03, 0x80, 0x01, 0xC0, 0x01, 0x01, 0x81, 0x80, 0x01, 0x81, 0xC0, 0x00,
0x01, 0xC1, 0x80, 0x40, 0x01, 0x81, 0x80, 0xE0, 0x03, 0xFF, 0xFF, 0xF0, 0x03, 0x01, 0x80, 0x00, 0x06, 0x01, 0x80, 0x00, 0x0C, 0x01, 0x80, 0x00, 0x08, 0x01, 0x81, 0x80, 0x11, 0xFF, 0xFF, 0xC0, 0x21, 0x01, 0x80, 0x00, 0x40, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x01, 0x80, 0x3C, 0x3F, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: º£
{0x6D, 0x77},
{ 0x6D, 0x77 },
{
0x02, 0x00, 0x42, 0x08, 0x33, 0xFC, 0x14, 0x00, 0x8B, 0xF8, 0x62, 0x88, 0x22, 0x48, 0x0A, 0x08,
0x1F, 0xFE, 0x24, 0x88, 0xE4, 0x48, 0x24, 0x08, 0x27, 0xFC, 0x20, 0x08, 0x20, 0x28, 0x20, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x08, 0x07, 0x00, 0x00, 0x0E, 0x06, 0x00, 0x00, 0x07, 0x0E, 0x00, 0x30, 0x07, 0x0F, 0xFF, 0xF8, 0x03, 0x0C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x40, 0x98, 0x00, 0x80, 0x70, 0xBF, 0xFF, 0xC0, 0x38, 0xAF, 0xFF, 0xC0, 0x19, 0xCC, 0xC1, 0xC0, 0x19, 0x8C, 0x61, 0xC0, 0x09, 0x1C, 0x71, 0xC0, 0x03, 0x1C, 0x31, 0xC0,
0x03, 0x1C, 0x01, 0xC8, 0x02, 0xFF, 0xFF, 0xFC, 0x06, 0x18, 0x01, 0x80, 0x06, 0x18, 0xC1, 0x80, 0x06, 0x18, 0x61, 0x80, 0x0C, 0x38, 0x71, 0x80, 0x7C, 0x38, 0x71, 0x80, 0x1C, 0x30, 0x21, 0x88, 0x1C, 0x7F, 0xFF, 0xFC, 0x1C, 0x30, 0x01, 0x80, 0x1C, 0x00, 0x01, 0x80, 0x1C, 0x00, 0x63, 0x80, 0x1C, 0x00, 0x3F, 0x80, 0x1C, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: ¿Æ
{0x79, 0xD1},
{ 0x79, 0xD1 },
{
0x04, 0x10, 0x0E, 0x10, 0xF8, 0x90, 0x08, 0x50, 0x08, 0x10, 0xFE, 0x90, 0x08, 0x50, 0x1C, 0x14,
0x1A, 0x1E, 0x29, 0xF0, 0x28, 0x10, 0x48, 0x10, 0x88, 0x10, 0x08, 0x10, 0x08, 0x10, 0x08, 0x10,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xE0, 0x00, 0x3C, 0x00, 0xE0, 0x01, 0xFC, 0x00, 0xC0, 0x1F, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x60, 0xC0, 0x00, 0xC0, 0x30, 0xC0, 0x00, 0xC0, 0x38, 0xC0, 0x00, 0xC0, 0x18, 0xC0, 0x00, 0xC4, 0x18, 0xC0, 0x3F, 0xFE, 0x00, 0xC0, 0x3F, 0xFE, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x01, 0xC0, 0xC0, 0xC0, 0x01, 0xE0, 0x70, 0xC0,
0x03, 0xF8, 0x30, 0xC0, 0x03, 0xDC, 0x30, 0xC8, 0x07, 0xCE, 0x00, 0xDC, 0x06, 0xC6, 0x00, 0xFE, 0x0C, 0xC0, 0x0F, 0xE0, 0x18, 0xC3, 0xF8, 0xC0, 0x10, 0xC7, 0x00, 0xC0, 0x20, 0xC0, 0x00, 0xC0, 0x40, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: ¼¼
{0x62, 0x80},
{ 0x62, 0x80 },
{
0x10, 0x40, 0x10, 0x40, 0x10, 0x48, 0x13, 0xFC, 0xFC, 0x40, 0x10, 0x40, 0x10, 0x40, 0x13, 0xF8,
0x1A, 0x08, 0x31, 0x10, 0xD1, 0x10, 0x10, 0xA0, 0x10, 0x40, 0x10, 0xB0, 0x51, 0x0E, 0x26, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0xC0, 0x0E, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x88, 0x0C, 0x18, 0x3F, 0xFF, 0xFF, 0xFC, 0x21, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x80, 0x0C, 0x00, 0x01, 0x8C, 0x0C, 0x20, 0x01, 0xFB, 0xFF, 0xF0,
0x03, 0xE0, 0x80, 0x60, 0x1F, 0x80, 0xC0, 0xE0, 0x3F, 0x80, 0x40, 0xC0, 0x39, 0x80, 0x41, 0xC0, 0x01, 0x80, 0x61, 0xC0, 0x01, 0x80, 0x33, 0x80, 0x01, 0x80, 0x33, 0x00, 0x01, 0x80, 0x1F, 0x00, 0x01, 0x80, 0x1E, 0x00, 0x01, 0x80, 0x1E, 0x00, 0x01, 0x80, 0x3F, 0x00, 0x11, 0x80, 0xE3, 0xC0, 0x1F, 0x83, 0xC1, 0xFC, 0x07, 0x8F, 0x00, 0x7C, 0x03, 0x38, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: »ú
{0x67, 0x3A},
{ 0x67, 0x3A },
{
0x10, 0x00, 0x10, 0x10, 0x11, 0xF8, 0x11, 0x10, 0xFD, 0x10, 0x11, 0x10, 0x31, 0x10, 0x39, 0x10,
0x55, 0x10, 0x51, 0x10, 0x91, 0x10, 0x11, 0x10, 0x11, 0x12, 0x12, 0x12, 0x14, 0x0E, 0x18, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x03, 0x81, 0x01, 0x80, 0x03, 0x81, 0xFF, 0xC0, 0x03, 0x81, 0x81, 0xC0, 0x03, 0x81, 0x81, 0x80, 0x03, 0x91, 0x81, 0x80, 0x01, 0xB9, 0x81, 0x80, 0x3F, 0xFD, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0x81, 0x81, 0x80, 0x03, 0xE1, 0x81, 0x80, 0x07, 0xF9, 0x81, 0x80,
0x07, 0xBD, 0x81, 0x80, 0x07, 0x9D, 0x81, 0x80, 0x0F, 0x8D, 0x81, 0x80, 0x0F, 0x81, 0x81, 0x80, 0x1B, 0x81, 0x81, 0x80, 0x1B, 0x83, 0x81, 0x80, 0x33, 0x83, 0x01, 0x80, 0x23, 0x83, 0x01, 0x8C, 0x63, 0x83, 0x01, 0x8C, 0x03, 0x86, 0x01, 0x8C, 0x03, 0x86, 0x01, 0x8C, 0x03, 0x8C, 0x01, 0x8E, 0x03, 0x98, 0x01, 0xFE, 0x03, 0xB0, 0x00, 0xFC, 0x03, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: е
{0x68, 0xB0},
{ 0x68, 0xB0 },
{
0x10, 0x20, 0x10, 0x28, 0x10, 0x24, 0x17, 0xFE, 0xFC, 0x20, 0x12, 0xA0, 0x32, 0xA0, 0x3A, 0xA4,
0x57, 0xE4, 0x52, 0xA8, 0x92, 0xA8, 0x12, 0x90, 0x14, 0xB0, 0x18, 0x52, 0x10, 0x8A, 0x13, 0x06,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x0E, 0x00, 0x03, 0x00, 0x07, 0xC0, 0x03, 0x00, 0x06, 0x70, 0x03, 0x00, 0x06, 0x30, 0x03, 0x00, 0x06, 0x30, 0x03, 0x00, 0x06, 0x00, 0x03, 0x20, 0x06, 0x1C, 0x3F, 0xF7, 0xFF, 0xFC, 0x3F, 0xF0, 0x06, 0x00, 0x07, 0x06, 0xE6, 0x00, 0x07, 0x06, 0xE6, 0x20, 0x07, 0xC6, 0xE6, 0x38, 0x07, 0xE6, 0xE6, 0x38, 0x07, 0x76, 0xE6, 0x30,
0x0F, 0x26, 0xE6, 0x30, 0x0F, 0x3F, 0xFE, 0x70, 0x1B, 0x3F, 0xFE, 0x60, 0x1B, 0x06, 0xE7, 0x60, 0x13, 0x06, 0xE3, 0xC0, 0x33, 0x06, 0xE3, 0xC0, 0x23, 0x0C, 0xE3, 0x80, 0x43, 0x0C, 0xE3, 0x84, 0x03, 0x0C, 0xE3, 0x84, 0x03, 0x18, 0xE7, 0xC4, 0x03, 0x18, 0xEC, 0xEC, 0x03, 0x30, 0xD8, 0x7C, 0x03, 0x20, 0x30, 0x3C, 0x03, 0x40, 0xE0, 0x1C, 0x03, 0x03, 0x80, 0x0E, 0x00, 0x00, 0x00, 0x00,
}
},
{
// Original: ʦ
{0x5E, 0x08},
{ 0x5E, 0x08 },
{
0x08, 0x04, 0x0B, 0xFE, 0x48, 0x20, 0x48, 0x24, 0x49, 0xFE, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24,
0x49, 0x24, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24, 0x11, 0x34, 0x11, 0x28, 0x20, 0x20, 0x40, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x18, 0x00, 0xEF, 0xFF, 0xFC, 0x00, 0xE6, 0x0C, 0x00, 0x10, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x00, 0x1C, 0xE0, 0x0C, 0x10, 0x1C, 0xE7, 0xFF, 0xF8, 0x1C, 0xE7, 0xFF, 0xF8, 0x1C, 0xE6, 0x0C, 0x18, 0x1C, 0xE6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18,
0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1C, 0xC6, 0x0C, 0x18, 0x1D, 0xC6, 0x0C, 0x18, 0x1D, 0x86, 0x0C, 0x18, 0x19, 0x86, 0x0D, 0xF8, 0x03, 0x86, 0x0C, 0x70, 0x03, 0x06, 0x0C, 0x20, 0x06, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x0C, 0x00, 0x1C, 0x00, 0x10, 0x00, 0x1C, 0x00, 0x20, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00,
}
},
};
static Chinese_t *find_chinese_data(uint8_t unicode_high, uint8_t unicode_low) {
static Chinese_t* find_chinese_data(uint8_t unicode_high, uint8_t unicode_low) {
for (int i = 0; i < sizeof(Hzk) / sizeof(Chinese_t); ++i) {
if (Hzk[i].unicode[0] == unicode_high && Hzk[i].unicode[1] == unicode_low) {
return &Hzk[i];

12
main.c
View File

@ -12,7 +12,7 @@
#include "t_tft.h"
#include "tool.h"
#include "sim_test.h"
#include "sim_sdl.h"
#include <windows.h>
#include <stdint.h>
#include <SDL3/SDL.h>
@ -30,12 +30,6 @@ static SDL_Point points[POINTS_COUNT] = {
static SDL_Rect bigrect = {0, 0, 540, 380};
static SIM_SDL3_t sdl1;
static SIM_SDL3_t sdl2;
static SIM_SDL3_t sdl3;
static SIM_SDL3_t sdls[3];
int main(int argc, char *argv[]) {
srand((unsigned) time(NULL));
@ -166,8 +160,8 @@ int main(int argc, char *argv[]) {
// Test_Run("List", Test_List,NULL);
// Test_RunTime("Key", Test_Key);
// Test_RunTime("Queue", Test_Queue);
Test_RunTime("Task", Test_task);
// Test_RunTime("OLED", Test_OLED);
// Test_RunTime("Task", Test_task);
Test_RunTime("OLED", Test_OLED);
// Test_RunTime("LVGL", Test_lvgl);
// Test_RunTime("TFT", Test_tft);
return 0;

View File

@ -108,4 +108,117 @@ uint8_t SIM_Key_Scan() {
return key;
}
uint8_t SIM_Key_UP(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_UP || event.key.key == SDLK_W)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_DOWN(uint8_t l) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_DOWN || event.key.key == SDLK_S)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_LEFT(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_LEFT || event.key.key == SDLK_A)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_RIGHT(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_RIGHT || event.key.key == SDLK_D)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_ENABLE(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_KP_ENTER || event.key.key == SDLK_E)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_SET(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_Q)key = 1;
break;
default:
break;
}
return key;
}
uint8_t SIM_Key_RESET(uint8_t) {
SDL_Event event;
uint8_t key = 0;
SDL_PollEvent(&event);
switch (event.type) {
case SDL_EVENT_QUIT:
return 0;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_R)key = 1;
break;
default:
break;
}
return key;
}
#endif