2 #include "oswald_hal.h"
3 #include "oswald_strings.h"
6 #include "LcdDisplay.h"
8 void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp)
13 // we only draw set pixel, unset pixel remain as they are
14 for (y=0; y<height; y++) {
15 for (x=0; x<width; x++) {
16 cb = (uint8_t *)(bmp + (y * ((width / 8)+((width % 8) ? 1:0))) + (x / 8));
17 if (*cb & (1 << (x % 8)))
18 hal_lcd_set_pixel(xstart + x, ystart + y, TRUE);
23 void DrawLcdLineBresenham(u8t xstart, u8t ystart, u8t xend, u8t yend)
25 int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
30 incx = (dx >= 0) ? 1 : -1;
31 incy = (dy >= 0) ? 1 : -1;
51 hal_lcd_set_pixel(x, y, TRUE);
53 for (t = 0; t < el; ++t) {
63 hal_lcd_set_pixel(x, y, TRUE);
65 // lcd_update_display();
68 void DrawLcdLineBresenhamWW(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness)
70 int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
75 incx = (dx >= 0) ? 1 : -1;
76 incy = (dy >= 0) ? 1 : -1;
96 hal_lcd_set_pixel(x, y, TRUE);
97 for (i=1; i<thickness; i++) {
98 hal_lcd_set_pixel(x-i, y, TRUE);
99 hal_lcd_set_pixel(x+i, y, TRUE);
100 hal_lcd_set_pixel(x, y-i, TRUE);
101 hal_lcd_set_pixel(x, y+i, TRUE);
104 for (t = 0; t < el; ++t) {
114 hal_lcd_set_pixel(x, y, TRUE);
115 for (i=1; i<thickness; i++) {
116 hal_lcd_set_pixel(x-i, y, TRUE);
117 hal_lcd_set_pixel(x+i, y, TRUE);
118 hal_lcd_set_pixel(x, y-i, TRUE);
119 hal_lcd_set_pixel(x, y+i, TRUE);
122 // lcd_update_display();
125 u8t WriteLcdCharacter(u8t x, u8t y, u8t Character)
127 u8t CharacterHeight = GetCharacterHeight();
128 u8t CharacterWidth = GetCharacterWidth(Character);
129 u16t bitmap[MAX_FONT_ROWS];
132 GetCharacterBitmap(Character, bitmap);
134 // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
135 for (ly=0; ly<CharacterHeight; ly++) {
136 for (lx=0; lx<CharacterWidth; lx++) {
137 if (bitmap[ly] & (1<<lx)) {
138 hal_lcd_set_pixel(lx+x, ly+y, TRUE);
141 hal_lcd_set_pixel(lx+x, ly+y, FALSE);
147 // lcd_update_display();
148 return CharacterWidth + GetFontSpacing();
151 u8t WriteLcdString(u8t x, u8t y, char *str)
155 strl = oswald_strlen(str);
160 for (i=0; i<strl; i++) {
161 lx += WriteLcdCharacter(lx, y, str[i]);
167 void WriteLcdNumber(u8t x, u8t y, s16t number)
172 itoa(number, str, 10);
173 strl = oswald_strlen(str);
178 for (i=0; i<strl; i++) {
179 lx += WriteLcdCharacter(lx, y, str[i]);