From b549d3a4f1a3cb62c96d291a2fab4992a92d501a Mon Sep 17 00:00:00 2001 From: heurist1 Date: Tue, 28 Feb 2023 19:00:11 +0000 Subject: [PATCH] Add ability to draw text with a transparent background (cherry picked from commit a15da2e136147b31ab53058871815c8eb759576a) --- firmware/common/lcd_ili9341.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/firmware/common/lcd_ili9341.cpp b/firmware/common/lcd_ili9341.cpp index 58b3f5ddc..51a238d95 100644 --- a/firmware/common/lcd_ili9341.cpp +++ b/firmware/common/lcd_ili9341.cpp @@ -606,12 +606,35 @@ void ILI9341::draw_bitmap( const ui::Color foreground, const ui::Color background ) { - lcd_start_ram_write(p, size); + // Not a transparent background + if (ui::Color::magenta().v!=background.v) + { + lcd_start_ram_write(p, size); - const size_t count = size.width() * size.height(); - for(size_t i=0; i> 3] & (1U << (i & 0x7)); - io.lcd_write_pixel(pixel ? foreground : background); + const size_t count = size.width() * size.height(); + for(size_t i=0; i> 3] & (1U << (i & 0x7)); + io.lcd_write_pixel(pixel ? foreground : background); + } + } + else + { + int x = p.x(); + int y = p.y(); + int maxX = x + size.width(); + const size_t count = size.width() * size.height(); + for(size_t i=0; i> 3] & (1U << (i & 0x7)); + if (pixel) { + draw_pixel(ui::Point(x,y), foreground); + } + // Move to the next pixel + x++; + if (x>=maxX){ + x = p.x(); + y++; + } + } } }