summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-player.c33
-rw-r--r--firmware/export/lcd.h4
2 files changed, 27 insertions, 10 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c
index 2496fb6f66..6e62358da7 100644
--- a/firmware/drivers/lcd-player.c
+++ b/firmware/drivers/lcd-player.c
@@ -71,6 +71,7 @@ struct scrollinfo {
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 int jump_scroll;
74 int jump_scroll_steps;
74}; 75};
75 76
76#define MAX_CURSOR_CHARS 8 77#define MAX_CURSOR_CHARS 8
@@ -89,10 +90,11 @@ static char scroll_stack[DEFAULT_STACK_SIZE];
89static char scroll_name[] = "scroll"; 90static char scroll_name[] = "scroll";
90static char scroll_speed = 8; /* updates per second */ 91static char scroll_speed = 8; /* updates per second */
91static int scroll_delay = HZ/2; /* delay before starting scroll */ 92static int scroll_delay = HZ/2; /* delay before starting scroll */
93static int jump_scroll_delay = HZ/4; /* delay between jump scroll jumps */
92static char scroll_spacing = 3; /* spaces between end and start of text */ 94static char scroll_spacing = 3; /* spaces between end and start of text */
93static bool allow_bidirectional_scrolling = true; 95static bool allow_bidirectional_scrolling = true;
94static int bidir_limit = 50; /* percent */ 96static int bidir_limit = 50; /* percent */
95static int jump_scroll = 0; /* 0=off, 1=once, 2=always */ 97static int jump_scroll = 0; /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
96 98
97static struct scrollinfo scroll[SCROLLABLE_LINES]; 99static struct scrollinfo scroll[SCROLLABLE_LINES];
98 100
@@ -500,7 +502,7 @@ void lcd_init (void)
500 sizeof(scroll_stack), scroll_name); 502 sizeof(scroll_stack), scroll_name);
501} 503}
502 504
503void lcd_jump_scroll (int mode) /* 0=off, 1=once, 2=always */ 505void lcd_jump_scroll (int mode) /* 0=off, 1=once, ..., JUMP_SCROLL_ALWAYS */
504{ 506{
505 jump_scroll=mode; 507 jump_scroll=mode;
506} 508}
@@ -530,8 +532,11 @@ void lcd_puts_scroll(int x, int y, unsigned char* string )
530 s->starty=y; 532 s->starty=y;
531 s->direction=+1; 533 s->direction=+1;
532 s->jump_scroll=0; 534 s->jump_scroll=0;
533 if (jump_scroll && scroll_delay/2<(HZ/scroll_speed)*(s->textlen-11+x)) 535 s->jump_scroll_steps=0;
534 s->jump_scroll=11-x; 536 if (jump_scroll && jump_scroll_delay<(HZ/scroll_speed)*(s->textlen-11+x)) {
537 s->jump_scroll_steps=11-x;
538 s->jump_scroll=jump_scroll;
539 }
535 strncpy(s->text,string,sizeof s->text); 540 strncpy(s->text,string,sizeof s->text);
536 s->turn_offset=-1; 541 s->turn_offset=-1;
537 if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) { 542 if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) {
@@ -584,6 +589,13 @@ void lcd_scroll_delay(int ms)
584 scroll_delay = ms / (HZ / 10); 589 scroll_delay = ms / (HZ / 10);
585 DEBUGF("scroll_delay=%d (ms=%d, HZ=%d)\n", scroll_delay, ms, HZ); 590 DEBUGF("scroll_delay=%d (ms=%d, HZ=%d)\n", scroll_delay, ms, HZ);
586} 591}
592
593void lcd_jump_scroll_delay(int ms)
594{
595 jump_scroll_delay = ms / (HZ / 10);
596 DEBUGF("jump_scroll_delay=%d (ms=%d, HZ=%d)\n", jump_scroll_delay, ms, HZ);
597}
598
587static void scroll_thread(void) 599static void scroll_thread(void)
588{ 600{
589 struct scrollinfo* s; 601 struct scrollinfo* s;
@@ -605,11 +617,12 @@ static void scroll_thread(void)
605 if ( s->mode == SCROLL_MODE_RUN ) { 617 if ( s->mode == SCROLL_MODE_RUN ) {
606 if ( TIME_AFTER(current_tick, s->scroll_start_tick) ) { 618 if ( TIME_AFTER(current_tick, s->scroll_start_tick) ) {
607 char buffer[12]; 619 char buffer[12];
620 int jumping_scroll=s->jump_scroll;
608 update = true; 621 update = true;
609 if (s->jump_scroll) { 622 if (s->jump_scroll) {
610 s->offset+=s->jump_scroll; 623 s->offset+=s->jump_scroll_steps;
611 s->scroll_start_tick = current_tick + 624 s->scroll_start_tick = current_tick +
612 scroll_delay/2; 625 jump_scroll_delay;
613 /* Eat space */ 626 /* Eat space */
614 while (s->offset < s->textlen && 627 while (s->offset < s->textlen &&
615 s->text[s->offset] == ' ') { 628 s->text[s->offset] == ' ') {
@@ -617,8 +630,10 @@ static void scroll_thread(void)
617 } 630 }
618 if (s->offset >= s->textlen) { 631 if (s->offset >= s->textlen) {
619 s->offset=0; 632 s->offset=0;
620 if (jump_scroll!=2) { 633 s->scroll_start_tick = current_tick +
621 s->jump_scroll=0; 634 scroll_delay;
635 if (s->jump_scroll != JUMP_SCROLL_ALWAYS) {
636 s->jump_scroll--;
622 s->direction=1; 637 s->direction=1;
623 } 638 }
624 } 639 }
@@ -650,7 +665,7 @@ static void scroll_thread(void)
650 break; 665 break;
651 } 666 }
652 o=0; 667 o=0;
653 if (s->turn_offset == -1 && !s->jump_scroll) { 668 if (s->turn_offset == -1 && !jumping_scroll) {
654 while (i<11) { 669 while (i<11) {
655 buffer[i++]=s->text[o++]; 670 buffer[i++]=s->text[o++];
656 } 671 }
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index ff955e170b..0818f9d92e 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -87,7 +87,9 @@ enum
87extern void lcd_define_hw_pattern (int which,char *pattern,int length); 87extern void lcd_define_hw_pattern (int which,char *pattern,int length);
88extern void lcd_define_pattern (int which,char *pattern); 88extern void lcd_define_pattern (int which,char *pattern);
89extern void lcd_double_height (bool on); 89extern void lcd_double_height (bool on);
90extern void lcd_jump_scroll (int mode); /* 0=off, 1=once, 2=always */ 90#define JUMP_SCROLL_ALWAYS 5
91extern void lcd_jump_scroll (int mode); /* 0=off, 1=once, ..., ALWAYS */
92extern void lcd_jump_scroll_delay( int ms );
91unsigned char lcd_get_locked_pattern(void); 93unsigned char lcd_get_locked_pattern(void);
92void lcd_unlock_pattern(unsigned char pat); 94void lcd_unlock_pattern(unsigned char pat);
93void lcd_allow_bidirectional_scrolling(bool on); 95void lcd_allow_bidirectional_scrolling(bool on);