2 #include "oswald_hal.h"
3 #include "oswald_strings.h"
6 #include "LcdDisplay.h"
9 void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp)
14 // we only draw set pixel, unset pixel remain as they are
15 for (y=0; y<height; y++) {
16 for (x=0; x<width; x++) {
17 cb = (uint8_t *)(bmp + (y * ((width / 8)+((width % 8) ? 1:0))) + (x / 8));
18 if (*cb & (1 << (x % 8)))
19 hal_lcd_set_pixel(xstart + x, ystart + y, TRUE);
24 void DrawLcdLineBresenham(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend)
26 int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
31 incx = (dx >= 0) ? 1 : -1;
32 incy = (dy >= 0) ? 1 : -1;
52 hal_lcd_set_pixel(x, y, TRUE);
54 for (t = 0; t < el; ++t) {
64 hal_lcd_set_pixel(x, y, TRUE);
66 // lcd_update_display();
69 void DrawLcdLineBresenhamWW(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness)
71 int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
76 incx = (dx >= 0) ? 1 : -1;
77 incy = (dy >= 0) ? 1 : -1;
97 hal_lcd_set_pixel(x, y, TRUE);
98 for (i=1; i<thickness; i++) {
99 hal_lcd_set_pixel(x-i, y, TRUE);
100 hal_lcd_set_pixel(x+i, y, TRUE);
101 hal_lcd_set_pixel(x, y-i, TRUE);
102 hal_lcd_set_pixel(x, y+i, TRUE);
105 for (t = 0; t < el; ++t) {
115 hal_lcd_set_pixel(x, y, TRUE);
116 for (i=1; i<thickness; i++) {
117 hal_lcd_set_pixel(x-i, y, TRUE);
118 hal_lcd_set_pixel(x+i, y, TRUE);
119 hal_lcd_set_pixel(x, y-i, TRUE);
120 hal_lcd_set_pixel(x, y+i, TRUE);
123 // lcd_update_display();
126 u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character)
128 u8t CharacterHeight = GetCharacterHeight();
129 u8t CharacterWidth = GetCharacterWidth(Character);
130 u16t bitmap[MAX_FONT_ROWS];
133 GetCharacterBitmap(Character, bitmap);
135 // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
136 for (ly=0; ly<CharacterHeight; ly++) {
137 for (lx=0; lx<CharacterWidth; lx++) {
138 if (bitmap[ly] & (1<<lx)) {
139 hal_lcd_set_pixel(lx+x, ly+y, TRUE);
142 hal_lcd_set_pixel(lx+x, ly+y, FALSE);
148 // lcd_update_display();
149 return CharacterWidth + GetFontSpacing();
152 u8t WriteLcdString(const uint8_t x, const uint8_t y, const char *str)
156 strl = oswald_strlen((char *)str);
161 for (i=0; i<strl; i++) {
162 lx += WriteLcdCharacter(lx, y, str[i]);
168 void WriteLcdNumber(const uint8_t x, const uint8_t y, const int16_t number)
173 itoa(number, str, 10);
174 strl = oswald_strlen(str);
179 for (i=0; i<strl; i++) {
180 lx += WriteLcdCharacter(lx, y, str[i]);