From 6c343a4454f3a13fcddcdae3944716427aa2fa68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin-Charles=20Guih=C3=A9neuf?= Date: Thu, 17 Apr 2025 08:28:14 +0200 Subject: [PATCH 1/2] lvgl: Add config to disable monochrome pixel software inversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, pixel inversion is managed by the display hardware and software inversion is not required. Signed-off-by: Robin-Charles Guihéneuf --- doc/releases/release-notes-4.2.rst | 4 ++++ modules/lvgl/Kconfig | 4 ++++ modules/lvgl/lvgl_display_mono.c | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/doc/releases/release-notes-4.2.rst b/doc/releases/release-notes-4.2.rst index 0514cf8a77d3..77e24f2cec0c 100644 --- a/doc/releases/release-notes-4.2.rst +++ b/doc/releases/release-notes-4.2.rst @@ -212,6 +212,10 @@ New APIs and options * :kconfig:option:`CONFIG_NVME_PRP_PAGE_SIZE` +* Other + + * :kconfig:option:`CONFIG_LV_Z_COLOR_MONO_HW_INVERSION` + New Boards ********** diff --git a/modules/lvgl/Kconfig b/modules/lvgl/Kconfig index 8084dd11a332..01e1ef004dfd 100644 --- a/modules/lvgl/Kconfig +++ b/modules/lvgl/Kconfig @@ -94,6 +94,10 @@ config LV_COLOR_16_SWAP bool "Swap the 2 bytes of RGB565 color." depends on LV_COLOR_DEPTH_16 +config LV_Z_COLOR_MONO_HW_INVERSION + bool "Hardware pixel inversion (disables software pixel inversion)." + depends on LV_COLOR_DEPTH_1 + config LV_Z_FLUSH_THREAD bool "Flush LVGL frames in a separate thread" help diff --git a/modules/lvgl/lvgl_display_mono.c b/modules/lvgl/lvgl_display_mono.c index 09b9bfd2337f..069a0eea28bc 100644 --- a/modules/lvgl/lvgl_display_mono.c +++ b/modules/lvgl/lvgl_display_mono.c @@ -38,17 +38,25 @@ static ALWAYS_INLINE void set_px_at_pos(uint8_t *dst_buf, uint32_t x, uint32_t y } } +#ifdef CONFIG_LV_Z_COLOR_MONO_HW_INVERSION + *buf |= BIT(bit); +#else if (caps->current_pixel_format == PIXEL_FORMAT_MONO10) { *buf |= BIT(bit); } else { *buf &= ~BIT(bit); } +#endif } static void lvgl_transform_buffer(uint8_t **px_map, uint32_t width, uint32_t height, const struct display_capabilities *caps) { +#ifdef CONFIG_LV_Z_COLOR_MONO_HW_INVERSION + uint8_t clear_color = 0x00; +#else uint8_t clear_color = caps->current_pixel_format == PIXEL_FORMAT_MONO10 ? 0x00 : 0xFF; +#endif memset(mono_conv_buf, clear_color, mono_conv_buf_size); From 5876ba0ce5dd2905abe06550d300e0aebc998d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin-Charles=20Guih=C3=A9neuf?= Date: Mon, 31 Mar 2025 22:35:59 +0200 Subject: [PATCH 2/2] shields: ssd1306: Disable LVGL software screen inversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On this screen the inversion is managed by hardware. Signed-off-by: Robin-Charles Guihéneuf --- boards/shields/ssd1306/Kconfig.defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/boards/shields/ssd1306/Kconfig.defconfig b/boards/shields/ssd1306/Kconfig.defconfig index 3fc5d5a7c051..4ef59333d15c 100644 --- a/boards/shields/ssd1306/Kconfig.defconfig +++ b/boards/shields/ssd1306/Kconfig.defconfig @@ -17,6 +17,9 @@ config LV_DPI_DEF config LV_Z_BITS_PER_PIXEL default 1 +config LV_Z_COLOR_MONO_HW_INVERSION + default y + choice LV_COLOR_DEPTH default LV_COLOR_DEPTH_1 endchoice