2 #include "oswald_strings.h"
3 #include "oswald_fonts.h"
5 #include "oswald_graphics.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);
25 void oswald_draw_Line(uint8_t xstart, uint8_t ystart, uint8_t xend, uint8_t yend)
27 uint8_t x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
32 incx = (dx >= 0) ? 1 : -1;
33 incy = (dy >= 0) ? 1 : -1;
53 hal_lcd_set_pixel(x, y, TRUE);
55 for (t = 0; t < el; ++t) {
65 hal_lcd_set_pixel(x, y, TRUE);
67 hal_lcd_update_display();
70 void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness)
72 int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err;
77 incx = (dx >= 0) ? 1 : -1;
78 incy = (dy >= 0) ? 1 : -1;
98 hal_lcd_set_pixel(x, y, TRUE);
99 for (i=1; i<thickness; i++) {
100 hal_lcd_set_pixel(x-i, y, TRUE);
101 hal_lcd_set_pixel(x+i, y, TRUE);
102 hal_lcd_set_pixel(x, y-i, TRUE);
103 hal_lcd_set_pixel(x, y+i, TRUE);
106 for (t = 0; t < el; ++t) {
116 hal_lcd_set_pixel(x, y, TRUE);
117 for (i=1; i<thickness; i++) {
118 hal_lcd_set_pixel(x-i, y, TRUE);
119 hal_lcd_set_pixel(x+i, y, TRUE);
120 hal_lcd_set_pixel(x, y-i, TRUE);
121 hal_lcd_set_pixel(x, y+i, TRUE);
124 hal_lcd_update_display();
127 u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character)
130 u8t CharacterHeight = GetCharacterHeight();
131 u8t CharacterWidth = GetCharacterWidth(Character);
132 u16t bitmap[MAX_FONT_ROWS];
135 GetCharacterBitmap(Character, bitmap);
137 // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
138 for (ly=0; ly<CharacterHeight; ly++) {
139 for (lx=0; lx<CharacterWidth; lx++) {
140 if (bitmap[ly] & (1<<lx)) {
141 hal_lcd_set_pixel(lx+x, ly+y, TRUE);
144 hal_lcd_set_pixel(lx+x, ly+y, FALSE);
151 return CharacterWidth + GetFontSpacing();
153 char *cdata = oswald_fonts[face].data[Character];
155 dbg_out("%c", cdata[1]);
159 void oswald_write_string(u8t x, u8t y, oswald_font_face face, u8t *str)
161 register lx, i, strl;
163 strl = oswald_strlen(str);
168 for (i=0; i<strl; i++) {
169 lx += WriteLcdCharacter(lx, y, str[i]);
174 void oswald_Write_number(u8t x, u8t y, oswald_font_face face, s16t number)
176 register lx, i, strl;
179 itoa(number, str, 10);
180 strl = oswald_strlen(str);
185 for (i=0; i<strl; i++) {
186 lx += WriteLcdCharacter(lx, y, str[i]);