Skip to content

Commit

Permalink
lvgl: call display_flush at the end of a frame
Browse files Browse the repository at this point in the history
In frames with multiple writes (officially supported through
`CONFIG_LV_Z_VDB_SIZE`) the display needs to be signalled that the
current frame is over and the content should be displayed.
This allows displays to present the UI without tearing artifacts.

Signed-off-by: Martin Stumpf <martin.stumpf@vected.de>
  • Loading branch information
mstumpf-vected committed Oct 17, 2024
1 parent b172aed commit 2eddb88
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/lvgl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ config LV_Z_FLUSH_THREAD_STACK_SIZE
default 1024
help
Stack size for LVGL flush thread, which will call display_write
and display_flush

config LV_Z_FLUSH_THREAD_PRIO
int "LVGL flush thread priority"
Expand Down
13 changes: 11 additions & 2 deletions modules/lvgl/lvgl_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ void lvgl_flush_thread_entry(void *arg1, void *arg2, void *arg3)
while (1) {
k_msgq_get(&flush_queue, &flush, K_FOREVER);
data = (struct lvgl_disp_data *)flush.disp_drv->user_data;
const bool is_last = lv_disp_flush_is_last(flush.disp_drv);

display_write(data->display_dev, flush.x, flush.y, &flush.desc,
flush.buf);

lv_disp_flush_ready(flush.disp_drv);
k_sem_give(&flush_complete);

if (is_last) {
display_flush(data->display_dev);
}
}
}

Expand Down Expand Up @@ -129,11 +134,15 @@ void lvgl_flush_display(struct lvgl_display_flush *request)
k_yield();
#else
/* Write directly to the display */
struct lvgl_disp_data *data =
(struct lvgl_disp_data *)request->disp_drv->user_data;
struct lvgl_disp_data *data = (struct lvgl_disp_data *)request->disp_drv->user_data;
const bool is_last = lv_disp_flush_is_last(request->disp_drv);

display_write(data->display_dev, request->x, request->y,
&request->desc, request->buf);
lv_disp_flush_ready(request->disp_drv);

if (is_last) {
display_flush(data->display_dev);
}
#endif
}
4 changes: 4 additions & 0 deletions modules/lvgl/lvgl_display_mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ void lvgl_flush_cb_mono(lv_disp_drv_t *disp_drv, const lv_area_t *area, lv_color
display_write(display_dev, area->x1, area->y1, &desc, (void *)color_p);
}

if (is_last) {
display_flush(display_dev);
}

if (is_epd && is_last && data->blanking_on) {
/*
* The entire screen has now been rendered. Update the
Expand Down

0 comments on commit 2eddb88

Please sign in to comment.