... | ... |
@@ -193,6 +193,26 @@ void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t ch |
193 | 193 |
return; |
194 | 194 |
} |
195 | 195 |
|
196 |
+void oswald_writestr_font58(const unsigned int x1, unsigned int y1, const char *str, int *width, const uint8_t fg, const uint8_t bg) |
|
197 |
+{ |
|
198 |
+ int x,w; |
|
199 |
+ for(x=x1;*str!='\0';x+=w+1,str++) |
|
200 |
+ oswald_draw_font58(x, y1,*str,&w,fg,bg); |
|
201 |
+ *width=x-x1; |
|
202 |
+} |
|
203 |
+ |
|
204 |
+int oswald_getwidth_font58(char *str) |
|
205 |
+{ |
|
206 |
+ int total; |
|
207 |
+ int width; |
|
208 |
+ for(total=0;*str!='\0';str++) { |
|
209 |
+ if(oswald_getchar_font58(*str,&width)!=NULL) |
|
210 |
+ total+=width; |
|
211 |
+ total++; |
|
212 |
+ } |
|
213 |
+ return(total); |
|
214 |
+} |
|
215 |
+ |
|
196 | 216 |
void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg,const unsigned int scalex,const unsigned int scaley) |
197 | 217 |
{ |
198 | 218 |
int x,y,ix,iy; |
... | ... |
@@ -246,6 +266,25 @@ void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uin |
246 | 266 |
return; |
247 | 267 |
} |
248 | 268 |
|
269 |
+void oswald_writestr_font58_scaled(const unsigned int x1, unsigned int y1, const char *str, int *width, const uint8_t fg, const uint8_t bg,const unsigned int scalex,const unsigned int scaley) |
|
270 |
+{ |
|
271 |
+ int x,w; |
|
272 |
+ for(x=x1;*str!='\0';x+=w+1,str++) |
|
273 |
+ oswald_draw_font58_scaled(x, y1,*str,&w,fg,bg,scalex,scaley); |
|
274 |
+ *width=x-x1; |
|
275 |
+} |
|
276 |
+ |
|
277 |
+int oswald_getwidth_font58_scaled(char *str, int scalex, int scaley) |
|
278 |
+{ |
|
279 |
+ int total; |
|
280 |
+ int width; |
|
281 |
+ for(total=0;*str!='\0';str++) { |
|
282 |
+ if(oswald_getchar_font58(*str,&width)!=NULL) |
|
283 |
+ total+=width*scalex; |
|
284 |
+ total++; |
|
285 |
+ } |
|
286 |
+ return(total); |
|
287 |
+} |
|
249 | 288 |
|
250 | 289 |
void oswald_draw_microdigit(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
251 | 290 |
{ |
... | ... |
@@ -390,14 +429,6 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
390 | 429 |
} |
391 | 430 |
} |
392 | 431 |
|
393 |
-uint8_t oswald_getwidth_character(const oswald_font_face face, const uint8_t Character) |
|
394 |
-{ |
|
395 |
- int width; |
|
396 |
- if(oswald_getchar_font58(Character,&width)==NULL) |
|
397 |
- return(0); |
|
398 |
- return(width); |
|
399 |
-} |
|
400 |
- |
|
401 | 432 |
uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, |
402 | 433 |
const boolean invert, const uint8_t Character) |
403 | 434 |
{ |
... | ... |
@@ -406,18 +437,6 @@ uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_fo |
406 | 437 |
return width+1; |
407 | 438 |
} |
408 | 439 |
|
409 |
-int oswald_getwidth_string(const oswald_font_face face, char *str) |
|
410 |
-{ |
|
411 |
- int total; |
|
412 |
- int width; |
|
413 |
- for(total=0;*str!=NULL;str++) { |
|
414 |
- if(oswald_getchar_font58(*str,&width)!=NULL) |
|
415 |
- total+=width; |
|
416 |
- total++; |
|
417 |
- } |
|
418 |
- return(total); |
|
419 |
-} |
|
420 |
- |
|
421 | 440 |
void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, char *str) |
422 | 441 |
{ |
423 | 442 |
uint8_t lx, i, strl; |
... | ... |
@@ -152,15 +152,14 @@ void oswald_draw_grid(const unsigned int x1, const unsigned int y1, const unsign |
152 | 152 |
hal_lcd_set_pixel(x2-1,y2-1,1); |
153 | 153 |
} |
154 | 154 |
|
155 |
-void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
155 |
+static const uint8_t * |
|
156 |
+oswald_getchar_font58(const uint8_t character, int *width) |
|
156 | 157 |
{ |
157 |
- int bit; |
|
158 |
- int k; |
|
159 |
- uint8_t car; |
|
160 | 158 |
const uint8_t *ptr; |
161 |
- *width=0; |
|
162 |
- if(character<32 || character>255) |
|
163 |
- return; |
|
159 |
+ if(character<32 || character>255) { |
|
160 |
+ *width=0; |
|
161 |
+ return(NULL); |
|
162 |
+ } |
|
164 | 163 |
ptr=(font5x8+((character-32)<<2)); |
165 | 164 |
/* simple way to calc. the width */ |
166 | 165 |
*width=(((ptr[0]&0x02)||(ptr[1]&0x10)||(ptr[2]&0x84)||(ptr[3]&0x21))?5: |
... | ... |
@@ -168,6 +167,17 @@ void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t ch |
168 | 167 |
((ptr[0]&0x08)||(ptr[1]&0x42)||(ptr[2]&0x10)||(ptr[3]&0x84))?3: |
169 | 168 |
((ptr[0]&0x10)||(ptr[1]&0x84)||(ptr[2]&0x21)||(ptr[3]&0x08))?2: |
170 | 169 |
((ptr[0]&0x3f)||(ptr[1]&0xff)||(ptr[2]&0xff)||(ptr[3]&0xff))?2:1); |
170 |
+ return(ptr); |
|
171 |
+} |
|
172 |
+ |
|
173 |
+void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
174 |
+{ |
|
175 |
+ int bit; |
|
176 |
+ int k; |
|
177 |
+ uint8_t car; |
|
178 |
+ const uint8_t *ptr; |
|
179 |
+ if((ptr=oswald_getchar_font58(character,width))==NULL) |
|
180 |
+ return; |
|
171 | 181 |
if(ptr[0]&0x80) { |
172 | 182 |
oswald_draw_rect(x1,y1,x1+*width,y1+1,bg); |
173 | 183 |
if(ptr[0]&0x40) |
... | ... |
@@ -212,13 +222,8 @@ void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uin |
212 | 222 |
} |
213 | 223 |
} |
214 | 224 |
/* default case */ |
215 |
- ptr=(font5x8+((character-32)<<2)); |
|
216 |
- /* simple way to calc. the width */ |
|
217 |
- *width=(((ptr[0]&0x02)||(ptr[1]&0x10)||(ptr[2]&0x84)||(ptr[3]&0x21))?5: |
|
218 |
- ((ptr[0]&0x04)||(ptr[1]&0x21)||(ptr[2]&0x08)||(ptr[3]&0x42))?4: |
|
219 |
- ((ptr[0]&0x08)||(ptr[1]&0x42)||(ptr[2]&0x10)||(ptr[3]&0x84))?3: |
|
220 |
- ((ptr[0]&0x10)||(ptr[1]&0x84)||(ptr[2]&0x21)||(ptr[3]&0x08))?2: |
|
221 |
- ((ptr[0]&0x3f)||(ptr[1]&0xff)||(ptr[2]&0xff)||(ptr[3]&0xff))?2:1); |
|
225 |
+ if((ptr=oswald_getchar_font58(character,width))==NULL) |
|
226 |
+ return; |
|
222 | 227 |
if(ptr[0]&0x80) { |
223 | 228 |
if(ptr[0]&0x40) |
224 | 229 |
oswald_draw_rect(x1+(*width-1)*scalex,y1,x1+(*width-1+1)*scalex-1,y1+scaley-1,fg); |
... | ... |
@@ -385,6 +390,14 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
385 | 390 |
} |
386 | 391 |
} |
387 | 392 |
|
393 |
+uint8_t oswald_getwidth_character(const oswald_font_face face, const uint8_t Character) |
|
394 |
+{ |
|
395 |
+ int width; |
|
396 |
+ if(oswald_getchar_font58(Character,&width)==NULL) |
|
397 |
+ return(0); |
|
398 |
+ return(width); |
|
399 |
+} |
|
400 |
+ |
|
388 | 401 |
uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, |
389 | 402 |
const boolean invert, const uint8_t Character) |
390 | 403 |
{ |
... | ... |
@@ -393,6 +406,18 @@ uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_fo |
393 | 406 |
return width+1; |
394 | 407 |
} |
395 | 408 |
|
409 |
+int oswald_getwidth_string(const oswald_font_face face, char *str) |
|
410 |
+{ |
|
411 |
+ int total; |
|
412 |
+ int width; |
|
413 |
+ for(total=0;*str!=NULL;str++) { |
|
414 |
+ if(oswald_getchar_font58(*str,&width)!=NULL) |
|
415 |
+ total+=width; |
|
416 |
+ total++; |
|
417 |
+ } |
|
418 |
+ return(total); |
|
419 |
+} |
|
420 |
+ |
|
396 | 421 |
void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, char *str) |
397 | 422 |
{ |
398 | 423 |
uint8_t lx, i, strl; |
... | ... |
@@ -51,6 +51,17 @@ oswald_draw_point(const uint8_t color) |
51 | 51 |
gc.x%=gc.w; |
52 | 52 |
} |
53 | 53 |
|
54 |
+void |
|
55 |
+oswald_draw_point_transparent(const uint8_t color, const uint8_t transparent) |
|
56 |
+{ |
|
57 |
+ if(color!=transparent) |
|
58 |
+ hal_lcd_set_pixel(gc.x1+gc.x,gc.y1+gc.y,color); |
|
59 |
+ gc.x++; |
|
60 |
+ gc.y+=(gc.x/gc.w); |
|
61 |
+ gc.x%=gc.w; |
|
62 |
+} |
|
63 |
+ |
|
64 |
+ |
|
54 | 65 |
|
55 | 66 |
#if 0 |
56 | 67 |
void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart, uint8_t color) |
... | ... |
@@ -62,7 +73,7 @@ void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart, uin |
62 | 73 |
void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, |
63 | 74 |
const unsigned int xoff, const unsigned int yoff, |
64 | 75 |
const unsigned int width, const unsigned int height, |
65 |
- const boolean invert, |
|
76 |
+ const boolean fg, |
|
66 | 77 |
const unsigned int bmp_width, const unsigned int bmp_height, |
67 | 78 |
const void *bmp) |
68 | 79 |
{ |
... | ... |
@@ -72,25 +83,15 @@ void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystar |
72 | 83 |
if (bmp == NULL) |
73 | 84 |
return; |
74 | 85 |
|
75 |
- //g_printerr("dbmp %d,%d off %d,%d\n", xstart, ystart, width, height); |
|
76 | 86 |
cb = (uint8_t *)bmp; |
77 |
- //g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
78 | 87 |
// we only draw set pixel, unset pixel remain as they are |
79 | 88 |
for (y=yoff; y<bmp_height && y<height; y++) { |
80 | 89 |
for (x=xoff; x<bmp_width && x<width; x++) { |
81 | 90 |
cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
82 |
- // g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
83 | 91 |
if (*cb & (1 << (x % 8))) { |
84 |
- if (!invert) |
|
85 |
- hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
86 |
- // g_printerr("X"); |
|
87 |
- } else { |
|
88 |
- if (invert) |
|
89 |
- hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
90 |
- // g_printerr("."); |
|
92 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, fg); |
|
91 | 93 |
} |
92 | 94 |
} |
93 |
- //g_printerr("\n"); |
|
94 | 95 |
} |
95 | 96 |
} |
96 | 97 |
|
... | ... |
@@ -177,7 +178,7 @@ void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t ch |
177 | 178 |
oswald_set_draw_window(x1,y1,x1+4,y1+5); |
178 | 179 |
for(k=0;k<=3;++k) { |
179 | 180 |
for(bit=((k==0)?0x20:0x80),car=ptr[k];bit>0;bit>>=1) |
180 |
- oswald_draw_point((car&bit)?fg:bg); |
|
181 |
+ oswald_draw_point_transparent((car&bit)?fg:bg,bg); |
|
181 | 182 |
} |
182 | 183 |
return; |
183 | 184 |
} |
... | ... |
@@ -198,15 +199,15 @@ void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uin |
198 | 199 |
return; |
199 | 200 |
} else if(scalex==4 && scaley==5) { |
200 | 201 |
*width=16; |
201 |
- oswald_draw_bitmap_opts(x1,y1,(character-'0')*4*4,0,(character-'0')*4*4+16,font5x8scaledx4x5_height,!fg,font5x8scaledx4x5_width,font5x8scaledx4x5_height,font5x8scaledx4x5_bits); |
|
202 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*4*4,0,(character-'0')*4*4+16,font5x8scaledx4x5_height,fg,font5x8scaledx4x5_width,font5x8scaledx4x5_height,font5x8scaledx4x5_bits); |
|
202 | 203 |
return; |
203 | 204 |
} else if(scalex==2 && scaley==2) { |
204 | 205 |
*width=8; |
205 |
- oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x2_height,!fg,font5x8scaledx2x2_width,font5x8scaledx2x2_height,font5x8scaledx2x2_bits); |
|
206 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x2_height,fg,font5x8scaledx2x2_width,font5x8scaledx2x2_height,font5x8scaledx2x2_bits); |
|
206 | 207 |
return; |
207 | 208 |
} else if(scalex==2 && scaley==3) { |
208 | 209 |
*width=8; |
209 |
- oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x3_height,!fg,font5x8scaledx2x3_width,font5x8scaledx2x3_height,font5x8scaledx2x3_bits); |
|
210 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x3_height,fg,font5x8scaledx2x3_width,font5x8scaledx2x3_height,font5x8scaledx2x3_bits); |
|
210 | 211 |
return; |
211 | 212 |
} |
212 | 213 |
} |
... | ... |
@@ -219,12 +220,10 @@ void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uin |
219 | 220 |
((ptr[0]&0x10)||(ptr[1]&0x84)||(ptr[2]&0x21)||(ptr[3]&0x08))?2: |
220 | 221 |
((ptr[0]&0x3f)||(ptr[1]&0xff)||(ptr[2]&0xff)||(ptr[3]&0xff))?2:1); |
221 | 222 |
if(ptr[0]&0x80) { |
222 |
- oswald_draw_rect(x1,y1,x1+(4+1)*scalex-1,y1+(1+1)*scaley-1,bg); |
|
223 | 223 |
if(ptr[0]&0x40) |
224 | 224 |
oswald_draw_rect(x1+(*width-1)*scalex,y1,x1+(*width-1+1)*scalex-1,y1+scaley-1,fg); |
225 | 225 |
y1+=2*scaley; |
226 |
- } else |
|
227 |
- oswald_draw_rect(x1,y1+6*scaley,x1+(4+1)*scalex-1,y1+(7+1)*scaley-1,bg); |
|
226 |
+ } |
|
228 | 227 |
oswald_set_draw_window(x1,y1,x1+(4+1)*scalex-1,y1+(5+1)*scaley-1); |
229 | 228 |
for(y=0;y<6;y++) { |
230 | 229 |
for(iy=0;iy<scaley;iy++) { |
... | ... |
@@ -232,9 +231,9 @@ void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uin |
232 | 231 |
n=2+x+y*5; |
233 | 232 |
k=n>>3; |
234 | 233 |
b=n&0x7; |
235 |
- c=(ptr[k]&(0x80>>b))?1:0; |
|
234 |
+ c=(ptr[k]&(0x80>>b))?fg:bg; |
|
236 | 235 |
for(ix=0;ix<scalex;ix++) |
237 |
- oswald_draw_point(c); |
|
236 |
+ oswald_draw_point_transparent(c,bg); |
|
238 | 237 |
} |
239 | 238 |
} |
240 | 239 |
} |
... | ... |
@@ -252,7 +251,7 @@ void oswald_draw_microdigit(const unsigned int x1, unsigned int y1, const uint8_ |
252 | 251 |
car=((character>='0' && character<='9')?micronumbers[character-'0']:0x00); |
253 | 252 |
oswald_set_draw_window(x1,y1,x1+1,y1+3); |
254 | 253 |
for(bit=0x80;bit>0;bit>>=1) |
255 |
- oswald_draw_point((car&bit)?fg:bg); |
|
254 |
+ oswald_draw_point_transparent((car&bit)?fg:bg,bg); |
|
256 | 255 |
*width=3; |
257 | 256 |
return; |
258 | 257 |
} |
... | ... |
@@ -267,7 +266,7 @@ void oswald_draw_tinydigit(const unsigned int x1, unsigned int y1, const uint8_t |
267 | 266 |
car=((character>='0' && character<='9')?tinynumbers[character-'0']:0x00); |
268 | 267 |
oswald_set_draw_window(x1,y1,x1+2,y1+4); |
269 | 268 |
for(bit=0x4000;bit>0;bit>>=1) |
270 |
- oswald_draw_point((car&bit)?fg:bg); |
|
269 |
+ oswald_draw_point_transparent((car&bit)?fg:bg,bg); |
|
271 | 270 |
*width=4; |
272 | 271 |
return; |
273 | 272 |
} |
... | ... |
@@ -276,11 +275,11 @@ void oswald_draw_bigdigit(const unsigned int x1, unsigned int y1, const uint8_t |
276 | 275 |
{ |
277 | 276 |
*width=14; |
278 | 277 |
if(character>='0' && character<='9') |
279 |
- oswald_draw_bitmap_opts(x1,y1,(character-'0')*14,0,(character-'0')*14+14,fontbigdigits_height,!fg,fontbigdigits_width,fontbigdigits_height,fontbigdigits_bits); |
|
278 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*14,0,(character-'0')*14+14,fontbigdigits_height,fg,fontbigdigits_width,fontbigdigits_height,fontbigdigits_bits); |
|
280 | 279 |
return; |
281 | 280 |
} |
282 | 281 |
|
283 |
-void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) |
|
282 |
+void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t fg) |
|
284 | 283 |
{ |
285 | 284 |
int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
286 | 285 |
|
... | ... |
@@ -308,7 +307,7 @@ void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t |
308 | 307 |
x = xstart; |
309 | 308 |
y = ystart; |
310 | 309 |
err = el/2; |
311 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
310 |
+ hal_lcd_set_pixel(x, y, fg); |
|
312 | 311 |
|
313 | 312 |
for (t = 0; t < el; ++t) { |
314 | 313 |
err -= es; |
... | ... |
@@ -320,11 +319,11 @@ void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t |
320 | 319 |
x += pdx; |
321 | 320 |
y += pdy; |
322 | 321 |
} |
323 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
322 |
+ hal_lcd_set_pixel(x, y, fg); |
|
324 | 323 |
} |
325 | 324 |
} |
326 | 325 |
|
327 |
-void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
|
326 |
+void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t fg, const uint8_t thickness) |
|
328 | 327 |
{ |
329 | 328 |
int16_t i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
330 | 329 |
|
... | ... |
@@ -360,10 +359,10 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
360 | 359 |
err = el/2; |
361 | 360 |
hal_lcd_set_pixel(x, y, TRUE); |
362 | 361 |
for (i=1; i<thickness; i++) { |
363 |
- hal_lcd_set_pixel(x-i, y, TRUE); |
|
364 |
- hal_lcd_set_pixel(x+i, y, TRUE); |
|
365 |
- hal_lcd_set_pixel(x, y-i, TRUE); |
|
366 |
- hal_lcd_set_pixel(x, y+i, TRUE); |
|
362 |
+ hal_lcd_set_pixel(x-i, y, fg); |
|
363 |
+ hal_lcd_set_pixel(x+i, y, fg); |
|
364 |
+ hal_lcd_set_pixel(x, y-i, fg); |
|
365 |
+ hal_lcd_set_pixel(x, y+i, fg); |
|
367 | 366 |
} |
368 | 367 |
|
369 | 368 |
for (t = 0; t < el; ++t) { |
... | ... |
@@ -376,12 +375,12 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
376 | 375 |
x += pdx; |
377 | 376 |
y += pdy; |
378 | 377 |
} |
379 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
378 |
+ hal_lcd_set_pixel(x, y, fg); |
|
380 | 379 |
for (i=1; i<thickness; i++) { |
381 |
- hal_lcd_set_pixel(x-i, y, TRUE); |
|
382 |
- hal_lcd_set_pixel(x+i, y, TRUE); |
|
383 |
- hal_lcd_set_pixel(x, y-i, TRUE); |
|
384 |
- hal_lcd_set_pixel(x, y+i, TRUE); |
|
380 |
+ hal_lcd_set_pixel(x-i, y, fg); |
|
381 |
+ hal_lcd_set_pixel(x+i, y, fg); |
|
382 |
+ hal_lcd_set_pixel(x, y-i, fg); |
|
383 |
+ hal_lcd_set_pixel(x, y+i, fg); |
|
385 | 384 |
} |
386 | 385 |
} |
387 | 386 |
} |
... | ... |
@@ -4,243 +4,441 @@ |
4 | 4 |
#include "oswald_hal.h" |
5 | 5 |
|
6 | 6 |
#include "oswald_graphics.h" |
7 |
+#if defined(__GNUC__) && (__MSP430X__ > 0) |
|
8 |
+__attribute__((__far__)) |
|
9 |
+#endif |
|
10 |
+#include "fonts/font5x8scaledx4x5.xbm" |
|
11 |
+ |
|
12 |
+#if defined(__GNUC__) && (__MSP430X__ > 0) |
|
13 |
+__attribute__((__far__)) |
|
14 |
+#endif |
|
15 |
+#include "fonts/font5x8scaledx2x2.xbm" |
|
16 |
+ |
|
17 |
+#if defined(__GNUC__) && (__MSP430X__ > 0) |
|
18 |
+__attribute__((__far__)) |
|
19 |
+#endif |
|
20 |
+#include "fonts/font5x8scaledx2x3.xbm" |
|
21 |
+ |
|
22 |
+#if defined(__GNUC__) && (__MSP430X__ > 0) |
|
23 |
+__attribute__((__far__)) |
|
24 |
+#endif |
|
25 |
+#include "fonts/fontbigdigits.xbm" |
|
26 |
+ |
|
27 |
+#define LCD_WIDTH 96 |
|
28 |
+#define LCD_HEIGHT 96 |
|
29 |
+ |
|
30 |
+typedef struct { |
|
31 |
+ unsigned int x1,y1,x2,y2; |
|
32 |
+ unsigned int x,y; |
|
33 |
+ unsigned int w; |
|
34 |
+} gc_t; |
|
35 |
+gc_t gc={0,0,LCD_WIDTH-1,LCD_HEIGHT-1}; |
|
36 |
+ |
|
37 |
+void |
|
38 |
+oswald_set_draw_window(const unsigned int x1,const unsigned int y1,const unsigned int x2,const unsigned int y2) |
|
39 |
+{ |
|
40 |
+ gc.x1=x1,gc.x2=x2,gc.y1=y1,gc.y2=y2; |
|
41 |
+ gc.x=gc.y=0; |
|
42 |
+ gc.w=gc.x2-gc.x1+1; |
|
43 |
+} |
|
44 |
+ |
|
45 |
+void |
|
46 |
+oswald_draw_point(const uint8_t color) |
|
47 |
+{ |
|
48 |
+ hal_lcd_set_pixel(gc.x1+gc.x,gc.y1+gc.y,color); |
|
49 |
+ gc.x++; |
|
50 |
+ gc.y+=(gc.x/gc.w); |
|
51 |
+ gc.x%=gc.w; |
|
52 |
+} |
|
7 | 53 |
|
8 | 54 |
|
9 | 55 |
#if 0 |
10 | 56 |
void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart, uint8_t color) |
11 | 57 |
{ |
12 |
- hal_lcd_set_pixel(xstart, ystart, TRUE); |
|
58 |
+ hal_lcd_set_pixel(xstart, ystart, TRUE); |
|
13 | 59 |
} |
14 | 60 |
#endif |
15 | 61 |
|
16 | 62 |
void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, |
17 |
- const unsigned int xoff, const unsigned int yoff, |
|
18 |
- const unsigned int width, const unsigned int height, |
|
19 |
- const boolean invert, |
|
20 |
- const unsigned int bmp_width, const unsigned int bmp_height, |
|
21 |
- const void *bmp) |
|
22 |
-{ |
|
23 |
- unsigned int x, y; |
|
24 |
- uint8_t *cb; |
|
25 |
- |
|
26 |
- if (bmp == NULL) |
|
27 |
- return; |
|
28 |
- |
|
29 |
- //g_printerr("dbmp %d,%d off %d,%d\n", xstart, ystart, width, height); |
|
30 |
- cb = (uint8_t *)bmp; |
|
31 |
- //g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
32 |
- // we only draw set pixel, unset pixel remain as they are |
|
33 |
- for (y=yoff; y<bmp_height && y<height; y++) { |
|
34 |
- for (x=xoff; x<bmp_width && x<width; x++) { |
|
35 |
- cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
|
36 |
- // g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
37 |
- if (*cb & (1 << (x % 8))) { |
|
38 |
- if (!invert) |
|
39 |
- hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
40 |
- // g_printerr("X"); |
|
41 |
- } else { |
|
42 |
- if (invert) |
|
43 |
- hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
44 |
- // g_printerr("."); |
|
45 |
- } |
|
46 |
- } |
|
47 |
- //g_printerr("\n"); |
|
48 |
- } |
|
63 |
+ const unsigned int xoff, const unsigned int yoff, |
|
64 |
+ const unsigned int width, const unsigned int height, |
|
65 |
+ const boolean invert, |
|
66 |
+ const unsigned int bmp_width, const unsigned int bmp_height, |
|
67 |
+ const void *bmp) |
|
68 |
+{ |
|
69 |
+ unsigned int x, y; |
|
70 |
+ uint8_t *cb; |
|
71 |
+ |
|
72 |
+ if (bmp == NULL) |
|
73 |
+ return; |
|
74 |
+ |
|
75 |
+ //g_printerr("dbmp %d,%d off %d,%d\n", xstart, ystart, width, height); |
|
76 |
+ cb = (uint8_t *)bmp; |
|
77 |
+ //g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
78 |
+ // we only draw set pixel, unset pixel remain as they are |
|
79 |
+ for (y=yoff; y<bmp_height && y<height; y++) { |
|
80 |
+ for (x=xoff; x<bmp_width && x<width; x++) { |
|
81 |
+ cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
|
82 |
+ // g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
83 |
+ if (*cb & (1 << (x % 8))) { |
|
84 |
+ if (!invert) |
|
85 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
86 |
+ // g_printerr("X"); |
|
87 |
+ } else { |
|
88 |
+ if (invert) |
|
89 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
90 |
+ // g_printerr("."); |
|
91 |
+ } |
|
92 |
+ } |
|
93 |
+ //g_printerr("\n"); |
|
94 |
+ } |
|
49 | 95 |
} |
50 | 96 |
|
51 |
-void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) |
|
97 |
+void oswald_draw_bitmap_opts_1x2fg(const unsigned int xstart, const unsigned int ystart, |
|
98 |
+ const unsigned int xoff, const unsigned int yoff, |
|
99 |
+ const unsigned int width, const unsigned int height, |
|
100 |
+ const boolean fg, |
|
101 |
+ const unsigned int bmp_width, const unsigned int bmp_height, |
|
102 |
+ const void *bmp) |
|
52 | 103 |
{ |
53 |
- int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
54 |
- |
|
55 |
- dx = xend - xstart; |
|
56 |
- dy = yend - ystart; |
|
57 |
- |
|
58 |
- incx = (dx >= 0) ? 1 : -1; |
|
59 |
- incy = (dy >= 0) ? 1 : -1; |
|
60 |
- |
|
61 |
- if (dx<0) |
|
62 |
- dx = -dx; |
|
63 |
- if (dy<0) |
|
64 |
- dy = -dy; |
|
65 |
- |
|
66 |
- if (dx>dy) { |
|
67 |
- pdx = incx; pdy = 0; |
|
68 |
- ddx=incx; ddy=incy; |
|
69 |
- es =dy; el =dx; |
|
70 |
- } else { |
|
71 |
- pdx=0; pdy=incy; |
|
72 |
- ddx=incx; ddy=incy; |
|
73 |
- es =dx; el =dy; |
|
74 |
- } |
|
75 |
- |
|
76 |
- x = xstart; |
|
77 |
- y = ystart; |
|
78 |
- err = el/2; |
|
79 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
80 |
- |
|
81 |
- for (t = 0; t < el; ++t) { |
|
82 |
- err -= es; |
|
83 |
- if (err < 0) { |
|
84 |
- err += el; |
|
85 |
- x += ddx; |
|
86 |
- y += ddy; |
|
87 |
- } else { |
|
88 |
- x += pdx; |
|
89 |
- y += pdy; |
|
90 |
- } |
|
91 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
92 |
- } |
|
104 |
+ unsigned int x, y, iy; |
|
105 |
+ uint8_t *cb; |
|
106 |
+ |
|
107 |
+ if (bmp == NULL) |
|
108 |
+ return; |
|
109 |
+ |
|
110 |
+ cb = (uint8_t *)bmp; |
|
111 |
+ for (y=yoff,iy=0; y<bmp_height && y<height; y++, iy++) { |
|
112 |
+ for (x=xoff; x<bmp_width && x<width; x++) { |
|
113 |
+ cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
|
114 |
+ if (*cb & (1 << (x % 8))) { |
|
115 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff + iy , fg); |
|
116 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff + iy + 1, fg); |
|
117 |
+ } |
|
118 |
+ } |
|
119 |
+ } |
|
93 | 120 |
} |
94 | 121 |
|
95 |
-void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
|
122 |
+void oswald_draw_rect(const unsigned int x1, const unsigned int y1, const unsigned int x2, const unsigned int y2, const uint8_t color) |
|
96 | 123 |
{ |
97 |
- int16_t i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
98 |
- |
|
99 |
- dx = xend - xstart; |
|
100 |
- dy = yend - ystart; |
|
101 |
- |
|
102 |
- incx = (dx >= 0) ? 1 : -1; |
|
103 |
- incy = (dy >= 0) ? 1 : -1; |
|
104 |
- |
|
105 |
- if (dx<0) |
|
106 |
- dx = -dx; |
|
107 |
- if (dy<0) |
|
108 |
- dy = -dy; |
|
109 |
- |
|
110 |
- if (dx>dy) { |
|
111 |
- pdx = incx; |
|
112 |
- pdy = 0; |
|
113 |
- ddx = incx; |
|
114 |
- ddy = incy; |
|
115 |
- es = dy; |
|
116 |
- el = dx; |
|
117 |
- } else { |
|
118 |
- pdx = 0; |
|
119 |
- pdy = incy; |
|
120 |
- ddx = incx; |
|
121 |
- ddy = incy; |
|
122 |
- es = dx; |
|
123 |
- el = dy; |
|
124 |
- } |
|
125 |
- |
|
126 |
- x = xstart; |
|
127 |
- y = ystart; |
|
128 |
- err = el/2; |
|
129 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
130 |
- for (i=1; i<thickness; i++) { |
|
131 |
- hal_lcd_set_pixel(x-i, y, TRUE); |
|
132 |
- hal_lcd_set_pixel(x+i, y, TRUE); |
|
133 |
- hal_lcd_set_pixel(x, y-i, TRUE); |
|
134 |
- hal_lcd_set_pixel(x, y+i, TRUE); |
|
124 |
+ unsigned int x, y; |
|
125 |
+ for(y=y1;y<=y2;++y) { |
|
126 |
+ for(x=x1;x<=x2;++x) |
|
127 |
+ hal_lcd_set_pixel(x,y,color); |
|
128 |
+ } |
|
129 |
+} |
|
130 |
+ |
|
131 |
+void oswald_draw_grid(const unsigned int x1, const unsigned int y1, const unsigned int x2, const unsigned int y2, const unsigned int ix, const unsigned int iy) |
|
132 |
+{ |
|
133 |
+ unsigned int x, y; |
|
134 |
+ for(y=y1+iy;y<y2;y+=iy) { |
|
135 |
+ oswald_set_draw_window(x1,y,x2,y); |
|
136 |
+ for(x=x1;x<=x2;++x) |
|
137 |
+ oswald_draw_point(x&1); |
|
138 |
+ } |
|
139 |
+ for(x=x1+ix;x<x2;x+=ix) { |
|
140 |
+ oswald_set_draw_window(x,y1,x,y2); |
|
141 |
+ for(y=y1;y<=y2;++y) |
|
142 |
+ oswald_draw_point(y&1); |
|
143 |
+ } |
|
144 |
+ oswald_draw_rect(x1+1,y1,x2-1,y1,1); |
|
145 |
+ oswald_draw_rect(x1+1,y2,x2-1,y2,1); |
|
146 |
+ oswald_draw_rect(x1,y1+1,x1,y2-1,1); |
|
147 |
+ oswald_draw_rect(x2,y1+1,x2,y2-1,1); |
|
148 |
+ hal_lcd_set_pixel(x1+1,y1+1,1); |
|
149 |
+ hal_lcd_set_pixel(x1+1,y2-1,1); |
|
150 |
+ hal_lcd_set_pixel(x2-1,y1+1,1); |
|
151 |
+ hal_lcd_set_pixel(x2-1,y2-1,1); |
|
152 |
+} |
|
153 |
+ |
|
154 |
+void oswald_draw_font58(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
155 |
+{ |
|
156 |
+ int bit; |
|
157 |
+ int k; |
|
158 |
+ uint8_t car; |
|
159 |
+ const uint8_t *ptr; |
|
160 |
+ *width=0; |
|
161 |
+ if(character<32 || character>255) |
|
162 |
+ return; |
|
163 |
+ ptr=(font5x8+((character-32)<<2)); |
|
164 |
+ /* simple way to calc. the width */ |
|
165 |
+ *width=(((ptr[0]&0x02)||(ptr[1]&0x10)||(ptr[2]&0x84)||(ptr[3]&0x21))?5: |
|
166 |
+ ((ptr[0]&0x04)||(ptr[1]&0x21)||(ptr[2]&0x08)||(ptr[3]&0x42))?4: |
|
167 |
+ ((ptr[0]&0x08)||(ptr[1]&0x42)||(ptr[2]&0x10)||(ptr[3]&0x84))?3: |
|
168 |
+ ((ptr[0]&0x10)||(ptr[1]&0x84)||(ptr[2]&0x21)||(ptr[3]&0x08))?2: |
|
169 |
+ ((ptr[0]&0x3f)||(ptr[1]&0xff)||(ptr[2]&0xff)||(ptr[3]&0xff))?2:1); |
|
170 |
+ if(ptr[0]&0x80) { |
|
171 |
+ oswald_draw_rect(x1,y1,x1+*width,y1+1,bg); |
|
172 |
+ if(ptr[0]&0x40) |
|
173 |
+ oswald_draw_rect(x1+*width-1,y1,x1+*width-1,y1,fg); |
|
174 |
+ y1+=2; |
|
175 |
+ } else |
|
176 |
+ oswald_draw_rect(x1,y1,x1+*width-1,y1+7,bg); |
|
177 |
+ oswald_set_draw_window(x1,y1,x1+4,y1+5); |
|
178 |
+ for(k=0;k<=3;++k) { |
|
179 |
+ for(bit=((k==0)?0x20:0x80),car=ptr[k];bit>0;bit>>=1) |
|
180 |
+ oswald_draw_point((car&bit)?fg:bg); |
|
135 | 181 |
} |
136 |
- |
|
137 |
- for (t = 0; t < el; ++t) { |
|
138 |
- err -= es; |
|
139 |
- if (err < 0) { |
|
140 |
- err += el; |
|
141 |
- x += ddx; |
|
142 |
- y += ddy; |
|
143 |
- } else { |
|
144 |
- x += pdx; |
|
145 |
- y += pdy; |
|
182 |
+ return; |
|
183 |
+} |
|
184 |
+ |
|
185 |
+void oswald_draw_font58_scaled(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg,const unsigned int scalex,const unsigned int scaley) |
|
186 |
+{ |
|
187 |
+ int x,y,ix,iy; |
|
188 |
+ int k,n,b,c; |
|
189 |
+ const uint8_t *ptr; |
|
190 |
+ *width=0; |
|
191 |
+ if(character<32 || character>255) |
|
192 |
+ return; |
|
193 |
+ /* special cases */ |
|
194 |
+ if(character>='0' && character<='9') { |
|
195 |
+ if(scalex==4 && scaley==10) { |
|
196 |
+ *width=16; |
|
197 |
+ oswald_draw_bitmap_opts_1x2fg(x1,y1,(character-'0')*4*4,0,(character-'0')*4*4+16,font5x8scaledx4x5_height,fg,font5x8scaledx4x5_width,font5x8scaledx4x5_height,font5x8scaledx4x5_bits); |
|
198 |
+ return; |
|
199 |
+ } else if(scalex==4 && scaley==5) { |
|
200 |
+ *width=16; |
|
201 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*4*4,0,(character-'0')*4*4+16,font5x8scaledx4x5_height,!fg,font5x8scaledx4x5_width,font5x8scaledx4x5_height,font5x8scaledx4x5_bits); |
|
202 |
+ return; |
|
203 |
+ } else if(scalex==2 && scaley==2) { |
|
204 |
+ *width=8; |
|
205 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x2_height,!fg,font5x8scaledx2x2_width,font5x8scaledx2x2_height,font5x8scaledx2x2_bits); |
|
206 |
+ return; |
|
207 |
+ } else if(scalex==2 && scaley==3) { |
|
208 |
+ *width=8; |
|
209 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*2*4,0,(character-'0')*2*4+8,font5x8scaledx2x3_height,!fg,font5x8scaledx2x3_width,font5x8scaledx2x3_height,font5x8scaledx2x3_bits); |
|
210 |
+ return; |
|
146 | 211 |
} |
147 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
148 |
- for (i=1; i<thickness; i++) { |
|
149 |
- hal_lcd_set_pixel(x-i, y, TRUE); |
|
150 |
- hal_lcd_set_pixel(x+i, y, TRUE); |
|
151 |
- hal_lcd_set_pixel(x, y-i, TRUE); |
|
152 |
- hal_lcd_set_pixel(x, y+i, TRUE); |
|
212 |
+ } |
|
213 |
+ /* default case */ |
|
214 |
+ ptr=(font5x8+((character-32)<<2)); |
|
215 |
+ /* simple way to calc. the width */ |
|
216 |
+ *width=(((ptr[0]&0x02)||(ptr[1]&0x10)||(ptr[2]&0x84)||(ptr[3]&0x21))?5: |
|
217 |
+ ((ptr[0]&0x04)||(ptr[1]&0x21)||(ptr[2]&0x08)||(ptr[3]&0x42))?4: |
|
218 |
+ ((ptr[0]&0x08)||(ptr[1]&0x42)||(ptr[2]&0x10)||(ptr[3]&0x84))?3: |
|
219 |
+ ((ptr[0]&0x10)||(ptr[1]&0x84)||(ptr[2]&0x21)||(ptr[3]&0x08))?2: |
|
220 |
+ ((ptr[0]&0x3f)||(ptr[1]&0xff)||(ptr[2]&0xff)||(ptr[3]&0xff))?2:1); |
|
221 |
+ if(ptr[0]&0x80) { |
|
222 |
+ oswald_draw_rect(x1,y1,x1+(4+1)*scalex-1,y1+(1+1)*scaley-1,bg); |
|
223 |
+ if(ptr[0]&0x40) |
|
224 |
+ oswald_draw_rect(x1+(*width-1)*scalex,y1,x1+(*width-1+1)*scalex-1,y1+scaley-1,fg); |
|
225 |
+ y1+=2*scaley; |
|
226 |
+ } else |
|
227 |
+ oswald_draw_rect(x1,y1+6*scaley,x1+(4+1)*scalex-1,y1+(7+1)*scaley-1,bg); |
|
228 |
+ oswald_set_draw_window(x1,y1,x1+(4+1)*scalex-1,y1+(5+1)*scaley-1); |
|
229 |
+ for(y=0;y<6;y++) { |
|
230 |
+ for(iy=0;iy<scaley;iy++) { |
|
231 |
+ for(x=0;x<5;x++) { |
|
232 |
+ n=2+x+y*5; |
|
233 |
+ k=n>>3; |
|
234 |
+ b=n&0x7; |
|
235 |
+ c=(ptr[k]&(0x80>>b))?1:0; |
|
236 |
+ for(ix=0;ix<scalex;ix++) |
|
237 |
+ oswald_draw_point(c); |
|
238 |
+ } |
|
153 | 239 |
} |
154 | 240 |
} |
241 |
+ *width*=scalex; |
|
242 |
+ return; |
|
155 | 243 |
} |
156 | 244 |
|
157 |
-uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, const uint8_t Character) |
|
245 |
+ |
|
246 |
+void oswald_draw_microdigit(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
158 | 247 |
{ |
159 |
- uint8_t *cdata = oswald_fonts[face].data; |
|
160 |
- uint8_t cwidth; |
|
161 |
- int csize; |
|
248 |
+ static unsigned char micronumbers[10] = { 0xff, 0x55, 0xdb, 0xd7, /* 0-3 */ |
|
249 |
+ 0xbd, 0xe6, 0xef, 0xda, /* 4-7 */ |
|
250 |
+ 0xcf, 0xf7 /* 8-9 */ }; |
|
251 |
+ unsigned char bit,car; |
|
252 |
+ car=((character>='0' && character<='9')?micronumbers[character-'0']:0x00); |
|
253 |
+ oswald_set_draw_window(x1,y1,x1+1,y1+3); |
|
254 |
+ for(bit=0x80;bit>0;bit>>=1) |
|
255 |
+ oswald_draw_point((car&bit)?fg:bg); |
|
256 |
+ *width=3; |
|
257 |
+ return; |
|
258 |
+} |
|
162 | 259 |
|
163 |
-// if (Character == 32) { // space, blank no need to draw one ;) |
|
164 |
-// return oswald_fonts[face].width / 2; |
|
165 |
-// } |
|
260 |
+void oswald_draw_tinydigit(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
261 |
+{ |
|
262 |
+ static unsigned short tinynumbers[10] = { |
|
263 |
+ 0x2b6a,0x2c97,0x62a7,0x728e, |
|
264 |
+ 0x5bc9,0x798e,0x29aa,0x7252, |
|
265 |
+ 0x2aaa,0x2aca }; |
|
266 |
+ unsigned short bit,car; |
|
267 |
+ car=((character>='0' && character<='9')?tinynumbers[character-'0']:0x00); |
|
268 |
+ oswald_set_draw_window(x1,y1,x1+2,y1+4); |
|
269 |
+ for(bit=0x4000;bit>0;bit>>=1) |
|
270 |
+ oswald_draw_point((car&bit)?fg:bg); |
|
271 |
+ *width=4; |
|
272 |
+ return; |
|
273 |
+} |
|
274 |
+ |
|
275 |
+void oswald_draw_bigdigit(const unsigned int x1, unsigned int y1, const uint8_t character, int *width, const uint8_t fg, const uint8_t bg) |
|
276 |
+{ |
|
277 |
+ *width=14; |
|
278 |
+ if(character>='0' && character<='9') |
|
279 |
+ oswald_draw_bitmap_opts(x1,y1,(character-'0')*14,0,(character-'0')*14+14,fontbigdigits_height,!fg,fontbigdigits_width,fontbigdigits_height,fontbigdigits_bits); |
|
280 |
+ return; |
|
281 |
+} |
|
166 | 282 |
|
167 |
- csize = ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * oswald_fonts[face].height; |
|
168 |
- if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) |
|
169 |
- csize += 1; // at least 1px spacing |
|
283 |
+void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) |
|
284 |
+{ |
|
285 |
+ int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
170 | 286 |
|
171 |
- //csize += (oswald_fonts[face].height / 8) + ((oswald_fonts[face].height % 8) ? 1 : 0); |
|
287 |
+ dx = xend - xstart; |
|
288 |
+ dy = yend - ystart; |
|
172 | 289 |
|
173 |
- // g_printerr("fp = 0x%08lx cdata = 0x%08lx\n", font_7x12, cdata); |
|
290 |
+ incx = (dx >= 0) ? 1 : -1; |
|
291 |
+ incy = (dy >= 0) ? 1 : -1; |
|
174 | 292 |
|
175 |
- cdata = (cdata + ((int)csize * (int)Character)); |
|
293 |
+ if (dx<0) |
|
294 |
+ dx = -dx; |
|
295 |
+ if (dy<0) |
|
296 |
+ dy = -dy; |
|
176 | 297 |
|
177 |
- //g_printerr("%02x\n", oswald_fonts[face].data[0][0]); |
|
178 |
- //g_printerr("char %02x face %d %dx%d csize %d\n", Character, face, oswald_fonts[face].width, oswald_fonts[face].height, csize); |
|
179 |
- //g_printerr("char %02x %02x %02x\n", (uint8_t)cdata[0], (uint8_t)cdata[1], (uint8_t)cdata[2]); |
|
298 |
+ if (dx>dy) { |
|
299 |
+ pdx = incx; pdy = 0; |
|
300 |
+ ddx=incx; ddy=incy; |
|
301 |
+ es =dy; el =dx; |
|
302 |
+ } else { |
|
303 |
+ pdx=0; pdy=incy; |
|
304 |
+ ddx=incx; ddy=incy; |
|
305 |
+ es =dx; el =dy; |
|
306 |
+ } |
|
180 | 307 |
|
181 |
- // oswald_draw_bitmap(x, y, oswald_fonts[face].height, oswald_fonts[face].height, cdata); |
|
182 |
- if (oswald_fonts[face].font_type == FONT_TYPE_MONOSPACE) { |
|
183 |
- cwidth = oswald_fonts[face].width; |
|
184 |
- //oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
185 |
- oswald_draw_bitmap_opts(x,y,0,0,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8,oswald_fonts[face].height,invert,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8,oswald_fonts[face].height,(uint8_t *)cdata); |
|
186 |
- } else if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) { |
|
187 |
- cwidth = cdata[0]; |
|
188 |
- cdata++; |
|
189 |
- // oswald_draw_bitmap_size(x, y, (cwidth+1), oswald_fonts[face].height, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
190 |
- oswald_draw_bitmap_opts(x,y,0,0,(cwidth+1),oswald_fonts[face].height,invert,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8,oswald_fonts[face].height,(uint8_t *)cdata); |
|
191 |
- } else { |
|
192 |
- cwidth = 0; |
|
193 |
- } |
|
194 |
- // oswald_draw_bitmap_offset(x, y, (oswald_fonts[face].width % 8) > 0 ? (8-(oswald_fonts[face].width % 8)) : 0, 0, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
308 |
+ x = xstart; |
|
309 |
+ y = ystart; |
|
310 |
+ err = el/2; |
|
311 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
195 | 312 |
|
196 |
- return cwidth; |
|
313 |
+ for (t = 0; t < el; ++t) { |
|
314 |
+ err -= es; |
|
315 |
+ if (err < 0) { |
|
316 |
+ err += el; |
|
317 |
+ x += ddx; |
|
318 |
+ y += ddy; |
|
319 |
+ } else { |
|
320 |
+ x += pdx; |
|
321 |
+ y += pdy; |
|
322 |
+ } |
|
323 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
324 |
+ } |
|
325 |
+} |
|
326 |
+ |
|
327 |
+void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
|
328 |
+{ |
|
329 |
+ int16_t i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
330 |
+ |
|
331 |
+ dx = xend - xstart; |
|
332 |
+ dy = yend - ystart; |
|
333 |
+ |
|
334 |
+ incx = (dx >= 0) ? 1 : -1; |
|
335 |
+ incy = (dy >= 0) ? 1 : -1; |
|
336 |
+ |
|
337 |
+ if (dx<0) |
|
338 |
+ dx = -dx; |
|
339 |
+ if (dy<0) |
|
340 |
+ dy = -dy; |
|
341 |
+ |
|
342 |
+ if (dx>dy) { |
|
343 |
+ pdx = incx; |
|
344 |
+ pdy = 0; |
|
345 |
+ ddx = incx; |
|
346 |
+ ddy = incy; |
|
347 |
+ es = dy; |
|
348 |
+ el = dx; |
|
349 |
+ } else { |
|
350 |
+ pdx = 0; |
|
351 |
+ pdy = incy; |
|
352 |
+ ddx = incx; |
|
353 |
+ ddy = incy; |
|
354 |
+ es = dx; |
|
355 |
+ el = dy; |
|
356 |
+ } |
|
357 |
+ |
|
358 |
+ x = xstart; |
|
359 |
+ y = ystart; |
|
360 |
+ err = el/2; |
|
361 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
362 |
+ for (i=1; i<thickness; i++) { |
|
363 |
+ hal_lcd_set_pixel(x-i, y, TRUE); |
|
364 |
+ hal_lcd_set_pixel(x+i, y, TRUE); |
|
365 |
+ hal_lcd_set_pixel(x, y-i, TRUE); |
|
366 |
+ hal_lcd_set_pixel(x, y+i, TRUE); |
|
367 |
+ } |
|
368 |
+ |
|
369 |
+ for (t = 0; t < el; ++t) { |
|
370 |
+ err -= es; |
|
371 |
+ if (err < 0) { |
|
372 |
+ err += el; |
|
373 |
+ x += ddx; |
|
374 |
+ y += ddy; |
|
375 |
+ } else { |
|
376 |
+ x += pdx; |
|
377 |
+ y += pdy; |
|
378 |
+ } |
|
379 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
380 |
+ for (i=1; i<thickness; i++) { |
|
381 |
+ hal_lcd_set_pixel(x-i, y, TRUE); |
|
382 |
+ hal_lcd_set_pixel(x+i, y, TRUE); |
|
383 |
+ hal_lcd_set_pixel(x, y-i, TRUE); |
|
384 |
+ hal_lcd_set_pixel(x, y+i, TRUE); |
|
385 |
+ } |
|
386 |
+ } |
|
387 |
+} |
|
388 |
+ |
|
389 |
+uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, |
|
390 |
+ const boolean invert, const uint8_t Character) |
|
391 |
+{ |
|
392 |
+ int width; |
|
393 |
+ oswald_draw_font58(x,y,Character,&width,!invert,invert); |
|
394 |
+ return width+1; |
|
197 | 395 |
} |
198 | 396 |
|
199 | 397 |
void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, char *str) |
200 | 398 |
{ |
201 |
- uint8_t lx, i, strl; |
|
399 |
+ uint8_t lx, i, strl; |
|
202 | 400 |
|
203 |
- strl = oswald_strlen(str); |
|
204 |
- if (strl == 0) |
|
205 |
- return; |
|
401 |
+ strl = oswald_strlen(str); |
|
402 |
+ if (strl == 0) |
|
403 |
+ return; |
|
206 | 404 |
|
207 |
- lx = x; |
|
208 |
- for (i=0; i<strl; i++) { |
|
209 |
- lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
210 |
- } |
|
405 |
+ lx = x; |
|
406 |
+ for (i=0; i<strl; i++) { |
|
407 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
408 |
+ } |
|
211 | 409 |
} |
212 | 410 |
|
213 | 411 |
uint8_t oswald_write_string_length(const uint8_t x, const uint8_t y, const uint8_t len, const oswald_font_face face, const boolean invert, char *str) |
214 | 412 |
{ |
215 |
- uint8_t lx, i, strl; |
|
413 |
+ uint8_t lx, i, strl; |
|
216 | 414 |
|
217 |
- strl = oswald_strlen(str); |
|
218 |
- if (strl == 0) |
|
219 |
- return; |
|
415 |
+ strl = oswald_strlen(str); |
|
416 |
+ if (strl == 0) |
|
417 |
+ return(0); |
|
220 | 418 |
|
221 |
- lx = x; |
|
222 |
- for (i=0; i<strl; i++) { |
|
223 |
- lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
224 |
- if (lx > len) |
|
225 |
- break; |
|
226 |
- } |
|
419 |
+ lx = x; |
|
420 |
+ for (i=0; i<strl; i++) { |
|
421 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
422 |
+ if (lx > len) |
|
423 |
+ break; |
|
424 |
+ } |
|
227 | 425 |
|
228 |
- return (i+1); |
|
426 |
+ return (i+1); |
|
229 | 427 |
} |
230 | 428 |
|
231 | 429 |
void oswald_write_number(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, const int16_t number) |
232 | 430 |
{ |
233 |
- uint8_t lx, i, strl; |
|
234 |
- char str[8]; |
|
431 |
+ uint8_t lx, i, strl; |
|
432 |
+ char str[8]; |
|
235 | 433 |
|
236 |
- itoa(number, str, 10); |
|
237 |
- strl = oswald_strlen(str); |
|
238 |
- if (strl == 0) |
|
239 |
- return; |
|
434 |
+ itoa(number, str, 10); |
|
435 |
+ strl = oswald_strlen(str); |
|
436 |
+ if (strl == 0) |
|
437 |
+ return; |
|
240 | 438 |
|
241 |
- lx = x; |
|
242 |
- for (i=0; i<strl; i++) { |
|
243 |
- lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
244 |
- } |
|
439 |
+ lx = x; |
|
440 |
+ for (i=0; i<strl; i++) { |
|
441 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
442 |
+ } |
|
245 | 443 |
} |
246 | 444 |
|
... | ... |
@@ -94,7 +94,7 @@ void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t |
94 | 94 |
|
95 | 95 |
void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
96 | 96 |
{ |
97 |
- int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
97 |
+ int16_t i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
98 | 98 |
|
99 | 99 |
dx = xend - xstart; |
100 | 100 |
dy = yend - ystart; |
... | ... |
@@ -110,17 +110,17 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
110 | 110 |
if (dx>dy) { |
111 | 111 |
pdx = incx; |
112 | 112 |
pdy = 0; |
113 |
- ddx=incx; |
|
114 |
- ddy=incy; |
|
115 |
- es =dy; |
|
116 |
- el =dx; |
|
113 |
+ ddx = incx; |
|
114 |
+ ddy = incy; |
|
115 |
+ es = dy; |
|
116 |
+ el = dx; |
|
117 | 117 |
} else { |
118 |
- pdx=0; |
|
119 |
- pdy=incy; |
|
120 |
- ddx=incx; |
|
121 |
- ddy=incy; |
|
122 |
- es =dx; |
|
123 |
- el =dy; |
|
118 |
+ pdx = 0; |
|
119 |
+ pdy = incy; |
|
120 |
+ ddx = incx; |
|
121 |
+ ddy = incy; |
|
122 |
+ es = dx; |
|
123 |
+ el = dy; |
|
124 | 124 |
} |
125 | 125 |
|
126 | 126 |
x = xstart; |
... | ... |
@@ -6,12 +6,19 @@ |
6 | 6 |
#include "oswald_graphics.h" |
7 | 7 |
|
8 | 8 |
|
9 |
-void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart) |
|
9 |
+#if 0 |
|
10 |
+void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart, uint8_t color) |
|
10 | 11 |
{ |
11 | 12 |
hal_lcd_set_pixel(xstart, ystart, TRUE); |
12 | 13 |
} |
14 |
+#endif |
|
13 | 15 |
|
14 |
-void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, const unsigned int xoff, const unsigned int yoff, const unsigned int width, const unsigned int height, const unsigned int bmp_width, const unsigned int bmp_height, const void *bmp) |
|
16 |
+void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, |
|
17 |
+ const unsigned int xoff, const unsigned int yoff, |
|
18 |
+ const unsigned int width, const unsigned int height, |
|
19 |
+ const boolean invert, |
|
20 |
+ const unsigned int bmp_width, const unsigned int bmp_height, |
|
21 |
+ const void *bmp) |
|
15 | 22 |
{ |
16 | 23 |
unsigned int x, y; |
17 | 24 |
uint8_t *cb; |
... | ... |
@@ -28,55 +35,19 @@ void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystar |
28 | 35 |
cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
29 | 36 |
// g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
30 | 37 |
if (*cb & (1 << (x % 8))) { |
31 |
- hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
38 |
+ if (!invert) |
|
39 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
32 | 40 |
// g_printerr("X"); |
33 |
- } /*else { |
|
34 |
- g_printerr("."); |
|
35 |
- }*/ |
|
41 |
+ } else { |
|
42 |
+ if (invert) |
|
43 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
44 |
+ // g_printerr("."); |
|
45 |
+ } |
|
36 | 46 |
} |
37 | 47 |
//g_printerr("\n"); |
38 | 48 |
} |
39 | 49 |
} |
40 | 50 |
|
41 |
-#if 0 |
|
42 |
-/*inline*/ void oswald_draw_bitmap(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const void *bmp) |
|
43 |
-{ |
|
44 |
- unsigned int x, y; |
|
45 |
- uint8_t *cb; |
|
46 |
- |
|
47 |
- // we only draw set pixel, unset pixel remain as they are |
|
48 |
- for (y=0; y<height; y++) { |
|
49 |
- for (x=0; x<width; x++) { |
|
50 |
- cb = (uint8_t *)(bmp + (y * ((width / 8) + ((width % 8) ? 1 : 0))) + (x / 8)); |
|
51 |
- if (*cb & (1 << (x % 8))) |
|
52 |
- hal_lcd_set_pixel((xstart + x), (ystart + y), TRUE); |
|
53 |
- } |
|
54 |
- } |
|
55 |
-} |
|
56 |
-#else |
|
57 |
-void oswald_draw_bitmap(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const void *bmp) |
|
58 |
-{ |
|
59 |
- // seems we are triggering a MSPGCC compiler bug here... |
|
60 |
- // if we do not do this trick then bmp becomes 0x00 when passed a livel higher! |
|
61 |
- volatile unsigned int num; |
|
62 |
- |
|
63 |
- num = (unsigned int) bmp; |
|
64 |
- |
|
65 |
- oswald_draw_bitmap_opts(xstart, ystart, 0, 0, width, height, width, height, bmp); |
|
66 |
-} |
|
67 |
- |
|
68 |
-void oswald_draw_bitmap_size(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const unsigned int bmp_width, const unsigned int bmp_height, const void *bmp) |
|
69 |
-{ |
|
70 |
- // seems we are triggering a MSPGCC compiler bug here... |
|
71 |
- // if we do not do this trick then bmp becomes 0x00 when passed a livel higher! |
|
72 |
- volatile unsigned int num; |
|
73 |
- |
|
74 |
- num = (unsigned int) bmp; |
|
75 |
- |
|
76 |
- oswald_draw_bitmap_opts(xstart, ystart, 0, 0, width, height, bmp_width, bmp_height, bmp); |
|
77 |
-} |
|
78 |
-#endif |
|
79 |
- |
|
80 | 51 |
void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) |
81 | 52 |
{ |
82 | 53 |
int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
... | ... |
@@ -119,7 +90,6 @@ void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t |
119 | 90 |
} |
120 | 91 |
hal_lcd_set_pixel(x, y, TRUE); |
121 | 92 |
} |
122 |
- // hal_lcd_update_display(); |
|
123 | 93 |
} |
124 | 94 |
|
125 | 95 |
void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
... | ... |
@@ -182,45 +152,21 @@ void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8 |
182 | 152 |
hal_lcd_set_pixel(x, y+i, TRUE); |
183 | 153 |
} |
184 | 154 |
} |
185 |
- // hal_lcd_update_display(); |
|
186 | 155 |
} |
187 | 156 |
|
188 |
-uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, const uint8_t Character) |
|
157 |
+uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, const uint8_t Character) |
|
189 | 158 |
{ |
190 |
-#if 0 |
|
191 |
- u8t CharacterHeight = GetCharacterHeight(); |
|
192 |
- u8t CharacterWidth = GetCharacterWidth(Character); |
|
193 |
- u16t bitmap[MAX_FONT_ROWS]; |
|
194 |
- register lx, ly; |
|
195 |
- |
|
196 |
- GetCharacterBitmap(Character, bitmap); |
|
197 |
- |
|
198 |
- // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight); |
|
199 |
- for (ly=0; ly<CharacterHeight; ly++) { |
|
200 |
- for (lx=0; lx<CharacterWidth; lx++) { |
|
201 |
- if (bitmap[ly] & (1<<lx)) { |
|
202 |
- hal_lcd_set_pixel(lx+x, ly+y, TRUE); |
|
203 |
- // printf("."); |
|
204 |
- } /*else { |
|
205 |
- hal_lcd_set_pixel(lx+x, ly+y, FALSE); |
|
206 |
- // printf(" "); |
|
207 |
- }*/ |
|
208 |
- } |
|
209 |
- // printf("\n"); |
|
210 |
- } |
|
211 |
- |
|
212 |
- return CharacterWidth + GetFontSpacing(); |
|
213 |
-#else |
|
214 | 159 |
uint8_t *cdata = oswald_fonts[face].data; |
215 | 160 |
uint8_t cwidth; |
216 | 161 |
int csize; |
217 | 162 |
|
218 |
- if (Character == 32) // space / blank |
|
219 |
- return oswald_fonts[face].width / 2; |
|
163 |
+// if (Character == 32) { // space, blank no need to draw one ;) |
|
164 |
+// return oswald_fonts[face].width / 2; |
|
165 |
+// } |
|
220 | 166 |
|
221 | 167 |
csize = ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * oswald_fonts[face].height; |
222 | 168 |
if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) |
223 |
- csize += 1; |
|
169 |
+ csize += 1; // at least 1px spacing |
|
224 | 170 |
|
225 | 171 |
//csize += (oswald_fonts[face].height / 8) + ((oswald_fonts[face].height % 8) ? 1 : 0); |
226 | 172 |
|
... | ... |
@@ -235,20 +181,22 @@ uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_fo |
235 | 181 |
// oswald_draw_bitmap(x, y, oswald_fonts[face].height, oswald_fonts[face].height, cdata); |
236 | 182 |
if (oswald_fonts[face].font_type == FONT_TYPE_MONOSPACE) { |
237 | 183 |
cwidth = oswald_fonts[face].width; |
238 |
- oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
239 |
- } |
|
240 |
- if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) { |
|
184 |
+ //oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
185 |
+ oswald_draw_bitmap_opts(x,y,0,0,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8,oswald_fonts[face].height,invert,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * 8,oswald_fonts[face].height,(uint8_t *)cdata); |
|
186 |
+ } else if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) { |
|
241 | 187 |
cwidth = cdata[0]; |
242 | 188 |
cdata++; |
243 |
- oswald_draw_bitmap_size(x, y, cwidth+1, oswald_fonts[face].height, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
189 |
+ // oswald_draw_bitmap_size(x, y, (cwidth+1), oswald_fonts[face].height, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
190 |
+ oswald_draw_bitmap_opts(x,y,0,0,(cwidth+1),oswald_fonts[face].height,invert,((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8,oswald_fonts[face].height,(uint8_t *)cdata); |
|
191 |
+ } else { |
|
192 |
+ cwidth = 0; |
|
244 | 193 |
} |
245 | 194 |
// oswald_draw_bitmap_offset(x, y, (oswald_fonts[face].width % 8) > 0 ? (8-(oswald_fonts[face].width % 8)) : 0, 0, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
246 | 195 |
|
247 | 196 |
return cwidth; |
248 |
-#endif |
|
249 | 197 |
} |
250 | 198 |
|
251 |
-void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, char *str) |
|
199 |
+void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, char *str) |
|
252 | 200 |
{ |
253 | 201 |
uint8_t lx, i, strl; |
254 | 202 |
|
... | ... |
@@ -258,12 +206,29 @@ void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_fac |
258 | 206 |
|
259 | 207 |
lx = x; |
260 | 208 |
for (i=0; i<strl; i++) { |
261 |
- lx += oswald_write_character(lx, y, face, str[i]); |
|
209 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
262 | 210 |
} |
263 | 211 |
} |
264 | 212 |
|
213 |
+uint8_t oswald_write_string_length(const uint8_t x, const uint8_t y, const uint8_t len, const oswald_font_face face, const boolean invert, char *str) |
|
214 |
+{ |
|
215 |
+ uint8_t lx, i, strl; |
|
216 |
+ |
|
217 |
+ strl = oswald_strlen(str); |
|
218 |
+ if (strl == 0) |
|
219 |
+ return; |
|
265 | 220 |
|
266 |
-void oswald_write_number(const uint8_t x, const uint8_t y, const oswald_font_face face, const int16_t number) |
|
221 |
+ lx = x; |
|
222 |
+ for (i=0; i<strl; i++) { |
|
223 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
224 |
+ if (lx > len) |
|
225 |
+ break; |
|
226 |
+ } |
|
227 |
+ |
|
228 |
+ return (i+1); |
|
229 |
+} |
|
230 |
+ |
|
231 |
+void oswald_write_number(const uint8_t x, const uint8_t y, const oswald_font_face face, const boolean invert, const int16_t number) |
|
267 | 232 |
{ |
268 | 233 |
uint8_t lx, i, strl; |
269 | 234 |
char str[8]; |
... | ... |
@@ -275,8 +240,7 @@ void oswald_write_number(const uint8_t x, const uint8_t y, const oswald_font_fac |
275 | 240 |
|
276 | 241 |
lx = x; |
277 | 242 |
for (i=0; i<strl; i++) { |
278 |
- lx += oswald_write_character(lx, y, face, str[i]); |
|
243 |
+ lx += oswald_write_character(lx, y, face, invert, str[i]); |
|
279 | 244 |
} |
280 | 245 |
} |
281 | 246 |
|
282 |
- |
... | ... |
@@ -6,6 +6,11 @@ |
6 | 6 |
#include "oswald_graphics.h" |
7 | 7 |
|
8 | 8 |
|
9 |
+void oswald_draw_pixel(const unsigned int xstart, const unsigned int ystart) |
|
10 |
+{ |
|
11 |
+ hal_lcd_set_pixel(xstart, ystart, TRUE); |
|
12 |
+} |
|
13 |
+ |
|
9 | 14 |
void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, const unsigned int xoff, const unsigned int yoff, const unsigned int width, const unsigned int height, const unsigned int bmp_width, const unsigned int bmp_height, const void *bmp) |
10 | 15 |
{ |
11 | 16 |
unsigned int x, y; |
... | ... |
@@ -5,28 +5,8 @@ |
5 | 5 |
|
6 | 6 |
#include "oswald_graphics.h" |
7 | 7 |
|
8 |
-// dummies for MW replacement stuff |
|
9 | 8 |
|
10 |
-void SetFont(etFontType Type) |
|
11 |
-{ |
|
12 |
-} |
|
13 |
- |
|
14 |
-u8t WriteLcdString(const uint8_t x, const uint8_t y, const char *str) |
|
15 |
-{ |
|
16 |
- return 1; |
|
17 |
-} |
|
18 |
- |
|
19 |
-void WriteLcdNumber(const uint8_t x, const uint8_t y, const int16_t number) |
|
20 |
-{ |
|
21 |
-} |
|
22 |
- |
|
23 |
-u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character) |
|
24 |
-{ |
|
25 |
- return 1; |
|
26 |
-} |
|
27 |
- |
|
28 |
- |
|
29 |
-void oswald_draw_bitmap_offset(const unsigned int xstart, const unsigned int ystart, const unsigned int xoff, const unsigned int yoff, const unsigned int width, const unsigned int height, const void *bmp) |
|
9 |
+void oswald_draw_bitmap_opts(const unsigned int xstart, const unsigned int ystart, const unsigned int xoff, const unsigned int yoff, const unsigned int width, const unsigned int height, const unsigned int bmp_width, const unsigned int bmp_height, const void *bmp) |
|
30 | 10 |
{ |
31 | 11 |
unsigned int x, y; |
32 | 12 |
uint8_t *cb; |
... | ... |
@@ -34,13 +14,22 @@ void oswald_draw_bitmap_offset(const unsigned int xstart, const unsigned int yst |
34 | 14 |
if (bmp == NULL) |
35 | 15 |
return; |
36 | 16 |
|
17 |
+ //g_printerr("dbmp %d,%d off %d,%d\n", xstart, ystart, width, height); |
|
18 |
+ cb = (uint8_t *)bmp; |
|
19 |
+ //g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
37 | 20 |
// we only draw set pixel, unset pixel remain as they are |
38 |
- for (y=yoff; y<height; y++) { |
|
39 |
- for (x=xoff; x<width; x++) { |
|
40 |
- cb = (uint8_t *)(bmp + (y * ((width / 8) + ((width % 8) ? 1 : 0))) + (x / 8)); |
|
41 |
- if (*cb & (1 << (x % 8))) |
|
21 |
+ for (y=yoff; y<bmp_height && y<height; y++) { |
|
22 |
+ for (x=xoff; x<bmp_width && x<width; x++) { |
|
23 |
+ cb = (uint8_t *)(bmp + (y * ((bmp_width / 8) + ((bmp_width % 8) ? 1 : 0))) + (x / 8)); |
|
24 |
+ // g_printerr("dat %02x %02x %02x\n", (uint8_t)cb[0], (uint8_t)cb[1], (uint8_t)cb[2]); |
|
25 |
+ if (*cb & (1 << (x % 8))) { |
|
42 | 26 |
hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
27 |
+ // g_printerr("X"); |
|
28 |
+ } /*else { |
|
29 |
+ g_printerr("."); |
|
30 |
+ }*/ |
|
43 | 31 |
} |
32 |
+ //g_printerr("\n"); |
|
44 | 33 |
} |
45 | 34 |
} |
46 | 35 |
|
... | ... |
@@ -68,7 +57,18 @@ void oswald_draw_bitmap(const unsigned int xstart, const unsigned int ystart, co |
68 | 57 |
|
69 | 58 |
num = (unsigned int) bmp; |
70 | 59 |
|
71 |
- oswald_draw_bitmap_offset(xstart, ystart, 0, 0, width, height, bmp); |
|
60 |
+ oswald_draw_bitmap_opts(xstart, ystart, 0, 0, width, height, width, height, bmp); |
|
61 |
+} |
|
62 |
+ |
|
63 |
+void oswald_draw_bitmap_size(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const unsigned int bmp_width, const unsigned int bmp_height, const void *bmp) |
|
64 |
+{ |
|
65 |
+ // seems we are triggering a MSPGCC compiler bug here... |
|
66 |
+ // if we do not do this trick then bmp becomes 0x00 when passed a livel higher! |
|
67 |
+ volatile unsigned int num; |
|
68 |
+ |
|
69 |
+ num = (unsigned int) bmp; |
|
70 |
+ |
|
71 |
+ oswald_draw_bitmap_opts(xstart, ystart, 0, 0, width, height, bmp_width, bmp_height, bmp); |
|
72 | 72 |
} |
73 | 73 |
#endif |
74 | 74 |
|
... | ... |
@@ -207,27 +207,39 @@ uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_fo |
207 | 207 |
return CharacterWidth + GetFontSpacing(); |
208 | 208 |
#else |
209 | 209 |
uint8_t *cdata = oswald_fonts[face].data; |
210 |
+ uint8_t cwidth; |
|
210 | 211 |
int csize; |
211 | 212 |
|
212 | 213 |
if (Character == 32) // space / blank |
213 | 214 |
return oswald_fonts[face].width / 2; |
214 | 215 |
|
215 | 216 |
csize = ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * oswald_fonts[face].height; |
217 |
+ if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) |
|
218 |
+ csize += 1; |
|
219 |
+ |
|
216 | 220 |
//csize += (oswald_fonts[face].height / 8) + ((oswald_fonts[face].height % 8) ? 1 : 0); |
217 | 221 |
|
218 | 222 |
// g_printerr("fp = 0x%08lx cdata = 0x%08lx\n", font_7x12, cdata); |
219 | 223 |
|
220 |
- cdata = (cdata + (csize * (int)Character)); |
|
224 |
+ cdata = (cdata + ((int)csize * (int)Character)); |
|
221 | 225 |
|
222 | 226 |
//g_printerr("%02x\n", oswald_fonts[face].data[0][0]); |
223 | 227 |
//g_printerr("char %02x face %d %dx%d csize %d\n", Character, face, oswald_fonts[face].width, oswald_fonts[face].height, csize); |
224 | 228 |
//g_printerr("char %02x %02x %02x\n", (uint8_t)cdata[0], (uint8_t)cdata[1], (uint8_t)cdata[2]); |
225 | 229 |
|
226 | 230 |
// oswald_draw_bitmap(x, y, oswald_fonts[face].height, oswald_fonts[face].height, cdata); |
227 |
- //oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
228 |
- oswald_draw_bitmap_offset(x, y, (oswald_fonts[face].width % 8) > 0 ? (8-(oswald_fonts[face].width % 8)) : 0, 0, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
231 |
+ if (oswald_fonts[face].font_type == FONT_TYPE_MONOSPACE) { |
|
232 |
+ cwidth = oswald_fonts[face].width; |
|
233 |
+ oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
234 |
+ } |
|
235 |
+ if (oswald_fonts[face].font_type == FONT_TYPE_PROPORTIONAL) { |
|
236 |
+ cwidth = cdata[0]; |
|
237 |
+ cdata++; |
|
238 |
+ oswald_draw_bitmap_size(x, y, cwidth+1, oswald_fonts[face].height, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, (uint8_t *)cdata); |
|
239 |
+ } |
|
240 |
+ // oswald_draw_bitmap_offset(x, y, (oswald_fonts[face].width % 8) > 0 ? (8-(oswald_fonts[face].width % 8)) : 0, 0, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
229 | 241 |
|
230 |
- return oswald_fonts[face].width; |
|
242 |
+ return cwidth; |
|
231 | 243 |
#endif |
232 | 244 |
} |
233 | 245 |
|
... | ... |
@@ -1,30 +1,80 @@ |
1 |
-#include "oswald-ui.h" |
|
1 |
+#include "oswald.h" |
|
2 | 2 |
#include "oswald_strings.h" |
3 | 3 |
#include "oswald_fonts.h" |
4 |
+#include "oswald_hal.h" |
|
4 | 5 |
|
5 | 6 |
#include "oswald_graphics.h" |
6 | 7 |
|
8 |
+// dummies for MW replacement stuff |
|
9 |
+ |
|
10 |
+void SetFont(etFontType Type) |
|
11 |
+{ |
|
12 |
+} |
|
13 |
+ |
|
14 |
+u8t WriteLcdString(const uint8_t x, const uint8_t y, const char *str) |
|
15 |
+{ |
|
16 |
+ return 1; |
|
17 |
+} |
|
18 |
+ |
|
19 |
+void WriteLcdNumber(const uint8_t x, const uint8_t y, const int16_t number) |
|
20 |
+{ |
|
21 |
+} |
|
22 |
+ |
|
23 |
+u8t WriteLcdCharacter(const uint8_t x, const uint8_t y, const uint8_t Character) |
|
24 |
+{ |
|
25 |
+ return 1; |
|
26 |
+} |
|
27 |
+ |
|
28 |
+ |
|
29 |
+void oswald_draw_bitmap_offset(const unsigned int xstart, const unsigned int ystart, const unsigned int xoff, const unsigned int yoff, const unsigned int width, const unsigned int height, const void *bmp) |
|
30 |
+{ |
|
31 |
+ unsigned int x, y; |
|
32 |
+ uint8_t *cb; |
|
33 |
+ |
|
34 |
+ if (bmp == NULL) |
|
35 |
+ return; |
|
36 |
+ |
|
37 |
+ // we only draw set pixel, unset pixel remain as they are |
|
38 |
+ for (y=yoff; y<height; y++) { |
|
39 |
+ for (x=xoff; x<width; x++) { |
|
40 |
+ cb = (uint8_t *)(bmp + (y * ((width / 8) + ((width % 8) ? 1 : 0))) + (x / 8)); |
|
41 |
+ if (*cb & (1 << (x % 8))) |
|
42 |
+ hal_lcd_set_pixel((xstart + x) - xoff, (ystart + y) - yoff, TRUE); |
|
43 |
+ } |
|
44 |
+ } |
|
45 |
+} |
|
7 | 46 |
|
8 | 47 |
#if 0 |
9 |
-void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp) |
|
48 |
+/*inline*/ void oswald_draw_bitmap(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const void *bmp) |
|
10 | 49 |
{ |
11 |
- uint8_t x, y; |
|
50 |
+ unsigned int x, y; |
|
12 | 51 |
uint8_t *cb; |
13 | 52 |
|
14 | 53 |
// we only draw set pixel, unset pixel remain as they are |
15 | 54 |
for (y=0; y<height; y++) { |
16 | 55 |
for (x=0; x<width; x++) { |
17 |
- cb = (uint8_t *)(bmp + (y * ((width / 8)+((width % 8) ? 1:0))) + (x / 8)); |
|
56 |
+ cb = (uint8_t *)(bmp + (y * ((width / 8) + ((width % 8) ? 1 : 0))) + (x / 8)); |
|
18 | 57 |
if (*cb & (1 << (x % 8))) |
19 |
- hal_lcd_set_pixel(xstart + x, ystart + y, TRUE); |
|
58 |
+ hal_lcd_set_pixel((xstart + x), (ystart + y), TRUE); |
|
20 | 59 |
} |
21 | 60 |
} |
22 | 61 |
} |
62 |
+#else |
|
63 |
+void oswald_draw_bitmap(const unsigned int xstart, const unsigned int ystart, const unsigned int width, const unsigned int height, const void *bmp) |
|
64 |
+{ |
|
65 |
+ // seems we are triggering a MSPGCC compiler bug here... |
|
66 |
+ // if we do not do this trick then bmp becomes 0x00 when passed a livel higher! |
|
67 |
+ volatile unsigned int num; |
|
68 |
+ |
|
69 |
+ num = (unsigned int) bmp; |
|
70 |
+ |
|
71 |
+ oswald_draw_bitmap_offset(xstart, ystart, 0, 0, width, height, bmp); |
|
72 |
+} |
|
23 | 73 |
#endif |
24 | 74 |
|
25 |
-void oswald_draw_Line(uint8_t xstart, uint8_t ystart, uint8_t xend, uint8_t yend) |
|
75 |
+void oswald_draw_line(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend) |
|
26 | 76 |
{ |
27 |
- uint8_t x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
77 |
+ int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
28 | 78 |
|
29 | 79 |
dx = xend - xstart; |
30 | 80 |
dy = yend - ystart; |
... | ... |
@@ -64,10 +114,10 @@ void oswald_draw_Line(uint8_t xstart, uint8_t ystart, uint8_t xend, uint8_t yend |
64 | 114 |
} |
65 | 115 |
hal_lcd_set_pixel(x, y, TRUE); |
66 | 116 |
} |
67 |
- hal_lcd_update_display(); |
|
117 |
+ // hal_lcd_update_display(); |
|
68 | 118 |
} |
69 | 119 |
|
70 |
-void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness) |
|
120 |
+void oswald_draw_line_ww(const uint8_t xstart, const uint8_t ystart, const uint8_t xend, const uint8_t yend, const uint8_t thickness) |
|
71 | 121 |
{ |
72 | 122 |
int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
73 | 123 |
|
... | ... |
@@ -83,13 +133,19 @@ void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickne |
83 | 133 |
dy = -dy; |
84 | 134 |
|
85 | 135 |
if (dx>dy) { |
86 |
- pdx = incx; pdy = 0; |
|
87 |
- ddx=incx; ddy=incy; |
|
88 |
- es =dy; el =dx; |
|
136 |
+ pdx = incx; |
|
137 |
+ pdy = 0; |
|
138 |
+ ddx=incx; |
|
139 |
+ ddy=incy; |
|
140 |
+ es =dy; |
|
141 |
+ el =dx; |
|
89 | 142 |
} else { |
90 |
- pdx=0; pdy=incy; |
|
91 |
- ddx=incx; ddy=incy; |
|
92 |
- es =dx; el =dy; |
|
143 |
+ pdx=0; |
|
144 |
+ pdy=incy; |
|
145 |
+ ddx=incx; |
|
146 |
+ ddy=incy; |
|
147 |
+ es =dx; |
|
148 |
+ el =dy; |
|
93 | 149 |
} |
94 | 150 |
|
95 | 151 |
x = xstart; |
... | ... |
@@ -121,10 +177,10 @@ void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickne |
121 | 177 |
hal_lcd_set_pixel(x, y+i, TRUE); |
122 | 178 |
} |
123 | 179 |
} |
124 |
- hal_lcd_update_display(); |
|
180 |
+ // hal_lcd_update_display(); |
|
125 | 181 |
} |
126 | 182 |
|
127 |
-u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character) |
|
183 |
+uint8_t oswald_write_character(const uint8_t x, const uint8_t y, const oswald_font_face face, const uint8_t Character) |
|
128 | 184 |
{ |
129 | 185 |
#if 0 |
130 | 186 |
u8t CharacterHeight = GetCharacterHeight(); |
... | ... |
@@ -140,25 +196,44 @@ u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character) |
140 | 196 |
if (bitmap[ly] & (1<<lx)) { |
141 | 197 |
hal_lcd_set_pixel(lx+x, ly+y, TRUE); |
142 | 198 |
// printf("."); |
143 |
- } else { |
|
199 |
+ } /*else { |
|
144 | 200 |
hal_lcd_set_pixel(lx+x, ly+y, FALSE); |
145 | 201 |
// printf(" "); |
146 |
- } |
|
202 |
+ }*/ |
|
147 | 203 |
} |
148 | 204 |
// printf("\n"); |
149 | 205 |
} |
150 | 206 |
|
151 | 207 |
return CharacterWidth + GetFontSpacing(); |
152 |
-#endif |
|
153 |
- char *cdata = oswald_fonts[face].data[Character]; |
|
208 |
+#else |
|
209 |
+ uint8_t *cdata = oswald_fonts[face].data; |
|
210 |
+ int csize; |
|
211 |
+ |
|
212 |
+ if (Character == 32) // space / blank |
|
213 |
+ return oswald_fonts[face].width / 2; |
|
214 |
+ |
|
215 |
+ csize = ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0)) * oswald_fonts[face].height; |
|
216 |
+ //csize += (oswald_fonts[face].height / 8) + ((oswald_fonts[face].height % 8) ? 1 : 0); |
|
217 |
+ |
|
218 |
+ // g_printerr("fp = 0x%08lx cdata = 0x%08lx\n", font_7x12, cdata); |
|
154 | 219 |
|
155 |
- dbg_out("%c", cdata[1]); |
|
156 |
- return 0; |
|
220 |
+ cdata = (cdata + (csize * (int)Character)); |
|
221 |
+ |
|
222 |
+ //g_printerr("%02x\n", oswald_fonts[face].data[0][0]); |
|
223 |
+ //g_printerr("char %02x face %d %dx%d csize %d\n", Character, face, oswald_fonts[face].width, oswald_fonts[face].height, csize); |
|
224 |
+ //g_printerr("char %02x %02x %02x\n", (uint8_t)cdata[0], (uint8_t)cdata[1], (uint8_t)cdata[2]); |
|
225 |
+ |
|
226 |
+ // oswald_draw_bitmap(x, y, oswald_fonts[face].height, oswald_fonts[face].height, cdata); |
|
227 |
+ //oswald_draw_bitmap(x, y, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
228 |
+ oswald_draw_bitmap_offset(x, y, (oswald_fonts[face].width % 8) > 0 ? (8-(oswald_fonts[face].width % 8)) : 0, 0, ((oswald_fonts[face].width / 8) + ((oswald_fonts[face].width % 8) ? 1 : 0))*8, oswald_fonts[face].height, cdata); |
|
229 |
+ |
|
230 |
+ return oswald_fonts[face].width; |
|
231 |
+#endif |
|
157 | 232 |
} |
158 | 233 |
|
159 |
-void oswald_write_string(u8t x, u8t y, oswald_font_face face, u8t *str) |
|
234 |
+void oswald_write_string(const uint8_t x, const uint8_t y, const oswald_font_face face, char *str) |
|
160 | 235 |
{ |
161 |
- register lx, i, strl; |
|
236 |
+ uint8_t lx, i, strl; |
|
162 | 237 |
|
163 | 238 |
strl = oswald_strlen(str); |
164 | 239 |
if (strl == 0) |
... | ... |
@@ -166,15 +241,15 @@ void oswald_write_string(u8t x, u8t y, oswald_font_face face, u8t *str) |
166 | 241 |
|
167 | 242 |
lx = x; |
168 | 243 |
for (i=0; i<strl; i++) { |
169 |
- lx += WriteLcdCharacter(lx, y, str[i]); |
|
244 |
+ lx += oswald_write_character(lx, y, face, str[i]); |
|
170 | 245 |
} |
171 | 246 |
} |
172 | 247 |
|
173 | 248 |
|
174 |
-void oswald_Write_number(u8t x, u8t y, oswald_font_face face, s16t number) |
|
249 |
+void oswald_write_number(const uint8_t x, const uint8_t y, const oswald_font_face face, const int16_t number) |
|
175 | 250 |
{ |
176 |
- register lx, i, strl; |
|
177 |
- u8t str[8]; |
|
251 |
+ uint8_t lx, i, strl; |
|
252 |
+ char str[8]; |
|
178 | 253 |
|
179 | 254 |
itoa(number, str, 10); |
180 | 255 |
strl = oswald_strlen(str); |
... | ... |
@@ -183,7 +258,8 @@ void oswald_Write_number(u8t x, u8t y, oswald_font_face face, s16t number) |
183 | 258 |
|
184 | 259 |
lx = x; |
185 | 260 |
for (i=0; i<strl; i++) { |
186 |
- lx += WriteLcdCharacter(lx, y, str[i]); |
|
261 |
+ lx += oswald_write_character(lx, y, face, str[i]); |
|
187 | 262 |
} |
188 | 263 |
} |
189 | 264 |
|
265 |
+ |
... | ... |
@@ -5,21 +5,26 @@ |
5 | 5 |
#include "oswald_graphics.h" |
6 | 6 |
|
7 | 7 |
|
8 |
+#if 0 |
|
8 | 9 |
void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp) |
9 | 10 |
{ |
10 | 11 |
uint8_t x, y; |
12 |
+ uint8_t *cb; |
|
11 | 13 |
|
12 | 14 |
// we only draw set pixel, unset pixel remain as they are |
13 | 15 |
for (y=0; y<height; y++) { |
14 | 16 |
for (x=0; x<width; x++) { |
15 |
- hal_lcd_set_pixel(x, y, TRUE); |
|
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); |
|
16 | 20 |
} |
17 | 21 |
} |
18 | 22 |
} |
23 |
+#endif |
|
19 | 24 |
|
20 | 25 |
void oswald_draw_Line(uint8_t xstart, uint8_t ystart, uint8_t xend, uint8_t yend) |
21 | 26 |
{ |
22 |
- int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
27 |
+ uint8_t x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
23 | 28 |
|
24 | 29 |
dx = xend - xstart; |
25 | 30 |
dy = yend - ystart; |
... | ... |
@@ -5,7 +5,19 @@ |
5 | 5 |
#include "oswald_graphics.h" |
6 | 6 |
|
7 | 7 |
|
8 |
-void oswald_draw_Line(u8t xstart, u8t ystart, u8t xend, u8t yend) |
|
8 |
+void oswald_draw_bitmap(const uint8_t xstart, const uint8_t ystart, const uint8_t width, const uint8_t height, const void *bmp) |
|
9 |
+{ |
|
10 |
+ uint8_t x, y; |
|
11 |
+ |
|
12 |
+ // we only draw set pixel, unset pixel remain as they are |
|
13 |
+ for (y=0; y<height; y++) { |
|
14 |
+ for (x=0; x<width; x++) { |
|
15 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
16 |
+ } |
|
17 |
+ } |
|
18 |
+} |
|
19 |
+ |
|
20 |
+void oswald_draw_Line(uint8_t xstart, uint8_t ystart, uint8_t xend, uint8_t yend) |
|
9 | 21 |
{ |
10 | 22 |
int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
11 | 23 |
|
... | ... |
@@ -33,7 +45,7 @@ void oswald_draw_Line(u8t xstart, u8t ystart, u8t xend, u8t yend) |
33 | 45 |
x = xstart; |
34 | 46 |
y = ystart; |
35 | 47 |
err = el/2; |
36 |
- lcd_set_pixel(x, y, TRUE); |
|
48 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
37 | 49 |
|
38 | 50 |
for (t = 0; t < el; ++t) { |
39 | 51 |
err -= es; |
... | ... |
@@ -45,9 +57,9 @@ void oswald_draw_Line(u8t xstart, u8t ystart, u8t xend, u8t yend) |
45 | 57 |
x += pdx; |
46 | 58 |
y += pdy; |
47 | 59 |
} |
48 |
- lcd_set_pixel(x, y, TRUE); |
|
60 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
49 | 61 |
} |
50 |
- lcd_update_display(); |
|
62 |
+ hal_lcd_update_display(); |
|
51 | 63 |
} |
52 | 64 |
|
53 | 65 |
void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness) |
... | ... |
@@ -78,12 +90,12 @@ void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickne |
78 | 90 |
x = xstart; |
79 | 91 |
y = ystart; |
80 | 92 |
err = el/2; |
81 |
- lcd_set_pixel(x, y, TRUE); |
|
93 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
82 | 94 |
for (i=1; i<thickness; i++) { |
83 |
- lcd_set_pixel(x-i, y, TRUE); |
|
84 |
- lcd_set_pixel(x+i, y, TRUE); |
|
85 |
- lcd_set_pixel(x, y-i, TRUE); |
|
86 |
- lcd_set_pixel(x, y+i, TRUE); |
|
95 |
+ hal_lcd_set_pixel(x-i, y, TRUE); |
|
96 |
+ hal_lcd_set_pixel(x+i, y, TRUE); |
|
97 |
+ hal_lcd_set_pixel(x, y-i, TRUE); |
|
98 |
+ hal_lcd_set_pixel(x, y+i, TRUE); |
|
87 | 99 |
} |
88 | 100 |
|
89 | 101 |
for (t = 0; t < el; ++t) { |
... | ... |
@@ -96,15 +108,15 @@ void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickne |
96 | 108 |
x += pdx; |
97 | 109 |
y += pdy; |
98 | 110 |
} |
99 |
- lcd_set_pixel(x, y, TRUE); |
|
111 |
+ hal_lcd_set_pixel(x, y, TRUE); |
|
100 | 112 |
for (i=1; i<thickness; i++) { |
101 |
- lcd_set_pixel(x-i, y, TRUE); |
|
102 |
- lcd_set_pixel(x+i, y, TRUE); |
|
103 |
- lcd_set_pixel(x, y-i, TRUE); |
|
104 |
- lcd_set_pixel(x, y+i, TRUE); |
|
113 |
+ hal_lcd_set_pixel(x-i, y, TRUE); |
|
114 |
+ hal_lcd_set_pixel(x+i, y, TRUE); |
|
115 |
+ hal_lcd_set_pixel(x, y-i, TRUE); |
|
116 |
+ hal_lcd_set_pixel(x, y+i, TRUE); |
|
105 | 117 |
} |
106 | 118 |
} |
107 |
- lcd_update_display(); |
|
119 |
+ hal_lcd_update_display(); |
|
108 | 120 |
} |
109 | 121 |
|
110 | 122 |
u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character) |
... | ... |
@@ -121,10 +133,10 @@ u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character) |
121 | 133 |
for (ly=0; ly<CharacterHeight; ly++) { |
122 | 134 |
for (lx=0; lx<CharacterWidth; lx++) { |
123 | 135 |
if (bitmap[ly] & (1<<lx)) { |
124 |
- lcd_set_pixel(lx+x, ly+y, TRUE); |
|
136 |
+ hal_lcd_set_pixel(lx+x, ly+y, TRUE); |
|
125 | 137 |
// printf("."); |
126 | 138 |
} else { |
127 |
- lcd_set_pixel(lx+x, ly+y, FALSE); |
|
139 |
+ hal_lcd_set_pixel(lx+x, ly+y, FALSE); |
|
128 | 140 |
// printf(" "); |
129 | 141 |
} |
130 | 142 |
} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,172 @@ |
1 |
+#include "oswald-ui.h" |
|
2 |
+#include "oswald_strings.h" |
|
3 |
+#include "oswald_fonts.h" |
|
4 |
+ |
|
5 |
+#include "oswald_graphics.h" |
|
6 |
+ |
|
7 |
+ |
|
8 |
+void oswald_draw_Line(u8t xstart, u8t ystart, u8t xend, u8t yend) |
|
9 |
+{ |
|
10 |
+ int x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
11 |
+ |
|
12 |
+ dx = xend - xstart; |
|
13 |
+ dy = yend - ystart; |
|
14 |
+ |
|
15 |
+ incx = (dx >= 0) ? 1 : -1; |
|
16 |
+ incy = (dy >= 0) ? 1 : -1; |
|
17 |
+ |
|
18 |
+ if (dx<0) |
|
19 |
+ dx = -dx; |
|
20 |
+ if (dy<0) |
|
21 |
+ dy = -dy; |
|
22 |
+ |
|
23 |
+ if (dx>dy) { |
|
24 |
+ pdx = incx; pdy = 0; |
|
25 |
+ ddx=incx; ddy=incy; |
|
26 |
+ es =dy; el =dx; |
|
27 |
+ } else { |
|
28 |
+ pdx=0; pdy=incy; |
|
29 |
+ ddx=incx; ddy=incy; |
|
30 |
+ es =dx; el =dy; |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ x = xstart; |
|
34 |
+ y = ystart; |
|
35 |
+ err = el/2; |
|
36 |
+ lcd_set_pixel(x, y, TRUE); |
|
37 |
+ |
|
38 |
+ for (t = 0; t < el; ++t) { |
|
39 |
+ err -= es; |
|
40 |
+ if (err < 0) { |
|
41 |
+ err += el; |
|
42 |
+ x += ddx; |
|
43 |
+ y += ddy; |
|
44 |
+ } else { |
|
45 |
+ x += pdx; |
|
46 |
+ y += pdy; |
|
47 |
+ } |
|
48 |
+ lcd_set_pixel(x, y, TRUE); |
|
49 |
+ } |
|
50 |
+ lcd_update_display(); |
|
51 |
+} |
|
52 |
+ |
|
53 |
+void oswald_draw_line_ww(u8t xstart, u8t ystart, u8t xend, u8t yend, u8t thickness) |
|
54 |
+{ |
|
55 |
+ int i, x, y, t, dx, dy, incx, incy, pdx, pdy, ddx, ddy, es, el, err; |
|
56 |
+ |
|
57 |
+ dx = xend - xstart; |
|
58 |
+ dy = yend - ystart; |
|
59 |
+ |
|
60 |
+ incx = (dx >= 0) ? 1 : -1; |
|
61 |
+ incy = (dy >= 0) ? 1 : -1; |
|
62 |
+ |
|
63 |
+ if (dx<0) |
|
64 |
+ dx = -dx; |
|
65 |
+ if (dy<0) |
|
66 |
+ dy = -dy; |
|
67 |
+ |
|
68 |
+ if (dx>dy) { |
|
69 |
+ pdx = incx; pdy = 0; |
|
70 |
+ ddx=incx; ddy=incy; |
|
71 |
+ es =dy; el =dx; |
|
72 |
+ } else { |
|
73 |
+ pdx=0; pdy=incy; |
|
74 |
+ ddx=incx; ddy=incy; |
|
75 |
+ es =dx; el =dy; |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ x = xstart; |
|
79 |
+ y = ystart; |
|
80 |
+ err = el/2; |
|
81 |
+ lcd_set_pixel(x, y, TRUE); |
|
82 |
+ for (i=1; i<thickness; i++) { |
|
83 |
+ lcd_set_pixel(x-i, y, TRUE); |
|
84 |
+ lcd_set_pixel(x+i, y, TRUE); |
|
85 |
+ lcd_set_pixel(x, y-i, TRUE); |
|
86 |
+ lcd_set_pixel(x, y+i, TRUE); |
|
87 |
+ } |
|
88 |
+ |
|
89 |
+ for (t = 0; t < el; ++t) { |
|
90 |
+ err -= es; |
|
91 |
+ if (err < 0) { |
|
92 |
+ err += el; |
|
93 |
+ x += ddx; |
|
94 |
+ y += ddy; |
|
95 |
+ } else { |
|
96 |
+ x += pdx; |
|
97 |
+ y += pdy; |
|
98 |
+ } |
|
99 |
+ lcd_set_pixel(x, y, TRUE); |
|
100 |
+ for (i=1; i<thickness; i++) { |
|
101 |
+ lcd_set_pixel(x-i, y, TRUE); |
|
102 |
+ lcd_set_pixel(x+i, y, TRUE); |
|
103 |
+ lcd_set_pixel(x, y-i, TRUE); |
|
104 |
+ lcd_set_pixel(x, y+i, TRUE); |
|
105 |
+ } |
|
106 |
+ } |
|
107 |
+ lcd_update_display(); |
|
108 |
+} |
|
109 |
+ |
|
110 |
+u8t oswald_write_character(u8t x, u8t y, oswald_font_face face, u8t Character) |
|
111 |
+{ |
|
112 |
+#if 0 |
|
113 |
+ u8t CharacterHeight = GetCharacterHeight(); |
|
114 |
+ u8t CharacterWidth = GetCharacterWidth(Character); |
|
115 |
+ u16t bitmap[MAX_FONT_ROWS]; |
|
116 |
+ register lx, ly; |
|
117 |
+ |
|
118 |
+ GetCharacterBitmap(Character, bitmap); |
|
119 |
+ |
|
120 |
+ // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight); |
|
121 |
+ for (ly=0; ly<CharacterHeight; ly++) { |
|
122 |
+ for (lx=0; lx<CharacterWidth; lx++) { |
|
123 |
+ if (bitmap[ly] & (1<<lx)) { |
|
124 |
+ lcd_set_pixel(lx+x, ly+y, TRUE); |
|
125 |
+ // printf("."); |
|
126 |
+ } else { |
|
127 |
+ lcd_set_pixel(lx+x, ly+y, FALSE); |
|
128 |
+ // printf(" "); |
|
129 |
+ } |
|
130 |
+ } |
|
131 |
+ // printf("\n"); |
|
132 |
+ } |
|
133 |
+ |
|
134 |
+ return CharacterWidth + GetFontSpacing(); |
|
135 |
+#endif |
|
136 |
+ char *cdata = oswald_fonts[face].data[Character]; |
|
137 |
+ |
|
138 |
+ dbg_out("%c", cdata[1]); |
|
139 |
+ return 0; |
|
140 |
+} |
|
141 |
+ |
|
142 |
+void oswald_write_string(u8t x, u8t y, oswald_font_face face, u8t *str) |
|
143 |
+{ |
|
144 |
+ register lx, i, strl; |
|
145 |
+ |
|
146 |
+ strl = oswald_strlen(str); |
|
147 |
+ if (strl == 0) |
|
148 |
+ return; |
|
149 |
+ |
|
150 |
+ lx = x; |
|
151 |
+ for (i=0; i<strl; i++) { |
|
152 |
+ lx += WriteLcdCharacter(lx, y, str[i]); |
|
153 |
+ } |
|
154 |
+} |
|
155 |
+ |
|
156 |
+ |
|
157 |
+void oswald_Write_number(u8t x, u8t y, oswald_font_face face, s16t number) |
|
158 |
+{ |
|
159 |
+ register lx, i, strl; |
|
160 |
+ u8t str[8]; |
|
161 |
+ |
|
162 |
+ itoa(number, str, 10); |
|
163 |
+ strl = oswald_strlen(str); |
|
164 |
+ if (strl == 0) |
|
165 |
+ return; |
|
166 |
+ |
|
167 |
+ lx = x; |
|
168 |
+ for (i=0; i<strl; i++) { |
|
169 |
+ lx += WriteLcdCharacter(lx, y, str[i]); |
|
170 |
+ } |
|
171 |
+} |
|
172 |
+ |