From 42ccc3ac28dcf0cd36d373452d2182caabafff00 Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Sun, 29 Nov 2020 08:43:58 +0100 Subject: [PATCH] GFX: Add gfx_clearRows() implementation --- openrtx/include/interfaces/graphics.h | 13 ++++++++++++- openrtx/src/graphics/graphics_rgb565.c | 10 ++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/openrtx/include/interfaces/graphics.h b/openrtx/include/interfaces/graphics.h index 9e8f47a5..a64e032b 100644 --- a/openrtx/include/interfaces/graphics.h +++ b/openrtx/include/interfaces/graphics.h @@ -147,7 +147,18 @@ void gfx_render(); bool gfx_renderingInProgress(); /** - * Makes the screen black. + * Clears a portion of the screen content + * This results in a black screen on color displays + * And a white screen on B/W displays + * @param startRow: first row of the framebuffer section to be cleared + * @param endRow: last row of the framebuffer section to be cleared + */ +void gfx_clearRows(uint8_t startRow, uint8_t endRow); + +/** + * Clears the content of the screen + * This results in a black screen on color displays + * And a white screen on B/W displays */ void gfx_clearScreen(); diff --git a/openrtx/src/graphics/graphics_rgb565.c b/openrtx/src/graphics/graphics_rgb565.c index bcb7487d..d627d06b 100644 --- a/openrtx/src/graphics/graphics_rgb565.c +++ b/openrtx/src/graphics/graphics_rgb565.c @@ -85,6 +85,16 @@ rgb565_t _true2highColor(color_t true_color) return high_color; } +void gfx_clearRows(uint8_t startRow, uint8_t endRow) +{ + if(!initialized) return; + if(endRow < startRow) return; + uint16_t start = startRow * SCREEN_WIDTH * sizeof(rgb565_t); + uint16_t height = endRow - startRow * SCREEN_WIDTH * sizeof(rgb565_t); + // Set the specified rows to 0x00 = make the screen black + memset(buf + start, 0x00, height); +} + void gfx_clearScreen() { if(!initialized) return;