Skip to content

Commit 65e21f0

Browse files
pdgendtfabiobaltieri
authored andcommitted
modules: lvgl: Optional BGR888 to RGB888
Some display controllers allow to work with BGR888 directly, a significant reduction in CPU load is gained this way. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent aab3586 commit 65e21f0

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

modules/lvgl/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ config LV_Z_COLOR_MONO_HW_INVERSION
9898
bool "Hardware pixel inversion (disables software pixel inversion)."
9999
depends on LV_COLOR_DEPTH_1
100100

101+
config LV_Z_COLOR_24_BGR_TO_RGB
102+
bool "Convert BGR888 to RGB888 color before flushing"
103+
default y
104+
depends on LV_COLOR_DEPTH_24
105+
101106
config LV_Z_FLUSH_THREAD
102107
bool "Flush LVGL frames in a separate thread"
103108
help

modules/lvgl/lvgl_display_24bit.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ void lvgl_flush_cb_24bit(lv_display_t *display, const lv_area_t *area, uint8_t *
2424
flush.desc.height = h;
2525
flush.buf = (void *)px_map;
2626

27-
/* LVGL assumes BGR byte ordering, convert to RGB */
28-
for (size_t i = 0; i < flush.desc.buf_size; i += 3) {
29-
uint8_t tmp = px_map[i];
27+
if (IS_ENABLED(CONFIG_LV_Z_COLOR_24_BGR_TO_RGB)) {
28+
/* LVGL assumes BGR byte ordering, convert to RGB */
29+
for (size_t i = 0; i < flush.desc.buf_size; i += 3) {
30+
uint8_t tmp = px_map[i];
3031

31-
px_map[i] = px_map[i + 2];
32-
px_map[i + 2] = tmp;
32+
px_map[i] = px_map[i + 2];
33+
px_map[i + 2] = tmp;
34+
}
3335
}
3436

3537
lvgl_flush_display(&flush);

0 commit comments

Comments
 (0)