还是迁移回lvgl8吧

Signed-off-by: kevin <kevin@lmve.net>
This commit is contained in:
2026-02-24 00:25:06 +08:00
parent da7ed99c15
commit f5d8c90b12
7 changed files with 41 additions and 9 deletions
@@ -127,6 +127,7 @@ void app_main(void)
// lcd_send_full_buf();
// t = custom_tick_get();
// ESP_LOGI(TAG, "NOW is%lu", t);
//this_work_loop();
lv_task_handler();
vTaskDelay(1); // 必须让出CPU
@@ -8,27 +8,44 @@ LV_FONT_DECLARE(my_cn_font);
/**
* Create styles from scratch for buttons.
*/
unsigned int t=0;
char str[32]={0};
lv_obj_t *label3 ; //lv_label_create(lv_screen_active()); /*Add a label to the button*/
static lv_style_t style_label;
void this_work_loop(){
t++;
//sprintf(str,"xxx:%lu",t);
//lv_label_set_text(label3, str);
//lv_obj_add_style(label3, &style_label, 0);
lv_label_set_text_fmt(label3,"这是啥xxx:%d",t);
}
void lv_example_get_started_1(void)
{
// 1. 加载中文字体
lv_font_t* cn_font_16 = load_chinese_font_from_spiffs("S:/spiffs/cn_font.bin");
if (cn_font_16 == NULL) {
ESP_LOGE(TAG, "无法加载中文字体,使用默认字体");
cn_font_16 = &my_cn_font; // 回退到默认字体
lv_font_t *cn_font_16 = &my_cn_font; // load_chinese_font_from_spiffs("S:/spiffs/cn_font.bin");
if (cn_font_16 == NULL)
{
ESP_LOGE(TAG, "无法加载中文字体");
// cn_font_16 = &my_cn_font; // 回退到默认字体
}
/*Change the active screen's background color*/
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN);
static lv_style_t style_label;
lv_style_init(&style_label);
lv_style_set_text_font(&style_label, cn_font_16); // 关键:设置字体
//lv_style_set_text_font(&style_label, cn_font_16); // 关键:设置字体
/*Create a white label, set its text and align it to the center*/
lv_obj_t *label = lv_label_create(lv_screen_active());
lv_obj_add_style(label, &style_label, 0);
//lv_obj_add_style(label, &style_label, 0);
lv_label_set_text(label, "Hello world 你好世界!");
lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN);
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
@@ -40,4 +57,15 @@ void lv_example_get_started_1(void)
lv_obj_t *label2 = lv_label_create(btn); /*Add a label to the button*/
lv_label_set_text(label2, "Button"); /*Set the labels text*/
lv_obj_center(label2);
label3=lv_label_create(lv_screen_active()); /*Add a label to the button*/
//lv_label_set_text(label3, "xxx:"); /*Set the labels text*/
lv_obj_set_pos(label3, 200, 150);
lv_timer_create(this_work_loop, 1000, NULL);
}
@@ -5,5 +5,6 @@
#include "esp_log.h"
void lv_example_get_started_1(void);
void this_work_loop();
#endif
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
lv_font_conv --font HarmonyOS_Sans_SC_Regular.ttf --size 16 --bpp 1 --range 0x20-0x7F --range 0x3000-0x303F --format bin --output cn_font.bin
+1
View File
@@ -0,0 +1 @@
lv_font_conv --font HarmonyOS_Sans_SC_Regular.ttf --size 16 --bpp 1 --symbols "你好世界ABC123℃" --format bin --output test_cn_font.bin
Binary file not shown.