还得移植lv的fs

This commit is contained in:
2026-02-19 22:39:34 +08:00
parent a0b94d9f7c
commit de2cca57a8
11 changed files with 307 additions and 62 deletions
@@ -1,4 +1,7 @@
#include "lv_helloworld.h"
#include "lv_load_font_from_spiffs.h"
static const char *TAG = "DEMO1";
LV_FONT_DECLARE(my_cn_font);
@@ -7,12 +10,21 @@ LV_FONT_DECLARE(my_cn_font);
*/
void lv_example_get_started_1(void)
{
// 1. 加载中文字体
lv_font_t* cn_font_16 = load_chinese_font_from_spiffs("/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, &my_cn_font); // 关键:设置字体
//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());
@@ -2,6 +2,7 @@
#define LV_HELLOWORLD_H
#include "lvgl.h"
#include "esp_log.h"
void lv_example_get_started_1(void);