From d525200a11b7c1e8172f084ce3677bf4a122382a Mon Sep 17 00:00:00 2001 From: gemu Date: Wed, 14 Aug 2024 13:08:17 +0200 Subject: [PATCH] BW invert (#21955) * bw invert option * invert bw --- .../Display_Renderer-gemu-1.0/src/renderer.h | 2 +- lib/lib_display/UDisplay/uDisplay.cpp | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h index 3abe7800b..a40e28f9f 100644 --- a/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h +++ b/lib/lib_display/Display_Renderer-gemu-1.0/src/renderer.h @@ -36,7 +36,7 @@ typedef struct LVGL_PARAMS { uint8_t swap_color : 1; uint8_t async_dma : 1; // force DMA completion before returning, avoid conflict with other devices on same bus. If set you should make sure the display is the only device on the bus uint8_t busy_invert : 1; - uint8_t resvd_2 : 1; + uint8_t invert_bw : 1; uint8_t resvd_3 : 1; uint8_t resvd_4 : 1; uint8_t resvd_5 : 1; diff --git a/lib/lib_display/UDisplay/uDisplay.cpp b/lib/lib_display/UDisplay/uDisplay.cpp index 5b572177d..194d85afe 100755 --- a/lib/lib_display/UDisplay/uDisplay.cpp +++ b/lib/lib_display/UDisplay/uDisplay.cpp @@ -2197,12 +2197,22 @@ void uDisplay::pushColorsMono(uint16_t *data, uint16_t len, bool rgb16_swap) { for (uint32_t y = seta_yp1; y < seta_yp2; y++) { seta_yp1++; - for (uint32_t x = seta_xp1; x < seta_xp2; x++) { - uint16_t color = *data++; - if (bpp == 1) color = (color & rgb16_to_mono_mask) ? 1 : 0; - drawPixel(x, y, color); // todo - inline the method to save speed - len--; - if (!len) return; // failsafe - exist if len (pixel number) is exhausted + if (lvgl_param.invert_bw) { + for (uint32_t x = seta_xp1; x < seta_xp2; x++) { + uint16_t color = *data++; + if (bpp == 1) color = (color & rgb16_to_mono_mask) ? 0 : 1; + drawPixel(x, y, color); // todo - inline the method to save speed + len--; + if (!len) return; // failsafe - exist if len (pixel number) is exhausted + } + } else { + for (uint32_t x = seta_xp1; x < seta_xp2; x++) { + uint16_t color = *data++; + if (bpp == 1) color = (color & rgb16_to_mono_mask) ? 1 : 0; + drawPixel(x, y, color); // todo - inline the method to save speed + len--; + if (!len) return; // failsafe - exist if len (pixel number) is exhausted + } } } }