diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd.c | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 837fd5734d..59b1cc75c4 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c | |||
@@ -103,9 +103,9 @@ | |||
103 | 103 | ||
104 | struct scrollinfo { | 104 | struct scrollinfo { |
105 | char text[128]; | 105 | char text[128]; |
106 | char line[32]; | ||
106 | int textlen; | 107 | int textlen; |
107 | char offset; | 108 | char offset; |
108 | char xpos; | ||
109 | char startx; | 109 | char startx; |
110 | char starty; | 110 | char starty; |
111 | char space; | 111 | char space; |
@@ -113,7 +113,9 @@ struct scrollinfo { | |||
113 | 113 | ||
114 | static void scroll_thread(void); | 114 | static void scroll_thread(void); |
115 | static char scroll_stack[0x100]; | 115 | static char scroll_stack[0x100]; |
116 | static char scroll_speed = 5; /* updates per second */ | 116 | static char scroll_speed = 8; /* updates per second */ |
117 | static char scroll_spacing = 3; /* spaces between end and start of text */ | ||
118 | |||
117 | 119 | ||
118 | static struct scrollinfo scroll; /* only one scroll line at the moment */ | 120 | static struct scrollinfo scroll; /* only one scroll line at the moment */ |
119 | static int scroll_count = 0; | 121 | static int scroll_count = 0; |
@@ -766,17 +768,18 @@ void lcd_puts_scroll(int x, int y, char* string ) | |||
766 | #else | 768 | #else |
767 | int width, height; | 769 | int width, height; |
768 | lcd_getfontsize(font, &width, &height); | 770 | lcd_getfontsize(font, &width, &height); |
769 | s->space = (LCD_WIDTH - xmargin - x) / width; | 771 | s->space = (LCD_WIDTH - xmargin - x*width) / width; |
770 | #endif | 772 | #endif |
771 | lcd_puts(x,y,string); | 773 | lcd_puts(x,y,string); |
772 | s->textlen = strlen(string); | 774 | s->textlen = strlen(string); |
773 | if ( s->textlen > s->space ) { | 775 | if ( s->textlen > s->space ) { |
774 | s->offset=0; | 776 | s->offset=s->space; |
775 | s->xpos=x; | ||
776 | s->startx=x; | 777 | s->startx=x; |
777 | s->starty=y; | 778 | s->starty=y; |
778 | strncpy(s->text,string,sizeof s->text); | 779 | strncpy(s->text,string,sizeof s->text); |
779 | s->text[sizeof s->text - 1] = 0; | 780 | s->text[sizeof s->text - 1] = 0; |
781 | strncpy(s->line,string,sizeof s->line); | ||
782 | s->line[sizeof s->line - 1] = 0; | ||
780 | scroll_count = 1; | 783 | scroll_count = 1; |
781 | } | 784 | } |
782 | } | 785 | } |
@@ -801,31 +804,34 @@ void lcd_scroll_speed(int speed) | |||
801 | static void scroll_thread(void) | 804 | static void scroll_thread(void) |
802 | { | 805 | { |
803 | struct scrollinfo* s = &scroll; | 806 | struct scrollinfo* s = &scroll; |
807 | |||
804 | while ( 1 ) { | 808 | while ( 1 ) { |
805 | if ( !scroll_count ) { | 809 | if ( !scroll_count ) { |
806 | yield(); | 810 | yield(); |
807 | continue; | 811 | continue; |
808 | } | 812 | } |
809 | /* wait 1s before starting scroll */ | 813 | /* wait 0.5s before starting scroll */ |
810 | if ( scroll_count < scroll_speed ) | 814 | if ( scroll_count < scroll_speed/2 ) |
811 | scroll_count++; | 815 | scroll_count++; |
812 | else { | 816 | else { |
813 | lcd_puts(s->xpos,s->starty,s->text + s->offset); | 817 | int i; |
814 | if ( s->textlen - s->offset < s->space ) | 818 | for ( i=0; i<s->space-1; i++ ) |
815 | lcd_puts(s->startx + s->textlen - s->offset, s->starty," "); | 819 | s->line[i] = s->line[i+1]; |
816 | lcd_update(); | 820 | |
817 | 821 | if ( s->offset < s->textlen ) { | |
818 | if ( s->xpos > s->startx ) | 822 | s->line[s->space - 1] = s->text[s->offset]; |
819 | s->xpos--; | ||
820 | else | ||
821 | s->offset++; | 823 | s->offset++; |
822 | |||
823 | if (s->offset >= s->textlen) { | ||
824 | lcd_puts(s->startx + s->textlen - s->offset, s->starty," "); | ||
825 | scroll_count = scroll_speed; /* prevent wrap */ | ||
826 | s->offset=0; | ||
827 | s->xpos = s->space-1; | ||
828 | } | 824 | } |
825 | else { | ||
826 | s->line[s->space - 1] = ' '; | ||
827 | if ( s->offset < s->textlen + scroll_spacing - 1 ) | ||
828 | s->offset++; | ||
829 | else | ||
830 | s->offset = 0; | ||
831 | } | ||
832 | |||
833 | lcd_puts(s->startx,s->starty,s->line); | ||
834 | lcd_update(); | ||
829 | } | 835 | } |
830 | sleep(HZ/scroll_speed); | 836 | sleep(HZ/scroll_speed); |
831 | } | 837 | } |