summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/lcd.c57
1 files changed, 33 insertions, 24 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c
index f82ceb44a1..e3acddd543 100644
--- a/firmware/drivers/lcd.c
+++ b/firmware/drivers/lcd.c
@@ -100,6 +100,8 @@
100 100
101/*** generic code ***/ 101/*** generic code ***/
102 102
103#define SCROLL_DELAY 10 /* number of "scroll ticks" until scroll starts */
104
103struct scrollinfo { 105struct scrollinfo {
104 char text[128]; 106 char text[128];
105 int textlen; 107 int textlen;
@@ -115,7 +117,7 @@ static char scroll_stack[0x100];
115static char scroll_speed = 10; /* updates per second */ 117static char scroll_speed = 10; /* updates per second */
116 118
117static struct scrollinfo scroll; /* only one scroll line at the moment */ 119static struct scrollinfo scroll; /* only one scroll line at the moment */
118static bool run_scroll = false; 120static int scroll_count = 0;
119 121
120#ifndef SIMULATOR 122#ifndef SIMULATOR
121/* 123/*
@@ -773,6 +775,7 @@ void lcd_puts_scroll(int x, int y, char* string )
773 lcd_getfontsize(font, &width, &height); 775 lcd_getfontsize(font, &width, &height);
774 s->space = (LCD_WIDTH - xmargin - x) / width; 776 s->space = (LCD_WIDTH - xmargin - x) / width;
775#endif 777#endif
778 lcd_puts(x,y,string);
776 s->offset=0; 779 s->offset=0;
777 s->xpos=x; 780 s->xpos=x;
778 s->startx=x; 781 s->startx=x;
@@ -781,19 +784,19 @@ void lcd_puts_scroll(int x, int y, char* string )
781 strncpy(s->text,string,sizeof s->text); 784 strncpy(s->text,string,sizeof s->text);
782 s->text[sizeof s->text - 1] = 0; 785 s->text[sizeof s->text - 1] = 0;
783 786
784 run_scroll = true; 787 scroll_count = 1;
785 lcd_puts(s->xpos,y,s->text + s->offset);
786 lcd_update();
787} 788}
788 789
789void lcd_stop_scroll(void) 790void lcd_stop_scroll(void)
790{ 791{
791 struct scrollinfo* s = &scroll; 792 if ( scroll_count ) {
792 run_scroll = false; 793 struct scrollinfo* s = &scroll;
793 794 scroll_count = 0;
794 /* restore scrolled row */ 795
795 lcd_puts(s->startx,s->starty,s->text); 796 /* restore scrolled row */
796 lcd_update(); 797 lcd_puts(s->startx,s->starty,s->text);
798 lcd_update();
799 }
797} 800}
798 801
799void lcd_scroll_speed(int speed) 802void lcd_scroll_speed(int speed)
@@ -805,23 +808,29 @@ static void scroll_thread(void)
805{ 808{
806 struct scrollinfo* s = &scroll; 809 struct scrollinfo* s = &scroll;
807 while ( 1 ) { 810 while ( 1 ) {
808 if ( !run_scroll ) { 811 if ( !scroll_count ) {
809 yield(); 812 yield();
810 continue; 813 continue;
811 } 814 }
812 lcd_puts(s->xpos,s->starty,s->text + s->offset); 815 if ( scroll_count < SCROLL_DELAY )
813 if ( s->textlen - s->offset < s->space ) 816 scroll_count++;
814 lcd_puts(s->startx + s->textlen - s->offset, s->starty," "); 817 else {
815 lcd_update(); 818 lcd_puts(s->xpos,s->starty,s->text + s->offset);
816 819 debugf("puts(%2d,%s)\n",s->xpos,s->text+s->offset);
817 if ( s->xpos > s->startx ) 820 if ( s->textlen - s->offset < s->space )
818 s->xpos--; 821 lcd_puts(s->startx + s->textlen - s->offset, s->starty," ");
819 else 822 lcd_update();
820 s->offset++; 823
821 824 if ( s->xpos > s->startx )
822 if (s->offset > s->textlen) { 825 s->xpos--;
823 s->offset=0; 826 else
824 s->xpos = s->space-1; 827 s->offset++;
828
829 if (s->offset > s->textlen) {
830 scroll_count = SCROLL_DELAY; /* prevent wrap */
831 s->offset=0;
832 s->xpos = s->space;
833 }
825 } 834 }
826 sleep(HZ/scroll_speed); 835 sleep(HZ/scroll_speed);
827 } 836 }