diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-bitmap-common.c | 34 | ||||
-rw-r--r-- | firmware/export/lcd.h | 1 |
2 files changed, 17 insertions, 18 deletions
diff --git a/firmware/drivers/lcd-bitmap-common.c b/firmware/drivers/lcd-bitmap-common.c index fc84fdd6a1..8d95825858 100644 --- a/firmware/drivers/lcd-bitmap-common.c +++ b/firmware/drivers/lcd-bitmap-common.c | |||
@@ -254,11 +254,12 @@ void LCDFN(putsxyf)(int x, int y, const unsigned char *fmt, ...) | |||
254 | 254 | ||
255 | static void LCDFN(putsxyofs_style)(int xpos, int ypos, | 255 | static void LCDFN(putsxyofs_style)(int xpos, int ypos, |
256 | const unsigned char *str, int style, | 256 | const unsigned char *str, int style, |
257 | int w, int h, int offset) | 257 | int h, int offset) |
258 | { | 258 | { |
259 | int lastmode = current_vp->drawmode; | 259 | int lastmode = current_vp->drawmode; |
260 | int xrect = xpos + MAX(w - offset, 0); | 260 | int text_ypos = ypos; |
261 | int x = VP_IS_RTL(current_vp) ? xpos : xrect; | 261 | int line_height = font_get(current_vp->font)->height; |
262 | text_ypos += h/2 - line_height/2; /* center the text in the line */ | ||
262 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) | 263 | #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) |
263 | int oldfgcolor = current_vp->fg_pattern; | 264 | int oldfgcolor = current_vp->fg_pattern; |
264 | int oldbgcolor = current_vp->bg_pattern; | 265 | int oldbgcolor = current_vp->bg_pattern; |
@@ -284,21 +285,21 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos, | |||
284 | current_vp->fg_pattern = current_vp->lst_pattern; | 285 | current_vp->fg_pattern = current_vp->lst_pattern; |
285 | } | 286 | } |
286 | else { | 287 | else { |
287 | lcd_fillrect(x, ypos, current_vp->width - xrect, h); | 288 | lcd_fillrect(xpos, ypos, current_vp->width - xpos, h); |
288 | current_vp->drawmode = (style & STYLE_INVERT) ? | 289 | current_vp->drawmode = (style & STYLE_INVERT) ? |
289 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | 290 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; |
290 | } | 291 | } |
291 | if (str[0]) | 292 | if (str[0]) |
292 | lcd_putsxyofs(xpos, ypos, offset, str); | 293 | lcd_putsxyofs(xpos, text_ypos, offset, str); |
293 | current_vp->fg_pattern = oldfgcolor; | 294 | current_vp->fg_pattern = oldfgcolor; |
294 | current_vp->bg_pattern = oldbgcolor; | 295 | current_vp->bg_pattern = oldbgcolor; |
295 | #else | 296 | #else |
296 | current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ? | 297 | current_vp->drawmode = DRMODE_SOLID | ((style & STYLE_INVERT) ? |
297 | 0 : DRMODE_INVERSEVID); | 298 | 0 : DRMODE_INVERSEVID); |
298 | LCDFN(fillrect)(x, ypos, current_vp->width - xrect, h); | 299 | LCDFN(fillrect)(xpos, ypos, current_vp->width - xpos, h); |
299 | current_vp->drawmode ^= DRMODE_INVERSEVID; | 300 | current_vp->drawmode ^= DRMODE_INVERSEVID; |
300 | if (str[0]) | 301 | if (str[0]) |
301 | LCDFN(putsxyofs)(xpos, ypos, offset, str); | 302 | LCDFN(putsxyofs)(xpos, text_ypos, offset, str); |
302 | #endif | 303 | #endif |
303 | current_vp->drawmode = lastmode; | 304 | current_vp->drawmode = lastmode; |
304 | } | 305 | } |
@@ -309,15 +310,15 @@ static void LCDFN(putsxyofs_style)(int xpos, int ypos, | |||
309 | void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str, | 310 | void LCDFN(puts_style_xyoffset)(int x, int y, const unsigned char *str, |
310 | int style, int x_offset, int y_offset) | 311 | int style, int x_offset, int y_offset) |
311 | { | 312 | { |
312 | int xpos, ypos, w, h; | 313 | int xpos, ypos, h; |
313 | LCDFN(scroll_stop_line)(current_vp, y); | 314 | LCDFN(scroll_stop_line)(current_vp, y); |
314 | if(!str) | 315 | if(!str) |
315 | return; | 316 | return; |
316 | 317 | ||
317 | LCDFN(getstringsize)(str, &w, &h); | 318 | h = current_vp->line_height ?: (int)font_get(current_vp->font)->height; |
318 | xpos = x * LCDFN(getstringsize)(" ", NULL, NULL); | 319 | xpos = x * LCDFN(getstringsize)(" ", NULL, NULL); |
319 | ypos = y * h + y_offset; | 320 | ypos = y * h + y_offset; |
320 | LCDFN(putsxyofs_style)(xpos, ypos, str, style, w, h, x_offset); | 321 | LCDFN(putsxyofs_style)(xpos, ypos, str, style, h, x_offset); |
321 | } | 322 | } |
322 | 323 | ||
323 | void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, | 324 | void LCDFN(puts_style_offset)(int x, int y, const unsigned char *str, |
@@ -436,10 +437,9 @@ void LCDFN(puts_scroll_offset)(int x, int y, const unsigned char *string, | |||
436 | 437 | ||
437 | void LCDFN(scroll_fn)(void) | 438 | void LCDFN(scroll_fn)(void) |
438 | { | 439 | { |
439 | struct font* pf; | ||
440 | struct scrollinfo* s; | 440 | struct scrollinfo* s; |
441 | int index; | 441 | int index; |
442 | int xpos, ypos; | 442 | int xpos, ypos, height; |
443 | struct viewport* old_vp = current_vp; | 443 | struct viewport* old_vp = current_vp; |
444 | bool makedelay; | 444 | bool makedelay; |
445 | 445 | ||
@@ -451,15 +451,15 @@ void LCDFN(scroll_fn)(void) | |||
451 | continue; | 451 | continue; |
452 | 452 | ||
453 | LCDFN(set_viewport)(s->vp); | 453 | LCDFN(set_viewport)(s->vp); |
454 | height = s->vp->line_height; | ||
454 | 455 | ||
455 | if (s->backward) | 456 | if (s->backward) |
456 | s->offset -= LCDFN(scroll_info).step; | 457 | s->offset -= LCDFN(scroll_info).step; |
457 | else | 458 | else |
458 | s->offset += LCDFN(scroll_info).step; | 459 | s->offset += LCDFN(scroll_info).step; |
459 | 460 | ||
460 | pf = font_get(current_vp->font); | ||
461 | xpos = s->startx; | 461 | xpos = s->startx; |
462 | ypos = s->y * pf->height + s->y_offset; | 462 | ypos = s->y * height + s->y_offset; |
463 | 463 | ||
464 | makedelay = false; | 464 | makedelay = false; |
465 | if (s->bidir) { /* scroll bidirectional */ | 465 | if (s->bidir) { /* scroll bidirectional */ |
@@ -488,10 +488,8 @@ void LCDFN(scroll_fn)(void) | |||
488 | s->start_tick = current_tick + LCDFN(scroll_info).delay + | 488 | s->start_tick = current_tick + LCDFN(scroll_info).delay + |
489 | LCDFN(scroll_info).ticks; | 489 | LCDFN(scroll_info).ticks; |
490 | 490 | ||
491 | LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, s->width, | 491 | LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, height, s->offset); |
492 | pf->height, s->offset); | 492 | LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width-xpos, height); |
493 | LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, | ||
494 | pf->height); | ||
495 | } | 493 | } |
496 | LCDFN(set_viewport)(old_vp); | 494 | LCDFN(set_viewport)(old_vp); |
497 | } | 495 | } |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index e6e19b1597..56e19ddefa 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -43,6 +43,7 @@ struct viewport { | |||
43 | #ifdef HAVE_LCD_BITMAP | 43 | #ifdef HAVE_LCD_BITMAP |
44 | int flags; | 44 | int flags; |
45 | int font; | 45 | int font; |
46 | int line_height; | ||
46 | int drawmode; | 47 | int drawmode; |
47 | #endif | 48 | #endif |
48 | #if LCD_DEPTH > 1 | 49 | #if LCD_DEPTH > 1 |