summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-06-12 15:15:51 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-06-12 15:15:51 +0000
commit4b422aaa366191462e430a9c18f368e5e784efa2 (patch)
tree90cb80bd66ed4b897be5a040fd4031273ba80d8c
parent8169c8f5bdac59b12ecaf7537e1351a8a94e311e (diff)
downloadrockbox-4b422aaa366191462e430a9c18f368e5e784efa2.tar.gz
rockbox-4b422aaa366191462e430a9c18f368e5e784efa2.zip
Fixed tighter looping scroll.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@977 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/lcd.c48
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
104struct scrollinfo { 104struct 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
114static void scroll_thread(void); 114static void scroll_thread(void);
115static char scroll_stack[0x100]; 115static char scroll_stack[0x100];
116static char scroll_speed = 5; /* updates per second */ 116static char scroll_speed = 8; /* updates per second */
117static char scroll_spacing = 3; /* spaces between end and start of text */
118
117 119
118static struct scrollinfo scroll; /* only one scroll line at the moment */ 120static struct scrollinfo scroll; /* only one scroll line at the moment */
119static int scroll_count = 0; 121static 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)
801static void scroll_thread(void) 804static 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 }