diff --git a/CMakeLists.txt b/CMakeLists.txt index 30a6858..f62df26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,12 @@ SET(CMAKE_CXX_FLAGS "-O3") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") -#file(GLOB DEMO_SUBDIRS "demo/tft/*") -#foreach (DEMO_SUBDIR ${DEMO_SUBDIRS}) -# include_directories(${DEMO_SUBDIR}) -#endforeach () +file(GLOB DEMO_SUBDIRS "demo/*/") +foreach (DEMO_SUBDIR ${DEMO_SUBDIRS}) + include_directories(${DEMO_SUBDIR}) +endforeach () -include_directories("demo/tft") +#include_directories("demo/tft") file(GLOB SIM_SUBDIRS "sim/*") foreach (SIM_SUBDIR ${SIM_SUBDIRS}) @@ -25,8 +25,10 @@ endforeach () include_directories(easyx/include) link_directories(easyx/lib64) -#file(GLOB_RECURSE SOURCES "demo/*/*.*" "sim/*/*.*" "lvgl/src/*/*.*" "lvgl/demos/*/*.*") -file(GLOB_RECURSE SOURCES "demo/tft/*.*" "sim/*/*.*" "lvgl/src/*/*.*") + +file(GLOB_RECURSE SOURCES "demo/*/*.*" "sim/*/*.*" "lvgl/src/*/*.*" "lvgl/demos/*/*.*") +#file(GLOB_RECURSE SOURCES "demo/tft/*.*" "sim/*/*.*" "lvgl/src/*/*.*") + link_libraries(libeasyx.a libgdi32.a libole32.a) add_executable(HW_Lib main.c ${SOURCES}) diff --git a/demo/tft/test.c b/demo/tft/test.c index 56bfaa3..36cb2df 100644 --- a/demo/tft/test.c +++ b/demo/tft/test.c @@ -105,20 +105,21 @@ uint8_t tft_senddata(uint8_t *data, size_t len) { void Test_tft() { - demo_tft.width = 480; - demo_tft.height = 320; - demo_tft.wgramcmd = WGRAM_CMD; - demo_tft.setycmd = SETYCMD; - demo_tft.setxcmd = SETXCMD; - demo_tft.writeReg = tft_writereg; - demo_tft.sendData = tft_senddata; - demo_tft.dir = HORIZONTAL; + //设备信息预填充 + demo_tft.width = 480;//实际如有支持不用填(如ST7735/7796) + demo_tft.height = 320;//实际如有支持不用填(如ST7735/7796) + demo_tft.wgramcmd = WGRAM_CMD;//实际如有支持不用填(如ST7735/7796) + demo_tft.setycmd = SETYCMD;//实际如有支持不用填(如ST7735/7796) + demo_tft.setxcmd = SETXCMD;//实际如有支持不用填(如ST7735/7796) + demo_tft.writeReg = tft_writereg;//必须实现 + demo_tft.sendData = tft_senddata;//必须实现 + demo_tft.dir = HORIZONTAL;//必填 + + //模拟初始化 SIM_Display_INIT(demo_tft.width, demo_tft.height, 0xFFFF, 0x0000, 2, 0); SIM_Display_START(); -// SIM_Color_DrawPiexl(RGB565_to_RGB888(0xFFFFF),0,0); - Sleep(2000); - TFT_Init(&demo_tft); + TFT_Init(&demo_tft);//初始化 TFT_Color_t t; t.color = 0XFFFF; TFT_Fill(&demo_tft, 0, 0, demo_tft.width, demo_tft.height, t); @@ -152,8 +153,11 @@ void Test_tft() { TFT_ShowString(&demo_tft, 0, 160, "abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ<>(){}[]\\/?.,;:'\"!@#$%^&*-=_+~|", 16, 1); - for (float p = 0; p < 1; p += 0.0001) { + for (float p = 0; p < 1; p += 0.001) { TFT_ShowBar(&demo_tft, 0, 100, demo_tft.width, 24, p); + TFT_ShowBar(&demo_tft, 0, 125, demo_tft.width, 16, p); + TFT_ShowBar(&demo_tft, 0, 142, demo_tft.width, 12, p); + TFT_ShowBar(&demo_tft, 0, 155, demo_tft.width, 3, p); } while (1) { diff --git a/lib/font/inc/font_chuc.h b/lib/font/inc/font_chuc.h index d66afd4..4fa8adc 100644 --- a/lib/font/inc/font_chuc.h +++ b/lib/font/inc/font_chuc.h @@ -1,16 +1,16 @@ #pragma once -#ifndef HW_LIB_OLED_FONT_CHUC_H -#define HW_LIB_OLED_FONT_CHUC_H +#ifndef HW_LIB_FONT_CHUC_H +#define HW_LIB_FONT_CHUC_H typedef struct { uint8_t unicode[2]; uint8_t data[32]; } Chinese_t; -uint8_t Hzk_size = 16; +static uint8_t Hzk_size = 16; -Chinese_t Hzk[] = { +static Chinese_t Hzk[] = { { // Original: {0x66, 0x1F}, @@ -69,7 +69,7 @@ Chinese_t Hzk[] = { }, }; -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]; @@ -78,4 +78,4 @@ Chinese_t *find_chinese_data(uint8_t unicode_high, uint8_t unicode_low) { return NULL; } -#endif //HW_LIB_OLED_FONT_CHUC_H +#endif //HW_LIB_FONT_CHUC_H diff --git a/main.c b/main.c index 91b21cd..36ba763 100644 --- a/main.c +++ b/main.c @@ -1,14 +1,14 @@ #include #include #include -//#include "t_spi.h" -//#include "t_iic.h" -//#include "t_task.h" -//#include "t_arg.h" -//#include "t_list.h" -//#include "t_key.h" -//#include "t_oled.h" -//#include "t_lvgl.h" +#include "t_spi.h" +#include "t_iic.h" +#include "t_task.h" +#include "t_arg.h" +#include "t_list.h" +#include "t_key.h" +#include "t_oled.h" +#include "t_lvgl.h" #include "t_tft.h" #include "tool.h" #include diff --git a/tools/unicode_ch_gen.py b/tools/unicode_ch_gen.py index 9e47a0b..74425f9 100644 --- a/tools/unicode_ch_gen.py +++ b/tools/unicode_ch_gen.py @@ -89,14 +89,14 @@ def generate_chinese_array(input_str, font_str, size): def format_chinese_array_as_text(chinese_array, size): text_output = "#pragma once\n\n" - text_output += "#ifndef HW_LIB_OLED_FONT_CHUC_H\n" - text_output += "#define HW_LIB_OLED_FONT_CHUC_H\n\n" + text_output += "#ifndef HW_LIB_FONT_CHUC_H\n" + text_output += "#define HW_LIB_FONT_CHUC_H\n\n" text_output += f"typedef struct {{\n" text_output += " uint8_t unicode[2];\n" text_output += f" uint8_t data[{size[0] * ((size[1] + 7) // 8 * 8) // 8}];\n" text_output += "} Chinese_t;\n\n" - text_output += f"uint8_t Hzk_size={size[0]};\n\n" - text_output += "Chinese_t Hzk[] = {\n" + text_output += f"static uint8_t Hzk_size={size[0]};\n\n" + text_output += "static Chinese_t Hzk[] = {\n" line_size = size[0] * size[1] // 8 line_size = line_size // 2 # line_size = 16 if line_size >= 16 else 8 @@ -111,7 +111,7 @@ def format_chinese_array_as_text(chinese_array, size): text_output += '\n '.join(bytes_lines) text_output += ",\n }\n },\n" text_output += "};\n\n" - text_output += "Chinese_t* find_chinese_data(uint8_t unicode_high, uint8_t unicode_low) {\n" + text_output += "static Chinese_t* find_chinese_data(uint8_t unicode_high, uint8_t unicode_low) {\n" text_output += " for (int i = 0; i < sizeof(Hzk) / sizeof(Chinese_t); ++i) {\n" text_output += " if (Hzk[i].unicode[0] == unicode_high && Hzk[i].unicode[1] == unicode_low) {\n" text_output += " return &Hzk[i];\n" @@ -119,7 +119,7 @@ def format_chinese_array_as_text(chinese_array, size): text_output += " }\n" text_output += " return NULL;\n" text_output += "}\n" - text_output += "\n#endif //HW_LIB_OLED_FONT_CHUC_H" + text_output += "\n#endif //HW_LIB_FONT_CHUC_H" return text_output