Description
I’ve successfully implemented LVGL into my project, but I’d like my display flush function only to be called when LVGL has actually changed something on the screen. I.e, is there a option to only flush to the display when objects on screen are dirty/invalid? I can do this manually with a global variable that enables and disables flushing, but animations handled by LVGL are broken with my implementation. Code below.
For example, if the initial screen shows two buttons, LVGL should update once to show the buttons, then flushes if and only if the end user presses the button. In the above scenario, there would just be two calls of the flush function.
What MCU/Processor/Board and compiler are you using?
Raspberry Pi 4 using gcc
What LVGL version are you using?
LVGL 8.3.8
What do you want to achieve?
I want LVGL to natively call the display callback if and only if the screen changes.
What have you tried so far?
I’m using a global variable to enable and disable flushing. I enable flushing in event callbacks and disable it after calling the display flush function.
Code to reproduce
The below is partially functionaly, but animations are broken as LVGL has no way to change my global disp_flush_enabled
variable.
// I call this in event callbacks to enable flushing
void disp_enable_update(void)
{
disp_flush_enabled = true;
}
void disp_disable_update(void)
{
disp_flush_enabled = false;
}
static void disp_flush(lv_disp_drv_t *disp_drv, const lv_area_t * area, lv_color_t *color_p)
{
if (disp_flush_enabled){
flush_to_display(buffer_copy);
disp_disable_update();
}
lv_disp_flush_ready(disp_drv); // inform LVGL we're ready to flush
}
Screenshot and/or video
n/a