diff options
-rw-r--r-- | apps/gui/line.c | 12 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | firmware/drivers/lcd-charcell.c | 24 |
3 files changed, 20 insertions, 18 deletions
diff --git a/apps/gui/line.c b/apps/gui/line.c index e2eb6f277b..fe017970e6 100644 --- a/apps/gui/line.c +++ b/apps/gui/line.c | |||
@@ -53,18 +53,15 @@ static void put_text(struct screen *display, int x, int y, struct line_desc *lin | |||
53 | struct line_desc_scroll { | 53 | struct line_desc_scroll { |
54 | struct line_desc desc; /* must be first! */ | 54 | struct line_desc desc; /* must be first! */ |
55 | bool used; | 55 | bool used; |
56 | }; | 56 | } lines[MAX_LINES]; |
57 | |||
58 | #define NOINLINE __attribute__ ((noinline)) | ||
59 | 57 | ||
60 | struct line_desc_scroll *get_line_desc(void) NOINLINE; | 58 | static struct line_desc_scroll *get_line_desc(void) |
61 | struct line_desc_scroll *get_line_desc(void) | ||
62 | { | 59 | { |
63 | static struct line_desc_scroll lines[MAX_LINES]; | ||
64 | static unsigned line_index; | 60 | static unsigned line_index; |
65 | struct line_desc_scroll *this; | 61 | struct line_desc_scroll *this; |
66 | 62 | ||
67 | do { | 63 | do |
64 | { | ||
68 | this = &lines[line_index++]; | 65 | this = &lines[line_index++]; |
69 | if (line_index >= ARRAYLEN(lines)) | 66 | if (line_index >= ARRAYLEN(lines)) |
70 | line_index = 0; | 67 | line_index = 0; |
@@ -87,7 +84,6 @@ static void scroller(struct scrollinfo *s, struct screen *display) | |||
87 | line->used = false; | 84 | line->used = false; |
88 | } | 85 | } |
89 | else | 86 | else |
90 | if (s->line) | ||
91 | { | 87 | { |
92 | style_line(display, s->x, s->y - (line->desc.height/2 - display->getcharheight()/2), &line->desc); | 88 | style_line(display, s->x, s->y - (line->desc.height/2 - display->getcharheight()/2), &line->desc); |
93 | put_text(display, s->x, s->y, &line->desc, s->line, true, s->offset); | 89 | put_text(display, s->x, s->y, &line->desc, s->line, true, s->offset); |
diff --git a/apps/plugin.h b/apps/plugin.h index 5d6527d7a4..8a0d0562ff 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -326,7 +326,7 @@ struct plugin_api { | |||
326 | void (*lcd_remote_set_contrast)(int x); | 326 | void (*lcd_remote_set_contrast)(int x); |
327 | void (*lcd_remote_clear_display)(void); | 327 | void (*lcd_remote_clear_display)(void); |
328 | void (*lcd_remote_puts)(int x, int y, const unsigned char *string); | 328 | void (*lcd_remote_puts)(int x, int y, const unsigned char *string); |
329 | void (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string); | 329 | bool (*lcd_remote_puts_scroll)(int x, int y, const unsigned char* string); |
330 | void (*lcd_remote_scroll_stop)(void); | 330 | void (*lcd_remote_scroll_stop)(void); |
331 | void (*lcd_remote_set_drawmode)(int mode); | 331 | void (*lcd_remote_set_drawmode)(int mode); |
332 | int (*lcd_remote_get_drawmode)(void); | 332 | int (*lcd_remote_get_drawmode)(void); |
diff --git a/firmware/drivers/lcd-charcell.c b/firmware/drivers/lcd-charcell.c index 6a6e57e992..46c48bb726 100644 --- a/firmware/drivers/lcd-charcell.c +++ b/firmware/drivers/lcd-charcell.c | |||
@@ -511,7 +511,7 @@ void lcd_putsf(int x, int y, const unsigned char *fmt, ...) | |||
511 | 511 | ||
512 | /** scrolling **/ | 512 | /** scrolling **/ |
513 | 513 | ||
514 | void lcd_puts_scroll_worker(int x, int y, const unsigned char *string, | 514 | bool lcd_puts_scroll_worker(int x, int y, const unsigned char *string, |
515 | int offset, | 515 | int offset, |
516 | void (*scroll_func)(struct scrollinfo *), void *data) | 516 | void (*scroll_func)(struct scrollinfo *), void *data) |
517 | { | 517 | { |
@@ -519,12 +519,13 @@ void lcd_puts_scroll_worker(int x, int y, const unsigned char *string, | |||
519 | int len; | 519 | int len; |
520 | 520 | ||
521 | if ((unsigned)y >= (unsigned)current_vp->height) | 521 | if ((unsigned)y >= (unsigned)current_vp->height) |
522 | return; | 522 | return false; |
523 | 523 | ||
524 | /* remove any previously scrolling line at the same location */ | 524 | /* remove any previously scrolling line at the same location */ |
525 | lcd_scroll_stop_viewport_rect(current_vp, x, y, current_vp->width - x, 1); | 525 | lcd_scroll_stop_viewport_rect(current_vp, x, y, current_vp->width - x, 1); |
526 | 526 | ||
527 | if (lcd_scroll_info.lines >= LCD_SCROLLABLE_LINES) return; | 527 | if (lcd_scroll_info.lines >= LCD_SCROLLABLE_LINES) |
528 | return false; | ||
528 | 529 | ||
529 | s = &lcd_scroll_info.scroll[lcd_scroll_info.lines]; | 530 | s = &lcd_scroll_info.scroll[lcd_scroll_info.lines]; |
530 | 531 | ||
@@ -534,7 +535,7 @@ void lcd_puts_scroll_worker(int x, int y, const unsigned char *string, | |||
534 | len = utf8length(string); | 535 | len = utf8length(string); |
535 | 536 | ||
536 | if (current_vp->width - x >= len) | 537 | if (current_vp->width - x >= len) |
537 | return; | 538 | return false; |
538 | /* prepare scroll line */ | 539 | /* prepare scroll line */ |
539 | strlcpy(s->linebuffer, string, sizeof s->linebuffer); | 540 | strlcpy(s->linebuffer, string, sizeof s->linebuffer); |
540 | 541 | ||
@@ -558,19 +559,24 @@ void lcd_puts_scroll_worker(int x, int y, const unsigned char *string, | |||
558 | s->offset = offset; | 559 | s->offset = offset; |
559 | s->backward = false; | 560 | s->backward = false; |
560 | lcd_scroll_info.lines++; | 561 | lcd_scroll_info.lines++; |
562 | |||
563 | return true; | ||
561 | } | 564 | } |
562 | 565 | ||
563 | void lcd_putsxy_scroll_func(int x, int y, const unsigned char *string, | 566 | bool lcd_putsxy_scroll_func(int x, int y, const unsigned char *string, |
564 | void (*scroll_func)(struct scrollinfo *), | 567 | void (*scroll_func)(struct scrollinfo *), |
565 | void *data, int x_offset) | 568 | void *data, int x_offset) |
566 | { | 569 | { |
570 | bool retval = false; | ||
567 | if (!scroll_func) | 571 | if (!scroll_func) |
568 | lcd_putsxyofs(x, y, x_offset, string); | 572 | lcd_putsxyofs(x, y, x_offset, string); |
569 | else | 573 | else |
570 | lcd_puts_scroll_worker(x, y, string, x_offset, scroll_func, data); | 574 | retval = lcd_puts_scroll_worker(x, y, string, x_offset, scroll_func, data); |
575 | |||
576 | return retval; | ||
571 | } | 577 | } |
572 | 578 | ||
573 | void lcd_scroll_fn(struct scrollinfo* s) | 579 | static void lcd_scroll_fn(struct scrollinfo* s) |
574 | { | 580 | { |
575 | lcd_putsxyofs(s->x, s->y, s->offset, s->line); | 581 | lcd_putsxyofs(s->x, s->y, s->offset, s->line); |
576 | if (lcd_cursor.enabled) | 582 | if (lcd_cursor.enabled) |
@@ -583,7 +589,7 @@ void lcd_scroll_fn(struct scrollinfo* s) | |||
583 | } | 589 | } |
584 | } | 590 | } |
585 | 591 | ||
586 | void lcd_puts_scroll(int x, int y, const unsigned char *string) | 592 | bool lcd_puts_scroll(int x, int y, const unsigned char *string) |
587 | { | 593 | { |
588 | lcd_puts_scroll_worker(x, y, string, 0, lcd_scroll_fn, NULL); | 594 | return lcd_puts_scroll_worker(x, y, string, 0, lcd_scroll_fn, NULL); |
589 | } | 595 | } |