diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/lcd-16bit.c | 98 | ||||
-rw-r--r-- | firmware/export/lcd.h | 8 | ||||
-rw-r--r-- | firmware/export/scroll_engine.h | 6 |
3 files changed, 106 insertions, 6 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index 96a9e1a4d7..44d468521d 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c | |||
@@ -51,9 +51,15 @@ static long lcd_backdrop_offset IDATA_ATTR = 0; | |||
51 | #if !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR) | 51 | #if !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR) |
52 | static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; | 52 | static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; |
53 | static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; | 53 | static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; |
54 | static unsigned lss_pattern IDATA_ATTR = LCD_DEFAULT_LS; | ||
55 | static unsigned lse_pattern IDATA_ATTR = LCD_DEFAULT_BG; | ||
56 | static unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG; | ||
54 | #else | 57 | #else |
55 | unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; | 58 | unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG; |
56 | unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; | 59 | unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG; |
60 | unsigned lss_pattern IDATA_ATTR = LCD_DEFAULT_LS; | ||
61 | unsigned lse_pattern IDATA_ATTR = LCD_DEFAULT_BG; | ||
62 | unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG; | ||
57 | #endif | 63 | #endif |
58 | 64 | ||
59 | static int drawmode = DRMODE_SOLID; | 65 | static int drawmode = DRMODE_SOLID; |
@@ -103,6 +109,21 @@ unsigned lcd_get_background(void) | |||
103 | return bg_pattern; | 109 | return bg_pattern; |
104 | } | 110 | } |
105 | 111 | ||
112 | void lcd_set_selector_start(unsigned color) | ||
113 | { | ||
114 | lss_pattern = color; | ||
115 | } | ||
116 | |||
117 | void lcd_set_selector_end(unsigned color) | ||
118 | { | ||
119 | lse_pattern = color; | ||
120 | } | ||
121 | |||
122 | void lcd_set_selector_text(unsigned color) | ||
123 | { | ||
124 | lst_pattern = color; | ||
125 | } | ||
126 | |||
106 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) | 127 | void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color) |
107 | { | 128 | { |
108 | lcd_set_drawmode(mode); | 129 | lcd_set_drawmode(mode); |
@@ -808,16 +829,48 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style, | |||
808 | ypos = ymargin + y*h; | 829 | ypos = ymargin + y*h; |
809 | drawmode = (style & STYLE_INVERT) ? | 830 | drawmode = (style & STYLE_INVERT) ? |
810 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | 831 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; |
811 | if (style & STYLE_COLORED) { | 832 | if (style & STYLE_GRADIENT || style & STYLE_COLORBAR) { |
833 | fg_pattern = lss_pattern; | ||
834 | } | ||
835 | else if (style & STYLE_COLORED) { | ||
812 | if (drawmode == DRMODE_SOLID) | 836 | if (drawmode == DRMODE_SOLID) |
813 | fg_pattern = style & STYLE_COLOR_MASK; | 837 | fg_pattern = style & STYLE_COLOR_MASK; |
814 | else | 838 | else |
815 | bg_pattern = style & STYLE_COLOR_MASK; | 839 | bg_pattern = style & STYLE_COLOR_MASK; |
816 | } | 840 | } |
817 | lcd_putsxyofs(xpos, ypos, offset, str); | ||
818 | drawmode ^= DRMODE_INVERSEVID; | 841 | drawmode ^= DRMODE_INVERSEVID; |
819 | xrect = xpos + MAX(w - offset, 0); | 842 | xrect = xpos + MAX(w - offset, 0); |
820 | lcd_fillrect(xrect, ypos, LCD_WIDTH - xrect, h); | 843 | |
844 | if (style & STYLE_GRADIENT) { | ||
845 | int h_r = RGB_UNPACK_RED(lss_pattern) << 16; | ||
846 | int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16; | ||
847 | int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16; | ||
848 | int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16)) / h; | ||
849 | int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16)) / h; | ||
850 | int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16)) / h; | ||
851 | int count; | ||
852 | |||
853 | drawmode = DRMODE_FG; | ||
854 | for(count = 0; count < h; count++) { | ||
855 | lcd_hline(xpos, LCD_WIDTH, ypos + count); | ||
856 | h_r -= rstep; | ||
857 | h_g -= gstep; | ||
858 | h_b -= bstep; | ||
859 | fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); | ||
860 | } | ||
861 | fg_pattern = lst_pattern; | ||
862 | } | ||
863 | else if (style & STYLE_COLORBAR) { | ||
864 | drawmode = DRMODE_FG; | ||
865 | lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, h); | ||
866 | fg_pattern = lst_pattern; | ||
867 | } | ||
868 | else { | ||
869 | lcd_fillrect(xrect, ypos, LCD_WIDTH - xrect, h); | ||
870 | drawmode = (style & STYLE_INVERT) ? | ||
871 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | ||
872 | } | ||
873 | lcd_putsxyofs(xpos, ypos, offset, str); | ||
821 | drawmode = lastmode; | 874 | drawmode = lastmode; |
822 | fg_pattern = oldfgcolor; | 875 | fg_pattern = oldfgcolor; |
823 | bg_pattern = oldbgcolor; | 876 | bg_pattern = oldbgcolor; |
@@ -852,7 +905,13 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string, | |||
852 | s->start_tick = current_tick + lcd_scroll_info.delay; | 905 | s->start_tick = current_tick + lcd_scroll_info.delay; |
853 | s->invert = false; | 906 | s->invert = false; |
854 | if (style & STYLE_INVERT) { | 907 | if (style & STYLE_INVERT) { |
855 | s->invert = true; | 908 | s->invert = 1; |
909 | } | ||
910 | else if (style & STYLE_COLORBAR) { | ||
911 | s->invert = 2; | ||
912 | } | ||
913 | else if (style & STYLE_GRADIENT) { | ||
914 | s->invert = 3; | ||
856 | } | 915 | } |
857 | lcd_puts_style_offset(x,y,string,style,offset); | 916 | lcd_puts_style_offset(x,y,string,style,offset); |
858 | 917 | ||
@@ -961,8 +1020,37 @@ void lcd_scroll_fn(void) | |||
961 | } | 1020 | } |
962 | 1021 | ||
963 | lastmode = drawmode; | 1022 | lastmode = drawmode; |
964 | drawmode = s->invert ? | 1023 | drawmode = s->invert == 1 ? |
965 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; | 1024 | (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID; |
1025 | if (s->invert == 2) { | ||
1026 | fg_pattern = lss_pattern; | ||
1027 | drawmode = DRMODE_FG; | ||
1028 | lcd_fillrect(0, ypos, LCD_WIDTH, pf->height); | ||
1029 | fg_pattern = lst_pattern; | ||
1030 | } | ||
1031 | else if (s->invert == 3) { | ||
1032 | int h_r = RGB_UNPACK_RED(lss_pattern) << 16; | ||
1033 | int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16; | ||
1034 | int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16; | ||
1035 | int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16)) | ||
1036 | / pf->height; | ||
1037 | int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16)) | ||
1038 | / pf->height; | ||
1039 | int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16)) | ||
1040 | / pf->height; | ||
1041 | unsigned int count; | ||
1042 | |||
1043 | fg_pattern = lss_pattern; | ||
1044 | drawmode = DRMODE_FG; | ||
1045 | for(count = 0; count < pf->height; count++) { | ||
1046 | lcd_hline(0, LCD_WIDTH , ypos + count); | ||
1047 | h_r -= rstep; | ||
1048 | h_g -= gstep; | ||
1049 | h_b -= bstep; | ||
1050 | fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16); | ||
1051 | } | ||
1052 | fg_pattern = lst_pattern; | ||
1053 | } | ||
966 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); | 1054 | lcd_putsxyofs(xpos, ypos, s->offset, s->line); |
967 | drawmode = lastmode; | 1055 | drawmode = lastmode; |
968 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); | 1056 | lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height); |
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index ac0aea8664..2ea9906a2a 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -27,6 +27,8 @@ | |||
27 | #define STYLE_DEFAULT 0x00000000 | 27 | #define STYLE_DEFAULT 0x00000000 |
28 | #define STYLE_INVERT 0x20000000 | 28 | #define STYLE_INVERT 0x20000000 |
29 | #define STYLE_COLORED 0x10000000 | 29 | #define STYLE_COLORED 0x10000000 |
30 | #define STYLE_COLORBAR 0x40000000 | ||
31 | #define STYLE_GRADIENT 0x80000000 | ||
30 | #define STYLE_COLOR_MASK 0x0000FFFF | 32 | #define STYLE_COLOR_MASK 0x0000FFFF |
31 | 33 | ||
32 | #ifdef SIMULATOR | 34 | #ifdef SIMULATOR |
@@ -233,6 +235,7 @@ static inline unsigned lcd_color_to_native(unsigned color) | |||
233 | #define LCD_WHITE LCD_RGBPACK(255, 255, 255) | 235 | #define LCD_WHITE LCD_RGBPACK(255, 255, 255) |
234 | #define LCD_DEFAULT_FG LCD_BLACK | 236 | #define LCD_DEFAULT_FG LCD_BLACK |
235 | #define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */ | 237 | #define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */ |
238 | #define LCD_DEFAULT_LS LCD_WHITE | ||
236 | 239 | ||
237 | #elif LCD_DEPTH > 1 /* greyscale */ | 240 | #elif LCD_DEPTH > 1 /* greyscale */ |
238 | 241 | ||
@@ -355,6 +358,11 @@ extern void lcd_set_foreground(unsigned foreground); | |||
355 | extern unsigned lcd_get_foreground(void); | 358 | extern unsigned lcd_get_foreground(void); |
356 | extern void lcd_set_background(unsigned background); | 359 | extern void lcd_set_background(unsigned background); |
357 | extern unsigned lcd_get_background(void); | 360 | extern unsigned lcd_get_background(void); |
361 | #ifdef HAVE_LCD_COLOR | ||
362 | extern void lcd_set_selector_start(unsigned selector); | ||
363 | extern void lcd_set_selector_end(unsigned selector); | ||
364 | extern void lcd_set_selector_text(unsigned selector_text); | ||
365 | #endif | ||
358 | extern void lcd_set_drawinfo(int mode, unsigned foreground, | 366 | extern void lcd_set_drawinfo(int mode, unsigned foreground, |
359 | unsigned background); | 367 | unsigned background); |
360 | void lcd_set_backdrop(fb_data* backdrop); | 368 | void lcd_set_backdrop(fb_data* backdrop); |
diff --git a/firmware/export/scroll_engine.h b/firmware/export/scroll_engine.h index aa11a9ba1f..f40a00f96c 100644 --- a/firmware/export/scroll_engine.h +++ b/firmware/export/scroll_engine.h | |||
@@ -43,8 +43,12 @@ struct scrollinfo | |||
43 | int startx; | 43 | int startx; |
44 | #ifdef HAVE_LCD_BITMAP | 44 | #ifdef HAVE_LCD_BITMAP |
45 | int width; /* length of line in pixels */ | 45 | int width; /* length of line in pixels */ |
46 | bool invert; /* invert the scrolled text */ | 46 | #ifdef HAVE_LCD_COLOR |
47 | int invert; /* invert the scrolled text */ | ||
48 | #else | ||
49 | bool invert; | ||
47 | #endif | 50 | #endif |
51 | #endif/* HAVE_LCD_BITMAP */ | ||
48 | bool backward; /* scroll presently forward or backward? */ | 52 | bool backward; /* scroll presently forward or backward? */ |
49 | bool bidir; | 53 | bool bidir; |
50 | long start_tick; | 54 | long start_tick; |