X-Git-Url: https://git.karo-electronics.de/?p=oswald.git;a=blobdiff_plain;f=ui%2FLcdDisplay.c;h=f2652c2b7911412fe047502095cd06d9bde0a8f6;hp=ee88652ec12ed50b71ea9d5de9b309bf67423846;hb=e09935ae9396421171a3bc4e32320874a0bfd193;hpb=95bcec668def747ed77c38fe17f893c0d029bbbc diff --git a/ui/LcdDisplay.c b/ui/LcdDisplay.c index ee88652..f2652c2 100644 --- a/ui/LcdDisplay.c +++ b/ui/LcdDisplay.c @@ -1,9 +1,11 @@ #include #include #include +#include #include "oswald-ui.h" #include "Fonts.h" + #include "LcdDisplay.h" #define NUM_LCD_ROWS 96 @@ -11,12 +13,113 @@ #define MAX_FONT_ROWS ( 19 ) -gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character) +void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend) +{ + int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; + + dx = xend - xstart; + dy = yend - ystart; + + incx = (dx >= 0) ? 1 : -1; + incy = (dy >= 0) ? 1 : -1; + + if (dx<0) + dx = -dx; + if (dy<0) + dy = -dy; + + if (dx>dy) { + pdx = incx; pdy = 0; + ddx=incx; ddy=incy; + es =dy; el =dx; + } else { + pdx=0; pdy=incy; + ddx=incx; ddy=incy; + es =dx; el =dy; + } + + x = xstart; + y = ystart; + err = el/2; + lcd_set_pixel(x, y, TRUE); + + for (t = 0; t < el; ++t) { + err -= es; + if (err < 0) { + err += el; + x += ddx; + y += ddy; + } else { + x += pdx; + y += pdy; + } + lcd_set_pixel(x, y, TRUE); + } +} + +void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness) +{ + int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; + + dx = xend - xstart; + dy = yend - ystart; + + incx = (dx >= 0) ? 1 : -1; + incy = (dy >= 0) ? 1 : -1; + + if (dx<0) + dx = -dx; + if (dy<0) + dy = -dy; + + if (dx>dy) { + pdx = incx; pdy = 0; + ddx=incx; ddy=incy; + es =dy; el =dx; + } else { + pdx=0; pdy=incy; + ddx=incx; ddy=incy; + es =dx; el =dy; + } + + x = xstart; + y = ystart; + err = el/2; + lcd_set_pixel(x, y, TRUE); + for (i=1; i