summaryrefslogtreecommitdiff
path: root/firmware/drivers/lcd-recorder.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/lcd-recorder.c')
-rw-r--r--firmware/drivers/lcd-recorder.c52
1 files changed, 18 insertions, 34 deletions
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index 6a73c07f70..d1e2a6b0da 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -84,7 +84,7 @@ struct scrollinfo {
84 long start_tick; 84 long start_tick;
85}; 85};
86 86
87static int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ 87static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */
88 88
89static void scroll_thread(void); 89static void scroll_thread(void);
90static char scroll_stack[DEFAULT_STACK_SIZE]; 90static char scroll_stack[DEFAULT_STACK_SIZE];
@@ -212,7 +212,6 @@ void lcd_roll(int lines)
212 212
213void lcd_clear_display (void) 213void lcd_clear_display (void)
214{ 214{
215 DEBUGF("lcd_clear_display()\n");
216 memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); 215 memset (lcd_framebuffer, 0, sizeof lcd_framebuffer);
217 scrolling_lines = 0; 216 scrolling_lines = 0;
218} 217}
@@ -244,7 +243,6 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h)
244 int ch; 243 int ch;
245 int width = 0; 244 int width = 0;
246 245
247 /* DEBUGF("lcd_getstringsize('%s')\n", str); */
248 while((ch = *str++)) { 246 while((ch = *str++)) {
249 /* check input range*/ 247 /* check input range*/
250 if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) 248 if (ch < pf->firstchar || ch >= pf->firstchar+pf->size)
@@ -671,19 +669,24 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
671 int index; 669 int index;
672 int free_index=0; 670 int free_index=0;
673 671
674 DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string);
675 for (index = 0; index < SCROLLABLE_LINES; index++) { 672 for (index = 0; index < SCROLLABLE_LINES; index++) {
676 s = &scroll[index]; 673 s = &scroll[index];
674
677 if (scrolling_lines&(1<<index)) { 675 if (scrolling_lines&(1<<index)) {
678 if (s->starty == y) { 676 if (s->starty == y) {
677 /* we prefer to re-use an existing index with the
678 same y-position */
679 free_index=index; 679 free_index=index;
680 break; 680 break;
681 } 681 }
682 } else 682 }
683 else {
684 /* remember the last unused one */
683 free_index=index; 685 free_index=index;
686 }
684 } 687 }
685 index=free_index; 688 index=free_index;
686 689 s = &scroll[index]; /* get the proper 's' */
687 s->start_tick = current_tick + scroll_delay; 690 s->start_tick = current_tick + scroll_delay;
688 691
689 lcd_puts(x,y,string); 692 lcd_puts(x,y,string);
@@ -693,14 +696,14 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
693 /* prepare scroll line */ 696 /* prepare scroll line */
694 char *end; 697 char *end;
695 698
696 scrolling_lines|=(1<<index);
697 memset(s->line, 0, sizeof s->line); 699 memset(s->line, 0, sizeof s->line);
698 strcpy(s->line, string); 700 strcpy(s->line, string);
699 701
700 /* get width */ 702 /* get width */
701 s->width = lcd_getstringsize(s->line, &w, &h); 703 s->width = lcd_getstringsize(s->line, &w, &h);
702 704
703 /* scroll bidirectional or forward only depending on the string width */ 705 /* scroll bidirectional or forward only depending on the string
706 width */
704 if ( bidir_limit ) { 707 if ( bidir_limit ) {
705 s->bidir = s->width < (LCD_WIDTH - xmargin) * 708 s->bidir = s->width < (LCD_WIDTH - xmargin) *
706 (100 + bidir_limit) / 100; 709 (100 + bidir_limit) / 100;
@@ -714,7 +717,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
714 s->width = lcd_getstringsize(s->line, &w, &h); 717 s->width = lcd_getstringsize(s->line, &w, &h);
715 } 718 }
716 719
717 for (end = s->line; *end; end++); 720 end = strchr(s->line, '\0');
718 strncpy(end, string, LCD_WIDTH/2); 721 strncpy(end, string, LCD_WIDTH/2);
719 722
720 s->len = strlen(string); 723 s->len = strlen(string);
@@ -722,34 +725,15 @@ void lcd_puts_scroll(int x, int y, unsigned char* string)
722 s->startx = x; 725 s->startx = x;
723 s->starty = y; 726 s->starty = y;
724 s->backward = false; 727 s->backward = false;
728 scrolling_lines |= (1<<index);
725 } 729 }
730 else
731 /* force a bit switch-off since it doesn't scroll */
732 scrolling_lines &= ~(1<<index);
726} 733}
727 734
728void lcd_stop_scroll(void) 735void lcd_stop_scroll(void)
729{ 736{
730 DEBUGF("lcd_stop_scroll()\n");
731#if 0
732 struct scrollinfo* s;
733 int w,h;
734 int index;
735 int update=0;
736 for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
737 s = &scroll[index];
738 if ( scrolling_lines&(1<<index) ) {
739 lcd_getstringsize(s->line, &w, &h);
740 lcd_clearrect(xmargin + s->startx * w / s->len,
741 ymargin + s->starty * h,
742 LCD_WIDTH - xmargin,
743 h);
744
745 /* restore scrolled row */
746 lcd_puts(s->startx, s->starty, s->line);
747 update++;
748 }
749 }
750 if(update)
751 lcd_update(); /* update only if needed */
752#endif
753 scrolling_lines=0; 737 scrolling_lines=0;
754} 738}
755 739
@@ -784,12 +768,12 @@ static void scroll_thread(void)
784 768
785 while ( 1 ) { 769 while ( 1 ) {
786 for ( index = 0; index < SCROLLABLE_LINES; index++ ) { 770 for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
787 s = &scroll[index];
788
789 /* really scroll? */ 771 /* really scroll? */
790 if ( !(scrolling_lines&(1<<index)) ) 772 if ( !(scrolling_lines&(1<<index)) )
791 continue; 773 continue;
792 774
775 s = &scroll[index];
776
793 /* check pause */ 777 /* check pause */
794 if (TIME_BEFORE(current_tick, s->start_tick)) 778 if (TIME_BEFORE(current_tick, s->start_tick))
795 continue; 779 continue;