diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2007-07-28 08:12:05 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2007-07-28 08:12:05 +0000 |
commit | 58fc279d2674b5d56fed6772f82cdf1e431088f1 (patch) | |
tree | 07a174bba7430b0ebc3c0f84d39ecb209eec1fc5 /firmware/drivers/lcd-1bit-vert.c | |
parent | 885cdfdeb98d54b2597e65f1b9ae9ab98da8286f (diff) | |
download | rockbox-58fc279d2674b5d56fed6772f82cdf1e431088f1.tar.gz rockbox-58fc279d2674b5d56fed6772f82cdf1e431088f1.zip |
Scroll on main and remote with a single thread. Change the way system messages are defined before running out is an issue (which requires a full update of rockbox on the player).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14035 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/lcd-1bit-vert.c')
-rw-r--r-- | firmware/drivers/lcd-1bit-vert.c | 177 |
1 files changed, 56 insertions, 121 deletions
diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index b54238d085..ac50eff95c 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c | |||
@@ -29,10 +29,7 @@ | |||
29 | #include "font.h" | 29 | #include "font.h" |
30 | #include "rbunicode.h" | 30 | #include "rbunicode.h" |
31 | #include "bidi.h" | 31 | #include "bidi.h" |
32 | 32 | #include "scroll_engine.h" | |
33 | /*** definitions ***/ | ||
34 | |||
35 | #define SCROLLABLE_LINES ((LCD_HEIGHT+4)/5 < 32 ? (LCD_HEIGHT+4)/5 : 32) | ||
36 | 33 | ||
37 | /*** globals ***/ | 34 | /*** globals ***/ |
38 | 35 | ||
@@ -43,32 +40,13 @@ static int xmargin = 0; | |||
43 | static int ymargin = 0; | 40 | static int ymargin = 0; |
44 | static int curfont = FONT_SYSFIXED; | 41 | static int curfont = FONT_SYSFIXED; |
45 | 42 | ||
46 | /* scrolling */ | ||
47 | static volatile int scrolling_lines=0; /* Bitpattern of which lines are scrolling */ | ||
48 | static void scroll_thread(void); | ||
49 | static char scroll_stack[DEFAULT_STACK_SIZE]; | ||
50 | static const char scroll_name[] = "scroll"; | ||
51 | static int scroll_ticks = 12; /* # of ticks between updates*/ | ||
52 | static int scroll_delay = HZ/2; /* ticks delay before start */ | ||
53 | static int scroll_step = 6; /* pixels per scroll step */ | ||
54 | static int bidir_limit = 50; /* percent */ | ||
55 | static struct scrollinfo scroll[SCROLLABLE_LINES]; | ||
56 | |||
57 | static const char scroll_tick_table[16] = { | ||
58 | /* Hz values: | ||
59 | 1, 1.25, 1.55, 2, 2.5, 3.12, 4, 5, 6.25, 8.33, 10, 12.5, 16.7, 20, 25, 33 */ | ||
60 | 100, 80, 64, 50, 40, 32, 25, 20, 16, 12, 10, 8, 6, 5, 4, 3 | ||
61 | }; | ||
62 | |||
63 | /* LCD init */ | 43 | /* LCD init */ |
64 | void lcd_init(void) | 44 | void lcd_init(void) |
65 | { | 45 | { |
66 | lcd_clear_display(); | 46 | lcd_clear_display(); |
67 | /* Call device specific init */ | 47 | /* Call device specific init */ |
68 | lcd_init_device(); | 48 | lcd_init_device(); |
69 | create_thread(scroll_thread, scroll_stack, | 49 | scroll_init(); |
70 | sizeof(scroll_stack), scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE) | ||
71 | IF_COP(, CPU, false)); | ||
72 | } | 50 | } |
73 | 51 | ||
74 | /*** parameter handling ***/ | 52 | /*** parameter handling ***/ |
@@ -104,6 +82,11 @@ void lcd_setfont(int newfont) | |||
104 | curfont = newfont; | 82 | curfont = newfont; |
105 | } | 83 | } |
106 | 84 | ||
85 | int lcd_getfont(void) | ||
86 | { | ||
87 | return curfont; | ||
88 | } | ||
89 | |||
107 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) | 90 | int lcd_getstringsize(const unsigned char *str, int *w, int *h) |
108 | { | 91 | { |
109 | return font_getstringsize(str, w, h, curfont); | 92 | return font_getstringsize(str, w, h, curfont); |
@@ -212,7 +195,7 @@ void lcd_clear_display(void) | |||
212 | unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0; | 195 | unsigned bits = (drawmode & DRMODE_INVERSEVID) ? 0xFFu : 0; |
213 | 196 | ||
214 | memset(lcd_framebuffer, bits, sizeof lcd_framebuffer); | 197 | memset(lcd_framebuffer, bits, sizeof lcd_framebuffer); |
215 | scrolling_lines = 0; | 198 | lcd_scroll_info.lines = 0; |
216 | } | 199 | } |
217 | 200 | ||
218 | /* Set a single pixel */ | 201 | /* Set a single pixel */ |
@@ -664,7 +647,7 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, | |||
664 | int lastmode = drawmode; | 647 | int lastmode = drawmode; |
665 | 648 | ||
666 | /* make sure scrolling is turned off on the line we are updating */ | 649 | /* make sure scrolling is turned off on the line we are updating */ |
667 | scrolling_lines &= ~(1 << y); | 650 | lcd_scroll_info.lines &= ~(1 << y); |
668 | 651 | ||
669 | if(!str || !str[0]) | 652 | if(!str || !str[0]) |
670 | return; | 653 | return; |
@@ -682,46 +665,6 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, | |||
682 | } | 665 | } |
683 | 666 | ||
684 | /*** scrolling ***/ | 667 | /*** scrolling ***/ |
685 | |||
686 | /* Reverse the invert setting of the scrolling line (if any) at given char | ||
687 | position. Setting will go into affect next time line scrolls. */ | ||
688 | void lcd_invertscroll(int x, int y) | ||
689 | { | ||
690 | struct scrollinfo* s; | ||
691 | |||
692 | (void)x; | ||
693 | |||
694 | if(y>=SCROLLABLE_LINES) return; | ||
695 | |||
696 | s = &scroll[y]; | ||
697 | s->invert = !s->invert; | ||
698 | } | ||
699 | |||
700 | void lcd_stop_scroll(void) | ||
701 | { | ||
702 | scrolling_lines=0; | ||
703 | } | ||
704 | |||
705 | void lcd_scroll_speed(int speed) | ||
706 | { | ||
707 | scroll_ticks = scroll_tick_table[speed]; | ||
708 | } | ||
709 | |||
710 | void lcd_scroll_step(int step) | ||
711 | { | ||
712 | scroll_step = step; | ||
713 | } | ||
714 | |||
715 | void lcd_scroll_delay(int ms) | ||
716 | { | ||
717 | scroll_delay = ms / (HZ / 10); | ||
718 | } | ||
719 | |||
720 | void lcd_bidir_scroll(int percent) | ||
721 | { | ||
722 | bidir_limit = percent; | ||
723 | } | ||
724 | |||
725 | void lcd_puts_scroll(int x, int y, const unsigned char *string) | 668 | void lcd_puts_scroll(int x, int y, const unsigned char *string) |
726 | { | 669 | { |
727 | lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT); | 670 | lcd_puts_scroll_style(x, y, string, STYLE_DEFAULT); |
@@ -744,11 +687,11 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, | |||
744 | struct scrollinfo* s; | 687 | struct scrollinfo* s; |
745 | int w, h; | 688 | int w, h; |
746 | 689 | ||
747 | if(y>=SCROLLABLE_LINES) return; | 690 | if(y>=LCD_SCROLLABLE_LINES) return; |
748 | 691 | ||
749 | s = &scroll[y]; | 692 | s = &lcd_scroll_info.scroll[y]; |
750 | 693 | ||
751 | s->start_tick = current_tick + scroll_delay; | 694 | s->start_tick = current_tick + lcd_scroll_info.delay; |
752 | s->invert = false; | 695 | s->invert = false; |
753 | if (style & STYLE_INVERT) { | 696 | if (style & STYLE_INVERT) { |
754 | s->invert = true; | 697 | s->invert = true; |
@@ -771,9 +714,9 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, | |||
771 | 714 | ||
772 | /* scroll bidirectional or forward only depending on the string | 715 | /* scroll bidirectional or forward only depending on the string |
773 | width */ | 716 | width */ |
774 | if ( bidir_limit ) { | 717 | if ( lcd_scroll_info.bidir_limit ) { |
775 | s->bidir = s->width < (LCD_WIDTH - xmargin) * | 718 | s->bidir = s->width < (LCD_WIDTH - xmargin) * |
776 | (100 + bidir_limit) / 100; | 719 | (100 + lcd_scroll_info.bidir_limit) / 100; |
777 | } | 720 | } |
778 | else | 721 | else |
779 | s->bidir = false; | 722 | s->bidir = false; |
@@ -791,14 +734,14 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, | |||
791 | s->offset = offset; | 734 | s->offset = offset; |
792 | s->startx = xmargin + x * s->width / s->len;; | 735 | s->startx = xmargin + x * s->width / s->len;; |
793 | s->backward = false; | 736 | s->backward = false; |
794 | scrolling_lines |= (1<<y); | 737 | lcd_scroll_info.lines |= (1<<y); |
795 | } | 738 | } |
796 | else | 739 | else |
797 | /* force a bit switch-off since it doesn't scroll */ | 740 | /* force a bit switch-off since it doesn't scroll */ |
798 | scrolling_lines &= ~(1<<y); | 741 | lcd_scroll_info.lines &= ~(1<<y); |
799 | } | 742 | } |
800 | 743 | ||
801 | static void scroll_thread(void) | 744 | void lcd_scroll_fn(void) |
802 | { | 745 | { |
803 | struct font* pf; | 746 | struct font* pf; |
804 | struct scrollinfo* s; | 747 | struct scrollinfo* s; |
@@ -806,59 +749,51 @@ static void scroll_thread(void) | |||
806 | int xpos, ypos; | 749 | int xpos, ypos; |
807 | int lastmode; | 750 | int lastmode; |
808 | 751 | ||
809 | /* initialize scroll struct array */ | 752 | for ( index = 0; index < LCD_SCROLLABLE_LINES; index++ ) { |
810 | scrolling_lines = 0; | 753 | /* really scroll? */ |
811 | 754 | if ((lcd_scroll_info.lines & (1 << index)) == 0) | |
812 | while ( 1 ) { | 755 | continue; |
813 | for ( index = 0; index < SCROLLABLE_LINES; index++ ) { | ||
814 | /* really scroll? */ | ||
815 | if ( !(scrolling_lines&(1<<index)) ) | ||
816 | continue; | ||
817 | 756 | ||
818 | s = &scroll[index]; | 757 | s = &lcd_scroll_info.scroll[index]; |
819 | 758 | ||
820 | /* check pause */ | 759 | /* check pause */ |
821 | if (TIME_BEFORE(current_tick, s->start_tick)) | 760 | if (TIME_BEFORE(current_tick, s->start_tick)) |
822 | continue; | 761 | continue; |
823 | 762 | ||
824 | if (s->backward) | 763 | if (s->backward) |
825 | s->offset -= scroll_step; | 764 | s->offset -= lcd_scroll_info.step; |
826 | else | 765 | else |
827 | s->offset += scroll_step; | 766 | s->offset += lcd_scroll_info.step; |
828 | 767 | ||
829 | pf = font_get(curfont); | 768 | pf = font_get(curfont); |
830 | xpos = s->startx; | 769 | xpos = s->startx; |
831 | ypos = ymargin + index * pf->height; | 770 | ypos = ymargin + index * pf->height; |
832 | 771 | ||
833 | if (s->bidir) { /* scroll bidirectional */ | 772 | if (s->bidir) { /* scroll bidirectional */ |
834 | if (s->offset <= 0) { | 773 | if (s->offset <= 0) { |
835 | /* at beginning of line */ | 774 | /* at beginning of line */ |
836 | s->offset = 0; | 775 | s->offset = 0; |
837 | s->backward = false; | 776 | s->backward = false; |
838 | s->start_tick = current_tick + scroll_delay * 2; | 777 | s->start_tick = current_tick + lcd_scroll_info.delay * 2; |
839 | } | ||
840 | if (s->offset >= s->width - (LCD_WIDTH - xpos)) { | ||
841 | /* at end of line */ | ||
842 | s->offset = s->width - (LCD_WIDTH - xpos); | ||
843 | s->backward = true; | ||
844 | s->start_tick = current_tick + scroll_delay * 2; | ||
845 | } | ||
846 | } | 778 | } |
847 | else { | 779 | if (s->offset >= s->width - (LCD_WIDTH - xpos)) { |
848 | /* scroll forward the whole time */ | 780 | /* at end of line */ |
849 | if (s->offset >= s->width) | 781 | s->offset = s->width - (LCD_WIDTH - xpos); |
850 | s->offset %= s->width; | 782 | s->backward = true; |
783 | s->start_tick = current_tick + lcd_scroll_info.delay * 2; | ||
851 | } | 784 | } |
852 | 785 | } | |
853 | lastmode = drawmode; | 786 | else { |
854 | drawmode = s->invert ? | 787 | /* scroll forward the whole time */ |
855 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | 788 | if (s->offset >= s->width) |
856 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); | 789 | s->offset %= s->width; |
857 | drawmode = lastmode; | ||
858 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | ||
859 | } | 790 | } |
860 | 791 | ||
861 | sleep(scroll_ticks); | 792 | lastmode = drawmode; |
793 | drawmode = s->invert ? | ||
794 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
795 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); | ||
796 | drawmode = lastmode; | ||
797 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | ||
862 | } | 798 | } |
863 | } | 799 | } |
864 | |||