Skip to content

lvgl: Add config to disable monochrome pixel software inversion #87928

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/shields/ssd1306/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions doc/releases/release-notes-4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
**********

Expand Down
4 changes: 4 additions & 0 deletions modules/lvgl/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions modules/lvgl/lvgl_display_mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down