代码:
static lv_group_t *indev_group;
static void page_infomation_construct(void)
{
char buff[10];
g_page_infomation.root = lv_obj_create(NULL);
LV_LOG_WARN("g_page_infomation.root:%p", g_page_infomation.root);
if(g_page_infomation.root == NULL)
return;
lv_obj_t *penel = lv_obj_create(g_page_infomation.root);
LV_LOG_WARN("penel:%p", penel);
lv_obj_set_size(penel, PAGE_WIDTH, PAGE_HEIGHT);
lv_obj_clear_flag(penel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(penel, &g_style_bg, LV_PART_MAIN);
lv_obj_t *top_penel = lv_obj_create(penel);
lv_obj_set_size(top_penel, PAGE_WIDTH, PAGE_INFOMATION_TOP_HEIGHT);
lv_obj_clear_flag(top_penel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(top_penel, &g_style_bg, LV_PART_MAIN);
lv_obj_align(top_penel, LV_ALIGN_TOP_MID, 0, -13);
LV_LOG_WARN("top_penel:%p", top_penel);
lv_obj_t *name_label = lv_label_create(top_penel);
lv_obj_set_style_text_font(name_label, &lv_font_montserrat_24, LV_PART_MAIN);
lv_obj_align(name_label, LV_ALIGN_TOP_MID, 0, 5);
lv_label_set_text(name_label, “infomation”);
LV_LOG_WARN("name_label:%p", name_label);
lv_obj_t *info_penel = lv_obj_create(penel);
lv_obj_set_size(info_penel, PAGE_INFOMATION_BG_WEIGHT, PAGE_INFOMATION_BG_HEIGHT);
lv_obj_clear_flag(info_penel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(info_penel, &g_style_bg, LV_PART_MAIN);
lv_obj_set_style_radius(info_penel, 5, LV_PART_MAIN);
lv_obj_align(info_penel, LV_ALIGN_BOTTOM_MID, 0, 0);
lv_obj_t *hw_penel = lv_obj_create(info_penel);
lv_obj_set_size(hw_penel, PAGE_INFOMATION_VER_BG_WEIGHT, PAGE_INFOMATION_VER_BG_HEIGHT);
lv_obj_clear_flag(hw_penel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(hw_penel, &g_style_bg_default, LV_PART_MAIN);
lv_obj_set_style_radius(hw_penel, 5, LV_PART_MAIN);
lv_obj_align(hw_penel, LV_ALIGN_CENTER, 0, -30);
LV_LOG_WARN("hw_penel:%p", hw_penel);
lv_obj_t *hw_name_label = lv_label_create(hw_penel);
lv_obj_align(hw_name_label, LV_ALIGN_LEFT_MID, 0, 0);
lv_label_set_text(hw_name_label, "Hardware version:");
lv_obj_set_style_text_color(hw_name_label, lv_color_white(), LV_PART_MAIN);
LV_LOG_WARN("hw_name_label:%p", hw_name_label);
lv_obj_t *hw_label = lv_label_create(hw_penel);
lv_obj_align(hw_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_snprintf(buff, 10, "%d.%d", 0x10 / 16, 0x10 % 16);
lv_obj_set_style_text_color(hw_label, lv_color_white(), LV_PART_MAIN);
lv_label_set_text(hw_label, buff);
LV_LOG_WARN("hw_label:%p", hw_label);
lv_obj_t *sw_penel = lv_obj_create(info_penel);
lv_obj_set_size(sw_penel, PAGE_INFOMATION_VER_BG_WEIGHT, PAGE_INFOMATION_VER_BG_HEIGHT);
lv_obj_clear_flag(sw_penel, LV_OBJ_FLAG_SCROLLABLE);
lv_obj_add_style(sw_penel, &g_style_bg_default, LV_PART_MAIN);
lv_obj_set_style_radius(sw_penel, 5, LV_PART_MAIN);
lv_obj_align_to(sw_penel, hw_penel, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);
LV_LOG_WARN("sw_penel:%p", sw_penel);
lv_obj_t *sw_name_label = lv_label_create(sw_penel);
lv_obj_set_style_text_font(sw_name_label, &lv_font_montserrat_16, LV_PART_MAIN);
lv_obj_align(sw_name_label, LV_ALIGN_LEFT_MID, 0, 0);
lv_label_set_text(sw_name_label, "Software version:");
lv_obj_set_style_text_color(sw_name_label, lv_color_white(), LV_PART_MAIN);
LV_LOG_WARN("sw_name_label:%p", sw_name_label);
indev_group = lv_group_create();
page_indev_set_group(indev_group);
lv_group_set_default(indev_group);
LV_LOG_WARN("indev_group:%p", indev_group);
lv_obj_t *sw_label = lv_label_create(sw_penel);
lv_obj_set_style_text_font(sw_label, &lv_font_montserrat_16, LV_PART_MAIN);
lv_obj_align(sw_label, LV_ALIGN_RIGHT_MID, 0, 0);
lv_snprintf(buff, 10, "%d.%d",0x10 / 16, 0x10 % 16);
lv_obj_set_style_text_color(sw_label, lv_color_white(), LV_PART_MAIN);
lv_label_set_text(sw_label, buff);
lv_obj_add_event_cb(sw_label, page_infomation_back_cb, LV_EVENT_ALL, NULL);
lv_group_add_obj(indev_group, sw_label);
}
static void page_infomation_destruct(void)
{
if(g_page_infomation.root != NULL)
{
lv_obj_clean(g_page_infomation.root);
}
lv_group_focus_freeze(indev_group, true);
lv_group_remove_all_objs(indev_group);
lv_group_del(indev_group);
g_page_infomation.root = NULL;
indev_group = NULL;
}
执行顺序,page_infomation_construct()->page_infomation_destruct();
然后发现在lv_obj_clean()就卡死崩掉后台了。
求大佬有空可以帮解析解答,谢谢!