summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/lcd-16bit.c98
-rw-r--r--firmware/export/lcd.h8
-rw-r--r--firmware/export/scroll_engine.h6
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;
#if !defined(TOSHIBA_GIGABEAT_F) || defined(SIMULATOR)
static unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
static unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+static unsigned lss_pattern IDATA_ATTR = LCD_DEFAULT_LS;
+static unsigned lse_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+static unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG;
#else
unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+unsigned lss_pattern IDATA_ATTR = LCD_DEFAULT_LS;
+unsigned lse_pattern IDATA_ATTR = LCD_DEFAULT_BG;
+unsigned lst_pattern IDATA_ATTR = LCD_DEFAULT_FG;
#endif
static int drawmode = DRMODE_SOLID;
@@ -103,6 +109,21 @@ unsigned lcd_get_background(void)
return bg_pattern;
}
+void lcd_set_selector_start(unsigned color)
+{
+ lss_pattern = color;
+}
+
+void lcd_set_selector_end(unsigned color)
+{
+ lse_pattern = color;
+}
+
+void lcd_set_selector_text(unsigned color)
+{
+ lst_pattern = color;
+}
+
void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
{
lcd_set_drawmode(mode);
@@ -808,16 +829,48 @@ void lcd_puts_style_offset(int x, int y, const unsigned char *str, int style,
ypos = ymargin + y*h;
drawmode = (style & STYLE_INVERT) ?
(DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
- if (style & STYLE_COLORED) {
+ if (style & STYLE_GRADIENT || style & STYLE_COLORBAR) {
+ fg_pattern = lss_pattern;
+ }
+ else if (style & STYLE_COLORED) {
if (drawmode == DRMODE_SOLID)
fg_pattern = style & STYLE_COLOR_MASK;
else
bg_pattern = style & STYLE_COLOR_MASK;
}
- lcd_putsxyofs(xpos, ypos, offset, str);
drawmode ^= DRMODE_INVERSEVID;
xrect = xpos + MAX(w - offset, 0);
- lcd_fillrect(xrect, ypos, LCD_WIDTH - xrect, h);
+
+ if (style & STYLE_GRADIENT) {
+ int h_r = RGB_UNPACK_RED(lss_pattern) << 16;
+ int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16;
+ int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16;
+ int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16)) / h;
+ int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16)) / h;
+ int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16)) / h;
+ int count;
+
+ drawmode = DRMODE_FG;
+ for(count = 0; count < h; count++) {
+ lcd_hline(xpos, LCD_WIDTH, ypos + count);
+ h_r -= rstep;
+ h_g -= gstep;
+ h_b -= bstep;
+ fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
+ }
+ fg_pattern = lst_pattern;
+ }
+ else if (style & STYLE_COLORBAR) {
+ drawmode = DRMODE_FG;
+ lcd_fillrect(xpos, ypos, LCD_WIDTH - xpos, h);
+ fg_pattern = lst_pattern;
+ }
+ else {
+ lcd_fillrect(xrect, ypos, LCD_WIDTH - xrect, h);
+ drawmode = (style & STYLE_INVERT) ?
+ (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
+ }
+ lcd_putsxyofs(xpos, ypos, offset, str);
drawmode = lastmode;
fg_pattern = oldfgcolor;
bg_pattern = oldbgcolor;
@@ -852,7 +905,13 @@ void lcd_puts_scroll_style_offset(int x, int y, const unsigned char *string,
s->start_tick = current_tick + lcd_scroll_info.delay;
s->invert = false;
if (style & STYLE_INVERT) {
- s->invert = true;
+ s->invert = 1;
+ }
+ else if (style & STYLE_COLORBAR) {
+ s->invert = 2;
+ }
+ else if (style & STYLE_GRADIENT) {
+ s->invert = 3;
}
lcd_puts_style_offset(x,y,string,style,offset);
@@ -961,8 +1020,37 @@ void lcd_scroll_fn(void)
}
lastmode = drawmode;
- drawmode = s->invert ?
+ drawmode = s->invert == 1 ?
(DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
+ if (s->invert == 2) {
+ fg_pattern = lss_pattern;
+ drawmode = DRMODE_FG;
+ lcd_fillrect(0, ypos, LCD_WIDTH, pf->height);
+ fg_pattern = lst_pattern;
+ }
+ else if (s->invert == 3) {
+ int h_r = RGB_UNPACK_RED(lss_pattern) << 16;
+ int h_b = RGB_UNPACK_BLUE(lss_pattern) << 16;
+ int h_g = RGB_UNPACK_GREEN(lss_pattern) << 16;
+ int rstep = (h_r - ((signed)RGB_UNPACK_RED(lse_pattern) << 16))
+ / pf->height;
+ int gstep = (h_g - ((signed)RGB_UNPACK_GREEN(lse_pattern) << 16))
+ / pf->height;
+ int bstep = (h_b - ((signed)RGB_UNPACK_BLUE(lse_pattern) << 16))
+ / pf->height;
+ unsigned int count;
+
+ fg_pattern = lss_pattern;
+ drawmode = DRMODE_FG;
+ for(count = 0; count < pf->height; count++) {
+ lcd_hline(0, LCD_WIDTH , ypos + count);
+ h_r -= rstep;
+ h_g -= gstep;
+ h_b -= bstep;
+ fg_pattern = LCD_RGBPACK(h_r >> 16, h_g >> 16, h_b >> 16);
+ }
+ fg_pattern = lst_pattern;
+ }
lcd_putsxyofs(xpos, ypos, s->offset, s->line);
drawmode = lastmode;
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 @@
#define STYLE_DEFAULT 0x00000000
#define STYLE_INVERT 0x20000000
#define STYLE_COLORED 0x10000000
+#define STYLE_COLORBAR 0x40000000
+#define STYLE_GRADIENT 0x80000000
#define STYLE_COLOR_MASK 0x0000FFFF
#ifdef SIMULATOR
@@ -233,6 +235,7 @@ static inline unsigned lcd_color_to_native(unsigned color)
#define LCD_WHITE LCD_RGBPACK(255, 255, 255)
#define LCD_DEFAULT_FG LCD_BLACK
#define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */
+#define LCD_DEFAULT_LS LCD_WHITE
#elif LCD_DEPTH > 1 /* greyscale */
@@ -355,6 +358,11 @@ extern void lcd_set_foreground(unsigned foreground);
extern unsigned lcd_get_foreground(void);
extern void lcd_set_background(unsigned background);
extern unsigned lcd_get_background(void);
+#ifdef HAVE_LCD_COLOR
+extern void lcd_set_selector_start(unsigned selector);
+extern void lcd_set_selector_end(unsigned selector);
+extern void lcd_set_selector_text(unsigned selector_text);
+#endif
extern void lcd_set_drawinfo(int mode, unsigned foreground,
unsigned background);
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
int startx;
#ifdef HAVE_LCD_BITMAP
int width; /* length of line in pixels */
- bool invert; /* invert the scrolled text */
+#ifdef HAVE_LCD_COLOR
+ int invert; /* invert the scrolled text */
+#else
+ bool invert;
#endif
+#endif/* HAVE_LCD_BITMAP */
bool backward; /* scroll presently forward or backward? */
bool bidir;
long start_tick;