Flash when having switched screen

I want to switch screen to display two different screen,like mainUI with button “setup”,and when I clicked the button,it jump to settingUI.

I found when running function “lv_obj_clean”, the littlevgl will clean the screen first that causing the display flash.
How to solve it or other way to avoid it.

my code:
void main(void)
{
hres = lv_disp_get_hor_res(NULL);
vres = lv_disp_get_ver_res(NULL);
baseObj = lv_obj_create(lv_scr_act(), NULL);
lv_obj_set_size(baseObj, hres, vres);
lv_obj_set_pos(baseObj,0,0);

mainUI();

}

void mainUI(void)
{
if(lv_obj_get_child(baseObj,NULL))
lv_obj_clean(baseObj);

lv_obj_t* img = lv_img_create(baseObj,NULL);
lv_img_set_src(img, &mainMenu);

}

void settingUI(void)
{
if(lv_obj_get_child(baseObj,NULL))
lv_obj_clean(baseObj);

lv_obj_t* img = lv_img_create(baseObj,NULL);
lv_img_set_src(img, &mainMenu);

}

Have your root background color set to black.

If I understand you well, and if your problem is the flashing when you switch between two screens, you can use double buffering to avoid the flash.

Or make two screens, and generate the objects on them, and just use lv_scr_load(); function to switch between screens.
for example:
void load_scr1(void) {
lv_scr_load(screen1);
}

I have used double buffering.
The code is
lv_disp_buf_init(&disp_buf_1, GETPOINT16(frame2,0,0), GETPOINT16(frame1,0,0), LV_HOR_RES_MAX * LV_VER_RES_MAX);

I will try your way.
Thanks.

Thank you.
Can you tell how to set the color?

The init for double framebuffer is wrong.
It solved

1 Like