From 5d0b5d427a24a18088dca9bad89c72f430de389d Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 3 Feb 2016 10:33:54 -0800 Subject: [PATCH] Extract draw_bitmap from draw_glyph. --- firmware/common/lcd_ili9341.cpp | 25 +++++++++++++++++-------- firmware/common/lcd_ili9341.hpp | 8 ++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/firmware/common/lcd_ili9341.cpp b/firmware/common/lcd_ili9341.cpp index cad5747b5..0f0dd319d 100644 --- a/firmware/common/lcd_ili9341.cpp +++ b/firmware/common/lcd_ili9341.cpp @@ -299,20 +299,29 @@ void ILI9341::draw_pixels( io.lcd_write_pixels(colors, count); } +void ILI9341::draw_bitmap( + const ui::Point p, + const ui::Size size, + const uint8_t* const pixels, + const ui::Color foreground, + const ui::Color background +) { + lcd_start_ram_write(p, size); + + const size_t count = size.w * size.h; + for(size_t i=0; i> 3] & (1U << (i & 0x7)); + io.lcd_write_pixel(pixel ? foreground : background); + } +} + void ILI9341::draw_glyph( const ui::Point p, const ui::Glyph& glyph, const ui::Color foreground, const ui::Color background ) { - lcd_start_ram_write(p, glyph.size()); - - const size_t count = glyph.w() * glyph.h(); - const auto pixels = glyph.pixels(); - for(size_t i=0; i> 3] & (1U << (i & 0x7)); - io.lcd_write_pixel(pixel ? foreground : background); - } + draw_bitmap(p, glyph.size(), glyph.pixels(), foreground, background); } void ILI9341::scroll_set_area( diff --git a/firmware/common/lcd_ili9341.hpp b/firmware/common/lcd_ili9341.hpp index 3b688f837..7c5cda381 100644 --- a/firmware/common/lcd_ili9341.hpp +++ b/firmware/common/lcd_ili9341.hpp @@ -65,6 +65,14 @@ public: draw_pixels(r, colors.data(), colors.size()); } + void draw_bitmap( + const ui::Point p, + const ui::Size size, + const uint8_t* const data, + const ui::Color foreground, + const ui::Color background + ); + void draw_glyph( const ui::Point p, const ui::Glyph& glyph,