il3ven
December 19, 2019, 11:16am
1
Description
I am trying to load a screen and it is not working properly.
What MCU/Processor/Board and compiler are you using?
nRF52840 but also tried it on Simulator and having the same problem.
What do you experience?
I create and load a screen but screen is showing all black.
What do you expect?
I expect proper screen to be loaded.
Code to reproduce
lv_obj_t *screen1 = lv_obj_create(NULL, NULL);
lv_obj_t *heading = lv_label_create(screen1, NULL);
lv_obj_set_width(heading, LV_HOR_RES - 2);
lv_label_set_text(heading, "Add Text");
lv_obj_align(heading, NULL, LV_ALIGN_IN_TOP_MID, 0, 0);
lv_scr_load(screen1);
I’ll test this later today when I get a chance, but in the meantime, maybe you could try calling lv_scr_load
before you put the label on screen? Does that work?
Wesley
December 20, 2019, 1:32am
3
The function “lv_scr_load” is working well in my simulator. Can you show demo screen by calling “demo_create”? Maybe there are some problems when you porting the GUI, or some issues in your display driver.
il3ven
December 23, 2019, 8:24am
4
I have stripped down the problem to this.
This code produces this output.
Code -
lv_theme_t * th = lv_theme_mono_init(210, NULL);
lv_theme_set_current(th);
screen1 = lv_obj_create(NULL, NULL);
heading = lv_label_create(screen1, NULL);
ui_heading_create(heading, "Add Text", LV_HOR_RES - 2, LV_ALIGN_IN_TOP_LEFT);
options = lv_btn_create(screen1, NULL);
ui_options_create(options);
lv_obj_set_event_cb(options, NULL);
back_arrow = lv_btn_create(screen1, NULL);
ui_back_btn_create(back_arrow);
lv_scr_load(screen1);
Output -
Creating the screen before setting the theme gives correct output.
Code -
screen1 = lv_obj_create(NULL, NULL);
lv_theme_t * th = lv_theme_mono_init(210, NULL);
lv_theme_set_current(th);
heading = lv_label_create(screen1, NULL);
ui_heading_create(heading, "Add Text", LV_HOR_RES - 2, LV_ALIGN_IN_TOP_LEFT);
options = lv_btn_create(screen1, NULL);
ui_options_create(options);
lv_obj_set_event_cb(options, NULL);
back_arrow = lv_btn_create(screen1, NULL);
ui_back_btn_create(back_arrow);
lv_scr_load(screen1);
Output -
il3ven
December 23, 2019, 8:28am
5
If I use lv_scr_act()
instead of creating a screen (Code Below). Then it works fine.
Code -
lv_theme_t * th = lv_theme_mono_init(210, NULL);
lv_theme_set_current(th);
lv_obj_t *scr = lv_scr_act()
//Then create buttons and text
It’s because the theme will be applied only to the objects created after loading the theme.