|
本帖最后由 981378640 于 2021-10-27 14:11 编辑
我这边使用的LVGL8+freetype加载ttf字体,实际内容是“软件正在升级,请勿断电断网!”,但显示效果如下图,不是每次都是显示的如下结果,只是偶尔几次出现如下的结果,请求大神指点一下什么原因,附上代码
- void lv_gui_upgrade_display(int type)
- {
- lv_obj_t *upgrade_bg_container = lv_obj_create(lv_scr_act()); // 基于屏幕创建了一个容器
- if (upgrade_bg_container == NULL)
- {
- printf("[%s:%d] create upgrade_bg_container failed\n", __FUNCTION__, __LINE__);
- return;
- }
- static lv_style_t style;
- lv_style_reset(&style);
- lv_style_init(&style); // 初始化样式
- lv_style_set_radius(&style, 0); // 设置样式的圆角弧度
- lv_style_set_border_width(&style, 0); // 设置边框宽度
- lv_style_set_bg_opa(&style, LV_OPA_COVER); // 设置样式背景的透明度,不透明
- lv_style_set_bg_color(&style, lv_color_hex(0x355EDC)); // 设置样式的背景色
- lv_style_set_pad_all(&style, 0); // 设置样式内部padding填充宽度
- lv_obj_add_style(upgrade_bg_container, &style, 0); // 给对象添加样式
- lv_obj_set_size(upgrade_bg_container, LV_PCT(100), LV_PCT(100));
- lv_obj_center(upgrade_bg_container); // 对象居屏幕中间显示
- lv_obj_t *text_label = lv_label_create(upgrade_bg_container);
- if (text_label == NULL)
- {
- printf("[%s:%d] create text_label obj failed\n", __FUNCTION__, __LINE__);
- return;
- }
- lv_obj_set_style_text_color(text_label, lv_color_white(), 0);
- lv_obj_set_style_text_font(text_label, (const lv_font_t *)(ft_info_40.font), 0);
- lv_obj_center(text_label);
- switch (type)
- {
- case SOFTWARE_UPGRADE_START:
- lv_label_set_text(text_label, "软件正在升级,请勿断电断网!"); // 设置文本内容
- break;
-
- case SOFTWARE_UPGRADE_START_ENG:
- lv_label_set_text(text_label, "Software is upgrading, do not power off!"); // 设置文本内容
- break;
- case OTA_UPGRADE_START:
- lv_label_set_text(text_label, "系统正在OTA升级,请勿断电断网!"); // 设置文本内容
- break;
- case OTA_UPGRADE_START_ENG:
- lv_label_set_text(text_label, "System is OTA upgrading, do not power off!"); // 设置文本内容
- break;
- default:
- break;
- }
- }
复制代码
|
|