diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-player.c | 59 | ||||
-rw-r--r-- | firmware/drivers/lcd-recorder.c | 127 | ||||
-rw-r--r-- | firmware/drivers/lcd.h | 6 |
3 files changed, 25 insertions, 167 deletions
diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index 189cb0e899..1333a152f4 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c | |||
@@ -506,65 +506,6 @@ void lcd_stop_scroll(void) | |||
506 | lcd_update(); | 506 | lcd_update(); |
507 | } | 507 | } |
508 | 508 | ||
509 | void lcd_stop_scroll_line(int line) | ||
510 | { | ||
511 | struct scrollinfo* s; | ||
512 | |||
513 | s = &scroll[line]; | ||
514 | if ( s->mode == SCROLL_MODE_RUN || | ||
515 | s->mode == SCROLL_MODE_PAUSE ) { | ||
516 | /* restore scrolled row */ | ||
517 | lcd_puts(s->startx, s->starty, s->text); | ||
518 | } | ||
519 | |||
520 | lcd_update(); | ||
521 | } | ||
522 | |||
523 | void lcd_scroll_pause(void) | ||
524 | { | ||
525 | struct scrollinfo* s; | ||
526 | int index; | ||
527 | |||
528 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
529 | s = &scroll[index]; | ||
530 | if ( s->mode == SCROLL_MODE_RUN ) { | ||
531 | s->mode = SCROLL_MODE_PAUSE; | ||
532 | } | ||
533 | } | ||
534 | } | ||
535 | |||
536 | void lcd_scroll_pause_line(int line) | ||
537 | { | ||
538 | struct scrollinfo* s; | ||
539 | |||
540 | s = &scroll[line]; | ||
541 | if ( s->mode == SCROLL_MODE_RUN ) { | ||
542 | s->mode = SCROLL_MODE_PAUSE; | ||
543 | } | ||
544 | } | ||
545 | |||
546 | void lcd_scroll_resume(void) | ||
547 | { | ||
548 | struct scrollinfo* s; | ||
549 | int index; | ||
550 | |||
551 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
552 | s = &scroll[index]; | ||
553 | if ( s->mode == SCROLL_MODE_PAUSE ) { | ||
554 | s->mode = SCROLL_MODE_RUN; | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | |||
559 | void lcd_scroll_resume_line(int line) | ||
560 | { | ||
561 | struct scrollinfo* s; | ||
562 | |||
563 | s = &scroll[line]; | ||
564 | if (s->mode == SCROLL_MODE_PAUSE ) { | ||
565 | s->mode = SCROLL_MODE_RUN; | ||
566 | } | ||
567 | } | ||
568 | 509 | ||
569 | void lcd_allow_bidirectional_scrolling(bool on) | 510 | void lcd_allow_bidirectional_scrolling(bool on) |
570 | { | 511 | { |
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 08f14ea764..84fb486b8e 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c | |||
@@ -72,12 +72,7 @@ | |||
72 | 72 | ||
73 | #define SCROLLABLE_LINES 10 | 73 | #define SCROLLABLE_LINES 10 |
74 | 74 | ||
75 | #define SCROLL_MODE_OFF 0 | ||
76 | #define SCROLL_MODE_PAUSE 1 | ||
77 | #define SCROLL_MODE_RUN 2 | ||
78 | |||
79 | struct scrollinfo { | 75 | struct scrollinfo { |
80 | int mode; | ||
81 | char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2]; | 76 | char line[MAX_PATH + LCD_WIDTH/2 + SCROLL_SPACING + 2]; |
82 | int len; /* length of line in chars */ | 77 | int len; /* length of line in chars */ |
83 | int width; /* length of line in pixels */ | 78 | int width; /* length of line in pixels */ |
@@ -89,6 +84,8 @@ struct scrollinfo { | |||
89 | long start_tick; | 84 | long start_tick; |
90 | }; | 85 | }; |
91 | 86 | ||
87 | static int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ | ||
88 | |||
92 | static void scroll_thread(void); | 89 | static void scroll_thread(void); |
93 | static char scroll_stack[DEFAULT_STACK_SIZE]; | 90 | static char scroll_stack[DEFAULT_STACK_SIZE]; |
94 | static char scroll_name[] = "scroll"; | 91 | static char scroll_name[] = "scroll"; |
@@ -215,7 +212,9 @@ void lcd_roll(int lines) | |||
215 | 212 | ||
216 | void lcd_clear_display (void) | 213 | void lcd_clear_display (void) |
217 | { | 214 | { |
215 | DEBUGF("lcd_clear_display()\n"); | ||
218 | memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); | 216 | memset (lcd_framebuffer, 0, sizeof lcd_framebuffer); |
217 | scrolling_lines = 0; | ||
219 | } | 218 | } |
220 | 219 | ||
221 | void lcd_setmargins(int x, int y) | 220 | void lcd_setmargins(int x, int y) |
@@ -245,6 +244,7 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h) | |||
245 | int ch; | 244 | int ch; |
246 | int width = 0; | 245 | int width = 0; |
247 | 246 | ||
247 | /* DEBUGF("lcd_getstringsize('%s')\n", str); */ | ||
248 | while((ch = *str++)) { | 248 | while((ch = *str++)) { |
249 | /* check input range*/ | 249 | /* check input range*/ |
250 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) | 250 | if (ch < pf->firstchar || ch >= pf->firstchar+pf->size) |
@@ -258,7 +258,6 @@ int lcd_getstringsize(unsigned char *str, int *w, int *h) | |||
258 | *w = width; | 258 | *w = width; |
259 | if ( h ) | 259 | if ( h ) |
260 | *h = pf->height; | 260 | *h = pf->height; |
261 | |||
262 | return width; | 261 | return width; |
263 | } | 262 | } |
264 | 263 | ||
@@ -670,14 +669,21 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) | |||
670 | struct scrollinfo* s; | 669 | struct scrollinfo* s; |
671 | int w, h; | 670 | int w, h; |
672 | int index; | 671 | int index; |
672 | int free_index=0; | ||
673 | 673 | ||
674 | /* search for the next free entry */ | 674 | DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string); |
675 | for (index = 0; index < SCROLLABLE_LINES; index++) { | 675 | for (index = 0; index < SCROLLABLE_LINES; index++) { |
676 | s = &scroll[index]; | 676 | s = &scroll[index]; |
677 | if (s->mode == SCROLL_MODE_OFF) { | 677 | if (scrolling_lines&(1<<index)) { |
678 | break; | 678 | if (s->starty == y) { |
679 | } | 679 | free_index=index; |
680 | break; | ||
681 | } | ||
682 | } else | ||
683 | free_index=index; | ||
680 | } | 684 | } |
685 | index=free_index; | ||
686 | |||
681 | s->start_tick = current_tick + scroll_delay; | 687 | s->start_tick = current_tick + scroll_delay; |
682 | 688 | ||
683 | lcd_puts(x,y,string); | 689 | lcd_puts(x,y,string); |
@@ -687,6 +693,7 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) | |||
687 | /* prepare scroll line */ | 693 | /* prepare scroll line */ |
688 | char *end; | 694 | char *end; |
689 | 695 | ||
696 | scrolling_lines|=(1<<index); | ||
690 | memset(s->line, 0, sizeof s->line); | 697 | memset(s->line, 0, sizeof s->line); |
691 | strcpy(s->line, string); | 698 | strcpy(s->line, string); |
692 | 699 | ||
@@ -710,7 +717,6 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) | |||
710 | for (end = s->line; *end; end++); | 717 | for (end = s->line; *end; end++); |
711 | strncpy(end, string, LCD_WIDTH/2); | 718 | strncpy(end, string, LCD_WIDTH/2); |
712 | 719 | ||
713 | s->mode = SCROLL_MODE_RUN; | ||
714 | s->len = strlen(string); | 720 | s->len = strlen(string); |
715 | s->offset = 0; | 721 | s->offset = 0; |
716 | s->startx = x; | 722 | s->startx = x; |
@@ -721,15 +727,15 @@ void lcd_puts_scroll(int x, int y, unsigned char* string) | |||
721 | 727 | ||
722 | void lcd_stop_scroll(void) | 728 | void lcd_stop_scroll(void) |
723 | { | 729 | { |
730 | DEBUGF("lcd_stop_scroll()\n"); | ||
731 | #if 0 | ||
724 | struct scrollinfo* s; | 732 | struct scrollinfo* s; |
725 | int w,h; | 733 | int w,h; |
726 | int index; | 734 | int index; |
727 | int update=0; | 735 | int update=0; |
728 | |||
729 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 736 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { |
730 | s = &scroll[index]; | 737 | s = &scroll[index]; |
731 | if ( s->mode == SCROLL_MODE_RUN || | 738 | if ( scrolling_lines&(1<<index) ) { |
732 | s->mode == SCROLL_MODE_PAUSE ) { | ||
733 | lcd_getstringsize(s->line, &w, &h); | 739 | lcd_getstringsize(s->line, &w, &h); |
734 | lcd_clearrect(xmargin + s->startx * w / s->len, | 740 | lcd_clearrect(xmargin + s->startx * w / s->len, |
735 | ymargin + s->starty * h, | 741 | ymargin + s->starty * h, |
@@ -738,96 +744,13 @@ void lcd_stop_scroll(void) | |||
738 | 744 | ||
739 | /* restore scrolled row */ | 745 | /* restore scrolled row */ |
740 | lcd_puts(s->startx, s->starty, s->line); | 746 | lcd_puts(s->startx, s->starty, s->line); |
741 | s->mode = SCROLL_MODE_OFF; | ||
742 | update++; | 747 | update++; |
743 | } | 748 | } |
744 | } | 749 | } |
745 | |||
746 | if(update) | 750 | if(update) |
747 | lcd_update(); /* update only if needed */ | 751 | lcd_update(); /* update only if needed */ |
748 | } | 752 | #endif |
749 | 753 | scrolling_lines=0; | |
750 | void lcd_stop_scroll_line(int line) | ||
751 | { | ||
752 | struct scrollinfo* s; | ||
753 | int w,h; | ||
754 | int index; | ||
755 | int update=0; | ||
756 | |||
757 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
758 | s = &scroll[index]; | ||
759 | if ( s->startx == line && | ||
760 | ( s->mode == SCROLL_MODE_RUN || | ||
761 | s->mode == SCROLL_MODE_PAUSE )) { | ||
762 | lcd_getstringsize(s->line, &w, &h); | ||
763 | lcd_clearrect(xmargin + s->startx * w / s->len, | ||
764 | ymargin + s->starty * h, | ||
765 | LCD_WIDTH - xmargin, | ||
766 | h); | ||
767 | |||
768 | /* restore scrolled row */ | ||
769 | lcd_puts(s->startx, s->starty, s->line); | ||
770 | s->mode = SCROLL_MODE_OFF; | ||
771 | update++; | ||
772 | } | ||
773 | } | ||
774 | if(update) | ||
775 | /* only updated if need be */ | ||
776 | lcd_update(); | ||
777 | } | ||
778 | |||
779 | void lcd_scroll_pause(void) | ||
780 | { | ||
781 | struct scrollinfo* s; | ||
782 | int index; | ||
783 | |||
784 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
785 | s = &scroll[index]; | ||
786 | if ( s->mode == SCROLL_MODE_RUN ) { | ||
787 | s->mode = SCROLL_MODE_PAUSE; | ||
788 | } | ||
789 | } | ||
790 | } | ||
791 | |||
792 | void lcd_scroll_pause_line(int line) | ||
793 | { | ||
794 | struct scrollinfo* s; | ||
795 | int index; | ||
796 | |||
797 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
798 | s = &scroll[index]; | ||
799 | if ( s->startx == line && | ||
800 | s->mode == SCROLL_MODE_RUN ) { | ||
801 | s->mode = SCROLL_MODE_PAUSE; | ||
802 | } | ||
803 | } | ||
804 | } | ||
805 | |||
806 | void lcd_scroll_resume(void) | ||
807 | { | ||
808 | struct scrollinfo* s; | ||
809 | int index; | ||
810 | |||
811 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
812 | s = &scroll[index]; | ||
813 | if ( s->mode == SCROLL_MODE_PAUSE ) { | ||
814 | s->mode = SCROLL_MODE_RUN; | ||
815 | } | ||
816 | } | ||
817 | } | ||
818 | |||
819 | void lcd_scroll_resume_line(int line) | ||
820 | { | ||
821 | struct scrollinfo* s; | ||
822 | int index; | ||
823 | |||
824 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
825 | s = &scroll[index]; | ||
826 | if ( s->startx == line && | ||
827 | s->mode == SCROLL_MODE_PAUSE ) { | ||
828 | s->mode = SCROLL_MODE_RUN; | ||
829 | } | ||
830 | } | ||
831 | } | 754 | } |
832 | 755 | ||
833 | void lcd_scroll_speed(int speed) | 756 | void lcd_scroll_speed(int speed) |
@@ -857,16 +780,14 @@ static void scroll_thread(void) | |||
857 | int xpos, ypos; | 780 | int xpos, ypos; |
858 | 781 | ||
859 | /* initialize scroll struct array */ | 782 | /* initialize scroll struct array */ |
860 | for (index = 0; index < SCROLLABLE_LINES; index++) { | 783 | scrolling_lines = 0; |
861 | scroll[index].mode = SCROLL_MODE_OFF; | ||
862 | } | ||
863 | 784 | ||
864 | while ( 1 ) { | 785 | while ( 1 ) { |
865 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | 786 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { |
866 | s = &scroll[index]; | 787 | s = &scroll[index]; |
867 | 788 | ||
868 | /* really scroll? */ | 789 | /* really scroll? */ |
869 | if ( s->mode != SCROLL_MODE_RUN ) | 790 | if ( !(scrolling_lines&(1<<index)) ) |
870 | continue; | 791 | continue; |
871 | 792 | ||
872 | /* check pause */ | 793 | /* check pause */ |
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h index a4d8178b87..6fe07c1924 100644 --- a/firmware/drivers/lcd.h +++ b/firmware/drivers/lcd.h | |||
@@ -30,14 +30,10 @@ extern void lcd_clear_display(void); | |||
30 | extern void lcd_backlight(bool on); | 30 | extern void lcd_backlight(bool on); |
31 | extern void lcd_puts(int x, int y, unsigned char *string); | 31 | extern void lcd_puts(int x, int y, unsigned char *string); |
32 | extern void lcd_putc(int x, int y, unsigned short ch); | 32 | extern void lcd_putc(int x, int y, unsigned short ch); |
33 | extern void lcd_scroll_pause(void); | 33 | |
34 | extern void lcd_scroll_pause_line(int line); | ||
35 | extern void lcd_scroll_resume(void); | ||
36 | extern void lcd_scroll_resume_line(int line); | ||
37 | extern void lcd_puts_scroll(int x, int y, unsigned char* string ); | 34 | extern void lcd_puts_scroll(int x, int y, unsigned char* string ); |
38 | extern void lcd_icon(int icon, bool enable); | 35 | extern void lcd_icon(int icon, bool enable); |
39 | extern void lcd_stop_scroll(void); | 36 | extern void lcd_stop_scroll(void); |
40 | extern void lcd_stop_scroll_line(int line); | ||
41 | extern void lcd_scroll_speed( int speed ); | 37 | extern void lcd_scroll_speed( int speed ); |
42 | extern void lcd_scroll_delay( int ms ); | 38 | extern void lcd_scroll_delay( int ms ); |
43 | extern void lcd_set_contrast(int val); | 39 | extern void lcd_set_contrast(int val); |