summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/splash.c9
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h15
-rw-r--r--apps/plugins/bounce.c13
-rw-r--r--apps/plugins/cube.c16
-rw-r--r--apps/plugins/lib/gray.h10
-rw-r--r--apps/plugins/lib/gray_parm.c10
-rw-r--r--apps/plugins/minesweeper.c14
-rw-r--r--apps/plugins/sokoban.c6
-rw-r--r--apps/plugins/solitaire.c8
-rw-r--r--apps/plugins/sudoku.c10
-rw-r--r--apps/screen_access.h6
-rw-r--r--firmware/drivers/lcd-16bit.c42
-rw-r--r--firmware/drivers/lcd-h100.c10
-rw-r--r--firmware/export/lcd.h71
15 files changed, 94 insertions, 148 deletions
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index fc15294211..8d69068d3b 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -127,13 +127,8 @@ void internal_splash(struct screen * screen,
127 int xx = (screen->width-maxw)/2 - 2; 127 int xx = (screen->width-maxw)/2 - 2;
128 /* The new graphics routines handle clipping, so no need to check */ 128 /* The new graphics routines handle clipping, so no need to check */
129#if LCD_DEPTH > 1 129#if LCD_DEPTH > 1
130#ifdef HAVE_LCD_COLOR
131 screen->set_background((struct rgb){LCD_MAX_RED-1, LCD_MAX_GREEN-1,
132 LCD_MAX_BLUE-1});
133#else
134 if(screen->depth>1) 130 if(screen->depth>1)
135 screen->set_background(LCD_MAX_LEVEL-1); 131 screen->set_background(LCD_LIGHTGRAY);
136#endif
137#endif 132#endif
138 screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 133 screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
139 screen->fillrect(xx, y-2, maxw+4, screen->height-y*2+4); 134 screen->fillrect(xx, y-2, maxw+4, screen->height-y*2+4);
@@ -183,7 +178,7 @@ void internal_splash(struct screen * screen,
183 178
184#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1) 179#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH > 1)
185 if(screen->depth > 1) 180 if(screen->depth > 1)
186 screen->set_background(LCD_WHITE); 181 screen->set_background(LCD_DEFAULT_BG);
187#endif 182#endif
188#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR) 183#if defined(HAVE_LCD_BITMAP) || defined(SIMULATOR)
189 screen->update(); 184 screen->update();
diff --git a/apps/plugin.c b/apps/plugin.c
index a30b089e55..d5607aa822 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -434,7 +434,7 @@ int plugin_load(const char* plugin, void* parameter)
434 button_clear_queue(); 434 button_clear_queue();
435#ifdef HAVE_LCD_BITMAP 435#ifdef HAVE_LCD_BITMAP
436#if LCD_DEPTH > 1 436#if LCD_DEPTH > 1
437 lcd_set_drawinfo(DRMODE_SOLID, LCD_BLACK, LCD_WHITE); 437 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
438#else /* LCD_DEPTH == 1 */ 438#else /* LCD_DEPTH == 1 */
439 lcd_set_drawmode(DRMODE_SOLID); 439 lcd_set_drawmode(DRMODE_SOLID);
440#endif /* LCD_DEPTH */ 440#endif /* LCD_DEPTH */
diff --git a/apps/plugin.h b/apps/plugin.h
index 8630ce7f17..f8e84f8cae 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -173,17 +173,10 @@ struct plugin_api {
173 void (*lcd_mono_bitmap)(const unsigned char *src, int x, int y, 173 void (*lcd_mono_bitmap)(const unsigned char *src, int x, int y,
174 int width, int height); 174 int width, int height);
175#if LCD_DEPTH > 1 175#if LCD_DEPTH > 1
176#ifdef HAVE_LCD_COLOR 176 void (*lcd_set_foreground)(unsigned foreground);
177 void (*lcd_set_foreground)(struct rgb color); 177 unsigned (*lcd_get_foreground)(void);
178 struct rgb (*lcd_get_foreground)(void); 178 void (*lcd_set_background)(unsigned foreground);
179 void (*lcd_set_background)(struct rgb color); 179 unsigned (*lcd_get_background)(void);
180 struct rgb (*lcd_get_background)(void);
181#else
182 void (*lcd_set_foreground)(int brightness);
183 int (*lcd_get_foreground)(void);
184 void (*lcd_set_background)(int brightness);
185 int (*lcd_get_background)(void);
186#endif
187 void (*lcd_bitmap_part)(const fb_data *src, int src_x, int src_y, 180 void (*lcd_bitmap_part)(const fb_data *src, int src_x, int src_y,
188 int stride, int x, int y, int width, int height); 181 int stride, int x, int y, int width, int height);
189 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width, 182 void (*lcd_bitmap)(const fb_data *src, int x, int y, int width,
diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c
index 3ff3a8d5f6..1bf8b3b34d 100644
--- a/apps/plugins/bounce.c
+++ b/apps/plugins/bounce.c
@@ -282,17 +282,14 @@ static void addclock(void)
282#define DRAW_WIDTH (LCD_WIDTH + LETTER_WIDTH*2) 282#define DRAW_WIDTH (LCD_WIDTH + LETTER_WIDTH*2)
283 283
284#if LCD_DEPTH > 1 284#if LCD_DEPTH > 1
285#ifdef HAVE_LCD_COLOR 285static const unsigned face_colors[] =
286static const struct rgb face_colors[] =
287{ 286{
288 LCD_BLACK, {0, 0, LCD_MAX_BLUE}, {LCD_MAX_RED, 0, 0} 287#ifdef HAVE_LCD_COLOR
289}; 288 LCD_BLACK, LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(255, 0, 0)
290#else 289#else
291static const int face_colors[] = 290 LCD_BLACK, LCD_LIGHTGRAY, LCD_DARKGRAY
292{
293 0, 2*LCD_MAX_LEVEL/3, LCD_MAX_LEVEL/3
294};
295#endif 291#endif
292};
296#endif 293#endif
297 294
298static int scrollit(void) 295static int scrollit(void)
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index 2360269aba..dc5b5706f4 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -152,18 +152,16 @@ static const struct face faces[6] =
152}; 152};
153 153
154#if LCD_DEPTH > 1 154#if LCD_DEPTH > 1
155#ifdef HAVE_LCD_COLOR 155static const unsigned face_colors[6] =
156static const struct rgb face_colors[6] =
157{ 156{
158 {LCD_MAX_RED, 0, 0}, {LCD_MAX_RED, 0, 0}, {0, LCD_MAX_GREEN, 0}, 157#ifdef HAVE_LCD_COLOR
159 {0, LCD_MAX_GREEN, 0}, {0, 0, LCD_MAX_BLUE}, {0, 0, LCD_MAX_BLUE} 158 LCD_RGBPACK(255, 0, 0), LCD_RGBPACK(255, 0, 0), LCD_RGBPACK(0, 255, 0),
160}; 159 LCD_RGBPACK(0, 255, 0), LCD_RGBPACK(0, 0, 255), LCD_RGBPACK(0, 0, 255)
161#else 160#else
162static const int face_colors[6] = 161 LCD_LIGHTGRAY, LCD_LIGHTGRAY, LCD_DARKGRAY,
163{ 162 LCD_DARKGRAY, LCD_BLACK, LCD_BLACK
164 2*LCD_MAX_LEVEL/3, 2*LCD_MAX_LEVEL/3, LCD_MAX_LEVEL/3, LCD_MAX_LEVEL/3, 0, 0
165};
166#endif 163#endif
164};
167#endif 165#endif
168 166
169enum { 167enum {
diff --git a/apps/plugins/lib/gray.h b/apps/plugins/lib/gray.h
index dadac9298f..f82cf389c3 100644
--- a/apps/plugins/lib/gray.h
+++ b/apps/plugins/lib/gray.h
@@ -51,11 +51,11 @@ void gray_update_rect(int x, int y, int width, int height);
51void gray_set_position(int x, int by); 51void gray_set_position(int x, int by);
52void gray_set_drawmode(int mode); 52void gray_set_drawmode(int mode);
53int gray_get_drawmode(void); 53int gray_get_drawmode(void);
54void gray_set_foreground(int brightness); 54void gray_set_foreground(unsigned brightness);
55int gray_get_foreground(void); 55unsigned gray_get_foreground(void);
56void gray_set_background(int brightness); 56void gray_set_background(unsigned brightness);
57int gray_get_background(void); 57unsigned gray_get_background(void);
58void gray_set_drawinfo(int mode, int fg_brightness, int bg_brightness); 58void gray_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness);
59void gray_setfont(int newfont); 59void gray_setfont(int newfont);
60int gray_getstringsize(const unsigned char *str, int *w, int *h); 60int gray_getstringsize(const unsigned char *str, int *w, int *h);
61 61
diff --git a/apps/plugins/lib/gray_parm.c b/apps/plugins/lib/gray_parm.c
index a8c238a4eb..c4ee92f9cc 100644
--- a/apps/plugins/lib/gray_parm.c
+++ b/apps/plugins/lib/gray_parm.c
@@ -53,7 +53,7 @@ int gray_get_drawmode(void)
53} 53}
54 54
55/* Set the foreground shade for subsequent drawing operations */ 55/* Set the foreground shade for subsequent drawing operations */
56void gray_set_foreground(int brightness) 56void gray_set_foreground(unsigned brightness)
57{ 57{
58 unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127; 58 unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127;
59 59
@@ -61,14 +61,14 @@ void gray_set_foreground(int brightness)
61} 61}
62 62
63/* Return the current foreground shade */ 63/* Return the current foreground shade */
64int gray_get_foreground(void) 64unsigned gray_get_foreground(void)
65{ 65{
66 return (_gray_info.fg_brightness * 255 + (_gray_info.depth >> 1)) 66 return (_gray_info.fg_brightness * 255 + (_gray_info.depth >> 1))
67 / _gray_info.depth; 67 / _gray_info.depth;
68} 68}
69 69
70/* Set the background shade for subsequent drawing operations */ 70/* Set the background shade for subsequent drawing operations */
71void gray_set_background(int brightness) 71void gray_set_background(unsigned brightness)
72{ 72{
73 unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127; 73 unsigned data = MULU16(_gray_info.depth, brightness & 0xFF) + 127;
74 74
@@ -76,14 +76,14 @@ void gray_set_background(int brightness)
76} 76}
77 77
78/* Return the current background shade */ 78/* Return the current background shade */
79int gray_get_background(void) 79unsigned gray_get_background(void)
80{ 80{
81 return (_gray_info.bg_brightness * 255 + (_gray_info.depth >> 1)) 81 return (_gray_info.bg_brightness * 255 + (_gray_info.depth >> 1))
82 / _gray_info.depth; 82 / _gray_info.depth;
83} 83}
84 84
85/* Set draw mode, foreground and background shades at once */ 85/* Set draw mode, foreground and background shades at once */
86void gray_set_drawinfo(int mode, int fg_brightness, int bg_brightness) 86void gray_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
87{ 87{
88 gray_set_drawmode(mode); 88 gray_set_drawmode(mode);
89 gray_set_foreground(fg_brightness); 89 gray_set_foreground(fg_brightness);
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index 097c1b0c43..4af467b516 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -67,16 +67,6 @@ use F3 to see how many mines are left (supposing all your flags are correct)
67 67
68#endif 68#endif
69 69
70#if LCD_DEPTH > 1
71#if HAVE_LCD_COLOR
72#define LIGHT_GRAY ((struct rgb){2*LCD_MAX_RED/3, 2*LCD_MAX_GREEN/3, 2*LCD_MAX_BLUE/3})
73#define DARK_GRAY ((struct rgb){LCD_MAX_RED/3, LCD_MAX_GREEN/3, LCD_MAX_BLUE/3})
74#else
75#define LIGHT_GRAY (2*LCD_MAX_LEVEL/3)
76#define DARK_GRAY (LCD_MAX_LEVEL/3)
77#endif
78#endif
79
80/* here is a global api struct pointer. while not strictly necessary, 70/* here is a global api struct pointer. while not strictly necessary,
81 it's nice not to have to pass the api pointer in all function calls 71 it's nice not to have to pass the api pointer in all function calls
82 in the plugin */ 72 in the plugin */
@@ -385,7 +375,7 @@ int minesweeper(void)
385 for(i=0;i<height;i++){ 375 for(i=0;i<height;i++){
386 for(j=0;j<width;j++){ 376 for(j=0;j<width;j++){
387#if LCD_DEPTH > 1 377#if LCD_DEPTH > 1
388 rb->lcd_set_foreground(DARK_GRAY); 378 rb->lcd_set_foreground(LCD_DARKGRAY);
389 rb->lcd_drawrect(j*8,i*8,8,8); 379 rb->lcd_drawrect(j*8,i*8,8,8);
390 rb->lcd_set_foreground(LCD_BLACK); 380 rb->lcd_set_foreground(LCD_BLACK);
391#else 381#else
@@ -404,7 +394,7 @@ int minesweeper(void)
404 rb->lcd_drawline(j*8+2,i*8+5,j*8+5,i*8+2); 394 rb->lcd_drawline(j*8+2,i*8+5,j*8+5,i*8+2);
405 } else { 395 } else {
406#if LCD_DEPTH > 1 396#if LCD_DEPTH > 1
407 rb->lcd_set_foreground(LIGHT_GRAY); 397 rb->lcd_set_foreground(LCD_LIGHTGRAY);
408 rb->lcd_fillrect(j*8+1,i*8+1,6,6); 398 rb->lcd_fillrect(j*8+1,i*8+1,6,6);
409 rb->lcd_set_foreground(LCD_BLACK); 399 rb->lcd_set_foreground(LCD_BLACK);
410#else 400#else
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 70f616d406..a341cf5416 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -59,10 +59,10 @@
59#endif 59#endif
60 60
61#if LCD_DEPTH > 1 61#if LCD_DEPTH > 1
62#if HAVE_LCD_COLOR 62#ifdef HAVE_LCD_COLOR
63#define MEDIUM_GRAY ((struct rgb){LCD_MAX_RED/2, LCD_MAX_GREEN/2, LCD_MAX_BLUE/2}) 63#define MEDIUM_GRAY LCD_RGBPACK(127, 127, 127)
64#else 64#else
65#define MEDIUM_GRAY (LCD_MAX_LEVEL/2) 65#define MEDIUM_GRAY LCD_BRIGHTNESS(127)
66#endif 66#endif
67#endif 67#endif
68 68
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index b2af0828e2..30405a582f 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -135,13 +135,13 @@ static struct plugin_api* rb;
135#endif 135#endif
136 136
137#if LCD_DEPTH>1 137#if LCD_DEPTH>1
138static const unsigned colors[4] = {
138#ifdef HAVE_LCD_COLOR 139#ifdef HAVE_LCD_COLOR
139static const unsigned struct rgb colors[4] = { 140 LCD_BLACK, LCD_RGBPACK(255, 0, 0), LCD_BLACK, LCD_RGBPACK(255, 0, 0)
140 { 0, 0, 0 }, { LCD_MAX_RED, 0, 0 }, { 0, 0, 0 }, { LCD_MAX_RED, 0, 0 }
141};
142#else 141#else
143static const int colors[4] = { LCD_BLACK, LCD_MAX_LEVEL/2, LCD_BLACK, LCD_MAX_LEVEL/2 }; 142 LCD_BLACK, LCD_BRIGHTNESS(127), LCD_BLACK, LCD_BRIGHTNESS(127)
144#endif 143#endif
144};
145#endif 145#endif
146 146
147static const unsigned char suits[4][8] = { 147static const unsigned char suits[4][8] = {
diff --git a/apps/plugins/sudoku.c b/apps/plugins/sudoku.c
index 526416d11e..bab53bbad4 100644
--- a/apps/plugins/sudoku.c
+++ b/apps/plugins/sudoku.c
@@ -362,16 +362,6 @@ static unsigned char num_inverse[10][8]= {
362 #error SUDOKU: Unsupported LCD size 362 #error SUDOKU: Unsupported LCD size
363#endif 363#endif
364 364
365#if LCD_DEPTH > 1
366#if HAVE_LCD_COLOR
367#define LIGHT_GRAY ((struct rgb){2*LCD_MAX_RED/3, 2*LCD_MAX_GREEN/3, 2*LCD_MAX_BLUE/3})
368#define DARK_GRAY ((struct rgb){LCD_MAX_RED/3, LCD_MAX_GREEN/3, LCD_MAX_BLUE/3})
369#else
370#define LIGHT_GRAY (2*LCD_MAX_LEVEL/3)
371#define DARK_GRAY (LCD_MAX_LEVEL/3)
372#endif
373#endif
374
375/* here is a global api struct pointer. while not strictly necessary, 365/* here is a global api struct pointer. while not strictly necessary,
376 it's nice not to have to pass the api pointer in all function calls 366 it's nice not to have to pass the api pointer in all function calls
377 in the plugin */ 367 in the plugin */
diff --git a/apps/screen_access.h b/apps/screen_access.h
index c167708fbf..6111de9de4 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -76,11 +76,7 @@ struct screen
76 int x, int y, int width, int height); 76 int x, int y, int width, int height);
77 void (*set_drawmode)(int mode); 77 void (*set_drawmode)(int mode);
78#if LCD_DEPTH > 1 78#if LCD_DEPTH > 1
79#if HAVE_LCD_COLOR 79 void (*set_background)(unsigned background);
80 void (*set_background)(struct rgb color);
81#else
82 void (*set_background)(int brightness);
83#endif
84#endif /* LCD_DEPTH > 1 */ 80#endif /* LCD_DEPTH > 1 */
85 void (*update_rect)(int x, int y, int width, int height); 81 void (*update_rect)(int x, int y, int width, int height);
86 void (*fillrect)(int x, int y, int width, int height); 82 void (*fillrect)(int x, int y, int width, int height);
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c
index 185f572182..1aed98e5f6 100644
--- a/firmware/drivers/lcd-16bit.c
+++ b/firmware/drivers/lcd-16bit.c
@@ -34,13 +34,11 @@
34 34
35#define SCROLLABLE_LINES 26 35#define SCROLLABLE_LINES 26
36 36
37#define RGB_PACK(r,g,b) (htobe16(((r)<<11)|((g)<<5)|(b)))
38
39/*** globals ***/ 37/*** globals ***/
40fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (4))); 38fb_data lcd_framebuffer[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (4)));
41 39
42static unsigned fg_pattern; 40static unsigned fg_pattern = LCD_DEFAULT_FG;
43static unsigned bg_pattern; 41static unsigned bg_pattern = LCD_DEFAULT_BG;
44static int drawmode = DRMODE_SOLID; 42static int drawmode = DRMODE_SOLID;
45static int xmargin = 0; 43static int xmargin = 0;
46static int ymargin = 0; 44static int ymargin = 0;
@@ -72,9 +70,6 @@ int lcd_default_contrast(void)
72/* LCD init */ 70/* LCD init */
73void lcd_init(void) 71void lcd_init(void)
74{ 72{
75 fg_pattern = 0x0000; /* Black */
76 bg_pattern = RGB_PACK(0x17, 0x31, 0x1d); /* "Rockbox blue" */
77
78 lcd_clear_display(); 73 lcd_clear_display();
79 /* Call device specific init */ 74 /* Call device specific init */
80 lcd_init_device(); 75 lcd_init_device();
@@ -94,43 +89,32 @@ int lcd_get_drawmode(void)
94 return drawmode; 89 return drawmode;
95} 90}
96 91
97void lcd_set_foreground(struct rgb color) 92void lcd_set_foreground(unsigned color)
98{ 93{
99 fg_pattern = RGB_PACK(color.red, color.green, color.blue); 94 fg_pattern = color;
100} 95}
101 96
102struct rgb lcd_get_foreground(void) 97unsigned lcd_get_foreground(void)
103{ 98{
104 struct rgb colour; 99 return fg_pattern;
105
106 colour.red = (fg_pattern >> 11) & 0x1f;
107 colour.green = (fg_pattern >> 5) & 0x3f;
108 colour.blue = fg_pattern & 0x1f;
109 return colour;
110} 100}
111 101
112void lcd_set_background(struct rgb color) 102void lcd_set_background(unsigned color)
113{ 103{
114 bg_pattern = RGB_PACK(color.red, color.green, color. blue); 104 bg_pattern = color;
115} 105}
116 106
117 107
118struct rgb lcd_get_background(void) 108unsigned lcd_get_background(void)
119{ 109{
120 struct rgb colour; 110 return bg_pattern;
121
122 colour.red = (bg_pattern >> 11) & 0x1f;
123 colour.green = (bg_pattern >> 5) & 0x3f;
124 colour.blue = bg_pattern & 0x1f;
125 return colour;
126} 111}
127 112
128void lcd_set_drawinfo(int mode, struct rgb fg_color, 113void lcd_set_drawinfo(int mode, unsigned fg_color, unsigned bg_color)
129 struct rgb bg_color)
130{ 114{
131 lcd_set_drawmode(mode); 115 lcd_set_drawmode(mode);
132 lcd_set_foreground(fg_color); 116 fg_pattern = fg_color;
133 lcd_set_background(bg_color); 117 bg_pattern = bg_color;
134} 118}
135 119
136void lcd_setmargins(int x, int y) 120void lcd_setmargins(int x, int y)
diff --git a/firmware/drivers/lcd-h100.c b/firmware/drivers/lcd-h100.c
index e8541f7621..1005cf6b5f 100644
--- a/firmware/drivers/lcd-h100.c
+++ b/firmware/drivers/lcd-h100.c
@@ -307,27 +307,27 @@ int lcd_get_drawmode(void)
307 return drawmode; 307 return drawmode;
308} 308}
309 309
310void lcd_set_foreground(int brightness) 310void lcd_set_foreground(unsigned brightness)
311{ 311{
312 fg_pattern = 0x55 * (~brightness & 3); 312 fg_pattern = 0x55 * (~brightness & 3);
313} 313}
314 314
315int lcd_get_foreground(void) 315unsigned lcd_get_foreground(void)
316{ 316{
317 return ~fg_pattern & 3; 317 return ~fg_pattern & 3;
318} 318}
319 319
320void lcd_set_background(int brightness) 320void lcd_set_background(unsigned brightness)
321{ 321{
322 bg_pattern = 0x55 * (~brightness & 3); 322 bg_pattern = 0x55 * (~brightness & 3);
323} 323}
324 324
325int lcd_get_background(void) 325unsigned lcd_get_background(void)
326{ 326{
327 return ~bg_pattern & 3; 327 return ~bg_pattern & 3;
328} 328}
329 329
330void lcd_set_drawinfo(int mode, int fg_brightness, int bg_brightness) 330void lcd_set_drawinfo(int mode, unsigned fg_brightness, unsigned bg_brightness)
331{ 331{
332 lcd_set_drawmode(mode); 332 lcd_set_drawmode(mode);
333 lcd_set_foreground(fg_brightness); 333 lcd_set_foreground(fg_brightness);
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 2d04cec054..48244fe2a8 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -140,29 +140,39 @@ typedef void lcd_blockfunc_type(unsigned char *address, unsigned mask, unsigned
140 140
141#ifdef HAVE_LCD_COLOR 141#ifdef HAVE_LCD_COLOR
142#if LCD_DEPTH == 16 142#if LCD_DEPTH == 16
143#define LCD_MAX_RED ((1 << 5) - 1) 143#define LCD_MAX_RED 31
144#define LCD_MAX_GREEN ((1 << 6) - 1) 144#define LCD_MAX_GREEN 63
145#define LCD_MAX_BLUE ((1 << 5) - 1) 145#define LCD_MAX_BLUE 31
146#define _RGBPACK(r, g, b) ( ((((r) * 31 + 127) / 255) << 11) \
147 |((((g) * 63 + 127) / 255) << 5) \
148 | (((b) * 31 + 127) / 255))
149#if (CONFIG_LCD == LCD_IPODCOLOR) || (CONFIG_LCD == LCD_IPODNANO)
150#define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \
151 |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8))
146#else 152#else
147#define LCD_MAX_RED ((1 << (LCD_DEPTH/3)) - 1) 153#define LCD_RGBPACK(r, g, b) _RGBPACK((r), (g), (b))
148#define LCD_MAX_GREEN ((1 << (LCD_DEPTH/3)) - 1)
149#define LCD_MAX_BLUE ((1 << (LCD_DEPTH/3)) - 1)
150#endif 154#endif
151struct rgb { 155#else
152 unsigned char red; 156/* other colour depths */
153 unsigned char green; 157#endif
154 unsigned char blue; 158
155}; 159#define LCD_BLACK LCD_RGBPACK(0, 0, 0)
156#define LCD_BLACK ((struct rgb){0, 0, 0}) 160#define LCD_DARKGRAY LCD_RGBPACK(85, 85, 85)
157#define LCD_DARKGRAY ((struct rgb){LCD_MAX_RED/3, LCD_MAX_GREEN/3, LCD_MAX_BLUE/3}) 161#define LCD_LIGHTGRAY LCD_RGBPACK(170, 170, 170)
158#define LCD_LIGHTGRAY ((struct rgb){2*LCD_MAX_RED/3, 2*LCD_MAX_GREEN/3, 2*LCD_MAX_BLUE/3}) 162#define LCD_WHITE LCD_RGBPACK(255, 255, 255)
159#define LCD_WHITE ((struct rgb){LCD_MAX_RED, LCD_MAX_GREEN, LCD_MAX_BLUE}) 163#define LCD_DEFAULT_FG LCD_BLACK
160#else /* monochrome */ 164#define LCD_DEFAULT_BG LCD_RGBPACK(182, 198, 229) /* rockbox blue */
165
166#elif LCD_DEPTH > 1 /* greyscale */
161#define LCD_MAX_LEVEL ((1 << LCD_DEPTH) - 1) 167#define LCD_MAX_LEVEL ((1 << LCD_DEPTH) - 1)
162#define LCD_BLACK 0 168#define LCD_BRIGHTNESS(y) (((y) * LCD_MAX_LEVEL + 127) / 255)
163#define LCD_DARKGRAY (LCD_MAX_LEVEL/3) 169
164#define LCD_LIGHTGRAY (2*LCD_MAX_LEVEL/3) 170#define LCD_BLACK LCD_BRIGHTNESS(0)
165#define LCD_WHITE LCD_MAX_LEVEL 171#define LCD_DARKGRAY LCD_BRIGHTNESS(85)
172#define LCD_LIGHTGRAY LCD_BRIGHTNESS(170)
173#define LCD_WHITE LCD_BRIGHTNESS(255)
174#define LCD_DEFAULT_FG LCD_BLACK
175#define LCD_DEFAULT_BG LCD_WHITE
166#endif 176#endif
167 177
168/* Memory copy of display bitmap */ 178/* Memory copy of display bitmap */
@@ -207,20 +217,13 @@ extern void lcd_bidir_scroll(int threshold);
207extern void lcd_scroll_step(int pixels); 217extern void lcd_scroll_step(int pixels);
208 218
209#if LCD_DEPTH > 1 219#if LCD_DEPTH > 1
210#ifdef HAVE_LCD_COLOR 220extern void lcd_set_foreground(unsigned foreground);
211extern void lcd_set_foreground(struct rgb color); 221extern unsigned lcd_get_foreground(void);
212extern struct rgb lcd_get_foreground(void); 222extern void lcd_set_background(unsigned background);
213extern void lcd_set_background(struct rgb color); 223extern unsigned lcd_get_background(void);
214extern struct rgb lcd_get_background(void); 224extern void lcd_set_drawinfo(int mode, unsigned foreground,
215extern void lcd_set_drawinfo(int mode, struct rgb fg_color, 225 unsigned background);
216 struct rgb bg_color); 226
217#else /* monochrome */
218extern void lcd_set_foreground(int brightness);
219extern int lcd_get_foreground(void);
220extern void lcd_set_background(int brightness);
221extern int lcd_get_background(void);
222extern void lcd_set_drawinfo(int mode, int fg_brightness, int bg_brightness);
223#endif
224extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y, 227extern void lcd_mono_bitmap_part(const unsigned char *src, int src_x, int src_y,
225 int stride, int x, int y, int width, int height); 228 int stride, int x, int y, int width, int height);
226extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width, 229extern void lcd_mono_bitmap(const unsigned char *src, int x, int y, int width,