From f2d9db024c33a35d97222b06c7ada112eea3c68a Mon Sep 17 00:00:00 2001 From: Federico Amedeo Izzo Date: Wed, 18 Nov 2020 16:56:32 +0100 Subject: [PATCH] Graphics: Add drawHLine and drawVLine functions --- openrtx/include/interfaces/graphics.h | 17 +++++++++++++++++ openrtx/src/graphics/graphics_bw.c | 12 ++++++++++++ openrtx/src/graphics/graphics_rgb565.c | 12 ++++++++++++ 3 files changed, 41 insertions(+) diff --git a/openrtx/include/interfaces/graphics.h b/openrtx/include/interfaces/graphics.h index 1d828f32..9e8f47a5 100644 --- a/openrtx/include/interfaces/graphics.h +++ b/openrtx/include/interfaces/graphics.h @@ -172,6 +172,23 @@ void gfx_setPixel(point_t pos, color_t color); */ void gfx_drawLine(point_t start, point_t end, color_t color); + +/** + * Draw a horizontal line with specified vertical position and width. + * @param y: vertical position, in pixel coordinates. + * @param height: line height, in pixel coordinates. + * @param color: line color, in color_t format. + */ +void gfx_drawHLine(uint16_t y, uint16_t height, color_t color); + +/** + * Draw a vertical line with specified horizontal position and width. + * @param x: horizontal position, in pixel coordinates. + * @param width: line width, in pixel coordinates. + * @param color: line color, in color_t format. + */ +void gfx_drawVLine(uint16_t x, uint16_t width, color_t color); + /** * Draw a rectangle of specified width, height and color. * @param width: rectangle width, in pixels, borders included. diff --git a/openrtx/src/graphics/graphics_bw.c b/openrtx/src/graphics/graphics_bw.c index 0c21cedf..4b332801 100644 --- a/openrtx/src/graphics/graphics_bw.c +++ b/openrtx/src/graphics/graphics_bw.c @@ -157,6 +157,18 @@ void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color, } } +void gfx_drawHLine(uint16_t y, uint16_t height, color_t color) +{ + point_t start = {0, y}; + gfx_drawRect(start, SCREEN_WIDTH, height, color, 1); +} + +void gfx_drawVLine(uint16_t x, uint16_t width, color_t color) +{ + point_t start = {x, 0}; + gfx_drawRect(start, width, SCREEN_HEIGHT, color, 1); +} + /** * Compute the pixel size of the first text line * @param f: font used as the source of glyphs diff --git a/openrtx/src/graphics/graphics_rgb565.c b/openrtx/src/graphics/graphics_rgb565.c index 833cf6ac..55e063b4 100644 --- a/openrtx/src/graphics/graphics_rgb565.c +++ b/openrtx/src/graphics/graphics_rgb565.c @@ -146,6 +146,18 @@ void gfx_drawRect(point_t start, uint16_t width, uint16_t height, color_t color, } } +void gfx_drawHLine(uint16_t y, uint16_t height, color_t color) +{ + point_t start = {0, y}; + gfx_drawRect(start, SCREEN_WIDTH, height, color, 1); +} + +void gfx_drawVLine(uint16_t x, uint16_t width, color_t color) +{ + point_t start = {x, 0}; + gfx_drawRect(start, width, SCREEN_HEIGHT, color, 1); +} + /** * Compute the pixel size of the first text line * @param f: font used as the source of glyphs