Redraw screen content


I have added a switch to turn my LCD off and on.
and I check for its status with a pin at the esp32, to reinitialize the LCD and touch drivers.
but the screen stills black till I touch many parts of it.

How can I redraw all of the screen’s contents?

What have you tried so far?

lv_tabview_set_tab_act(tv, 0, LV_ANIM_ON);

but it isn’t enough the rest of the tap bar is still black tell I touch it.

you can invalidate the screen to force it refresh

But how would the screen be affected with this function?
What is it supposed to do be side refreshing the obj?

when lcd off you deinit the lcd hardware,after you switch it on,the drive already lost its content in its you need to resend all the screen data to the driver.

Actually I don’t deinit the lvgl display.
Nor the spi driver.
I just reinit the lcd and touch drivers, after they got repowered.
So the screen is containing the same display.
Just wanted to refresh it once.
To redraw them

You reinit the lcd,the ram content in it is already gone.I know you didn’t deinit the lvgl and spi,but you deinit the lcd hardware driver,it has the screen data in it, lvgl just send the changed screen data to it.
So if you want all the screen to show right,you need to send screen data to it after reinit lcd hardware driver.

@Pupil is correct; you can use lv_obj_invalidate(lv_scr_act()) to force a redraw of whatever the display was drawing previously.

Ok, thanks
Just asking for any side effects for this function.
I didn’t get what its purpose from the documentation.

By default LVGL tracks what objects you are changing and only redraws the portions of the screen that actually changed.

lv_obj_invalidate(lv_scr_act() tells LVGL that the entire screen has changed and needs to be redrawn.

1 Like