diff options
author | Kjell Ericson <kjell@haxx.se> | 2003-05-22 06:42:14 +0000 |
---|---|---|
committer | Kjell Ericson <kjell@haxx.se> | 2003-05-22 06:42:14 +0000 |
commit | 53f156a6fcec07301a6b29a3f647fff43520af7a (patch) | |
tree | e780f297944fedf31f6cafce3a1d00d4dc989993 /firmware/drivers/lcd-player.c | |
parent | 231ddff4bd3e9d0214b520726ef9235117c87b31 (diff) | |
download | rockbox-53f156a6fcec07301a6b29a3f647fff43520af7a.tar.gz rockbox-53f156a6fcec07301a6b29a3f647fff43520af7a.zip |
New feature for player: Jump scroll!
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3693 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-player.c')
-rw-r--r-- | firmware/drivers/lcd-player.c | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index c5915af9fa..2496fb6f66 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c | |||
@@ -70,6 +70,7 @@ struct scrollinfo { | |||
70 | int starty; | 70 | int starty; |
71 | long scroll_start_tick; | 71 | long scroll_start_tick; |
72 | int direction; /* +1 for right or -1 for left*/ | 72 | int direction; /* +1 for right or -1 for left*/ |
73 | int jump_scroll; | ||
73 | }; | 74 | }; |
74 | 75 | ||
75 | #define MAX_CURSOR_CHARS 8 | 76 | #define MAX_CURSOR_CHARS 8 |
@@ -91,6 +92,7 @@ static int scroll_delay = HZ/2; /* delay before starting scroll */ | |||
91 | static char scroll_spacing = 3; /* spaces between end and start of text */ | 92 | static char scroll_spacing = 3; /* spaces between end and start of text */ |
92 | static bool allow_bidirectional_scrolling = true; | 93 | static bool allow_bidirectional_scrolling = true; |
93 | static int bidir_limit = 50; /* percent */ | 94 | static int bidir_limit = 50; /* percent */ |
95 | static int jump_scroll = 0; /* 0=off, 1=once, 2=always */ | ||
94 | 96 | ||
95 | static struct scrollinfo scroll[SCROLLABLE_LINES]; | 97 | static struct scrollinfo scroll[SCROLLABLE_LINES]; |
96 | 98 | ||
@@ -498,6 +500,11 @@ void lcd_init (void) | |||
498 | sizeof(scroll_stack), scroll_name); | 500 | sizeof(scroll_stack), scroll_name); |
499 | } | 501 | } |
500 | 502 | ||
503 | void lcd_jump_scroll (int mode) /* 0=off, 1=once, 2=always */ | ||
504 | { | ||
505 | jump_scroll=mode; | ||
506 | } | ||
507 | |||
501 | void lcd_bidir_scroll(int percent) | 508 | void lcd_bidir_scroll(int percent) |
502 | { | 509 | { |
503 | bidir_limit = percent; | 510 | bidir_limit = percent; |
@@ -522,6 +529,9 @@ void lcd_puts_scroll(int x, int y, unsigned char* string ) | |||
522 | s->startx=x; | 529 | s->startx=x; |
523 | s->starty=y; | 530 | s->starty=y; |
524 | s->direction=+1; | 531 | s->direction=+1; |
532 | s->jump_scroll=0; | ||
533 | if (jump_scroll && scroll_delay/2<(HZ/scroll_speed)*(s->textlen-11+x)) | ||
534 | s->jump_scroll=11-x; | ||
525 | strncpy(s->text,string,sizeof s->text); | 535 | strncpy(s->text,string,sizeof s->text); |
526 | s->turn_offset=-1; | 536 | s->turn_offset=-1; |
527 | if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) { | 537 | if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) { |
@@ -596,18 +606,40 @@ static void scroll_thread(void) | |||
596 | if ( TIME_AFTER(current_tick, s->scroll_start_tick) ) { | 606 | if ( TIME_AFTER(current_tick, s->scroll_start_tick) ) { |
597 | char buffer[12]; | 607 | char buffer[12]; |
598 | update = true; | 608 | update = true; |
599 | if ( s->offset < s->textlen-1 ) { | 609 | if (s->jump_scroll) { |
600 | s->offset+=s->direction; | 610 | s->offset+=s->jump_scroll; |
601 | if (s->offset==0) { | 611 | s->scroll_start_tick = current_tick + |
602 | s->direction=+1; | 612 | scroll_delay/2; |
603 | s->scroll_start_tick = current_tick + scroll_delay; | 613 | /* Eat space */ |
604 | } else if (s->offset==s->turn_offset) { | 614 | while (s->offset < s->textlen && |
605 | s->direction=-1; | 615 | s->text[s->offset] == ' ') { |
606 | s->scroll_start_tick = current_tick + scroll_delay; | 616 | s->offset++; |
617 | } | ||
618 | if (s->offset >= s->textlen) { | ||
619 | s->offset=0; | ||
620 | if (jump_scroll!=2) { | ||
621 | s->jump_scroll=0; | ||
622 | s->direction=1; | ||
623 | } | ||
624 | } | ||
625 | } else { | ||
626 | if ( s->offset < s->textlen-1 ) { | ||
627 | s->offset+=s->direction; | ||
628 | if (s->offset==0) { | ||
629 | s->direction=+1; | ||
630 | s->scroll_start_tick = current_tick + | ||
631 | scroll_delay; | ||
632 | } else { | ||
633 | if (s->offset == s->turn_offset) { | ||
634 | s->direction=-1; | ||
635 | s->scroll_start_tick = current_tick + | ||
636 | scroll_delay; | ||
637 | } | ||
638 | } | ||
639 | } | ||
640 | else { | ||
641 | s->offset = 0; | ||
607 | } | 642 | } |
608 | } | ||
609 | else { | ||
610 | s->offset = 0; | ||
611 | } | 643 | } |
612 | 644 | ||
613 | i=0; | 645 | i=0; |
@@ -618,10 +650,17 @@ static void scroll_thread(void) | |||
618 | break; | 650 | break; |
619 | } | 651 | } |
620 | o=0; | 652 | o=0; |
621 | while (i<11) { | 653 | if (s->turn_offset == -1 && !s->jump_scroll) { |
622 | buffer[i++]=s->text[o++]; | 654 | while (i<11) { |
655 | buffer[i++]=s->text[o++]; | ||
656 | } | ||
657 | } else { | ||
658 | while (i<11) { | ||
659 | buffer[i++]=' '; | ||
660 | } | ||
623 | } | 661 | } |
624 | buffer[11]=0; | 662 | buffer[11]=0; |
663 | |||
625 | lcd_puts_cont_scroll(s->startx, s->starty, buffer); | 664 | lcd_puts_cont_scroll(s->startx, s->starty, buffer); |
626 | } | 665 | } |
627 | } | 666 | } |