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