main
JiXieShi 2024-09-21 13:18:06 +08:00
parent 919a9ed1a7
commit 4e53f936d8
5 changed files with 45 additions and 39 deletions

View File

@ -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})

View File

@ -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) {

View File

@ -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

16
main.c
View File

@ -1,14 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.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_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 <windows.h>

View File

@ -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