diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 31 | ||||
-rw-r--r-- | firmware/drivers/lcd.h | 5 |
2 files changed, 13 insertions, 23 deletions
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 9f86d8f1c4..fee42d9ef4 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -228,17 +228,9 @@ void lcd_setfont(int newfont) | |||
228 | curfont = newfont; | 228 | curfont = newfont; |
229 | } | 229 | } |
230 | 230 | ||
231 | void lcd_getfontsize(int font, int *width, int *height) | 231 | int lcd_getstringsize(unsigned char *str, int *w, int *h) |
232 | { | 232 | { |
233 | struct font* pf = font_get(font); | 233 | struct font* pf = font_get(curfont); |
234 | |||
235 | *width = pf->maxwidth; | ||
236 | *height = pf->height; | ||
237 | } | ||
238 | |||
239 | int lcd_getstringsize(unsigned char *str, int font, int *w, int *h) | ||
240 | { | ||
241 | struct font* pf = font_get(font); | ||
242 | int ch; | 234 | int ch; |
243 | int width = 0; | 235 | int width = 0; |
244 | 236 | ||
@@ -279,10 +271,10 @@ void lcd_puts(int x, int y, unsigned char *str) | |||
279 | if(!str || !str[0]) | 271 | if(!str || !str[0]) |
280 | return; | 272 | return; |
281 | 273 | ||
282 | lcd_getstringsize(str, curfont, &w, &h); | 274 | lcd_getstringsize(str, &w, &h); |
283 | xpos = xmargin + x*w / strlen(str); | 275 | xpos = xmargin + x*w / strlen(str); |
284 | ypos = ymargin + y*h; | 276 | ypos = ymargin + y*h; |
285 | lcd_putsxy( xpos, ypos, str, curfont); | 277 | lcd_putsxy(xpos, ypos, str); |
286 | lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h); | 278 | lcd_clearrect(xpos + w, ypos, LCD_WIDTH - (xpos + w), h); |
287 | 279 | ||
288 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) | 280 | #if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) |
@@ -293,10 +285,10 @@ void lcd_puts(int x, int y, unsigned char *str) | |||
293 | } | 285 | } |
294 | 286 | ||
295 | /* put a string at a given pixel position */ | 287 | /* put a string at a given pixel position */ |
296 | void lcd_putsxy(int x, int y, unsigned char *str, int font) | 288 | void lcd_putsxy(int x, int y, unsigned char *str) |
297 | { | 289 | { |
298 | int ch; | 290 | int ch; |
299 | struct font* pf = font_get(font); | 291 | struct font* pf = font_get(curfont); |
300 | 292 | ||
301 | while (((ch = *str++) != '\0')) { | 293 | while (((ch = *str++) != '\0')) { |
302 | bitmap_t *bits; | 294 | bitmap_t *bits; |
@@ -645,15 +637,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string ) | |||
645 | struct scrollinfo* s = &scroll; | 637 | struct scrollinfo* s = &scroll; |
646 | unsigned char ch[2]; | 638 | unsigned char ch[2]; |
647 | int w, h; | 639 | int w, h; |
648 | int width, height; | 640 | int width; |
649 | lcd_getfontsize(curfont, &width, &height); | ||
650 | 641 | ||
651 | ch[1] = 0; /* zero terminate */ | 642 | ch[1] = 0; /* zero terminate */ |
652 | ch[0] = string[0]; | 643 | ch[0] = string[0]; |
653 | width = 0; | 644 | width = 0; |
654 | s->space = 0; | 645 | s->space = 0; |
655 | while ( ch[0] && | 646 | while ( ch[0] && |
656 | (width + lcd_getstringsize(ch, curfont, &w, &h) < | 647 | (width + lcd_getstringsize(ch, &w, &h) < |
657 | (LCD_WIDTH - x*8))) { | 648 | (LCD_WIDTH - x*8))) { |
658 | width += w; | 649 | width += w; |
659 | s->space++; | 650 | s->space++; |
@@ -664,7 +655,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string ) | |||
664 | s->textlen = strlen(string); | 655 | s->textlen = strlen(string); |
665 | 656 | ||
666 | s->space += 2; | 657 | s->space += 2; |
667 | lcd_getstringsize(string,curfont,&w,&h); | 658 | lcd_getstringsize(string,&w,&h); |
668 | if ( w > LCD_WIDTH - xmargin ) { | 659 | if ( w > LCD_WIDTH - xmargin ) { |
669 | s->offset=s->space; | 660 | s->offset=s->space; |
670 | s->startx=x; | 661 | s->startx=x; |
@@ -688,7 +679,7 @@ void lcd_stop_scroll(void) | |||
688 | struct scrollinfo* s = &scroll; | 679 | struct scrollinfo* s = &scroll; |
689 | scroll_count = 0; | 680 | scroll_count = 0; |
690 | 681 | ||
691 | lcd_getstringsize( s->text, FONT_UI, &w, &h); | 682 | lcd_getstringsize( s->text, &w, &h); |
692 | lcd_clearrect(xmargin + s->startx*w/s->textlen, | 683 | lcd_clearrect(xmargin + s->startx*w/s->textlen, |
693 | ymargin + s->starty*h, | 684 | ymargin + s->starty*h, |
694 | LCD_WIDTH - xmargin, | 685 | LCD_WIDTH - xmargin, |
@@ -745,7 +736,7 @@ static void scroll_thread(void) | |||
745 | s->offset = 0; | 736 | s->offset = 0; |
746 | } | 737 | } |
747 | 738 | ||
748 | lcd_getstringsize( s->text, FONT_UI, &w, &h); | 739 | lcd_getstringsize( s->text, &w, &h); |
749 | lcd_clearrect(xmargin + s->startx*w/s->textlen, | 740 | lcd_clearrect(xmargin + s->startx*w/s->textlen, |
750 | ymargin + s->starty*h, | 741 | ymargin + s->starty*h, |
751 | LCD_WIDTH - xmargin, | 742 | LCD_WIDTH - xmargin, |
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h index 76e38375e4..32f636059c 100644 --- a/firmware/drivers/lcd.h +++ b/firmware/drivers/lcd.h | |||
@@ -117,11 +117,10 @@ extern void lcd_invertpixel(int x, int y); | |||
117 | extern void lcd_roll(int pixels); | 117 | extern void lcd_roll(int pixels); |
118 | 118 | ||
119 | extern void lcd_setfont(int font); | 119 | extern void lcd_setfont(int font); |
120 | extern void lcd_getfontsize(int font, int *width, int *height); | 120 | extern void lcd_putsxy(int x, int y, unsigned char *string); |
121 | extern void lcd_putsxy(int x, int y, unsigned char *string, int font); | 121 | extern int lcd_getstringsize(unsigned char *str, int *w, int *h); |
122 | 122 | ||
123 | #endif /* CHARCELLS / BITMAP */ | 123 | #endif /* CHARCELLS / BITMAP */ |
124 | 124 | ||
125 | extern int lcd_getstringsize(unsigned char *str, int font, int *w, int *h); | ||
126 | 125 | ||
127 | #endif /* __LCD_H__ */ | 126 | #endif /* __LCD_H__ */ |