summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/lcd-16bit.c42
-rw-r--r--firmware/drivers/lcd-h100.c10
2 files changed, 18 insertions, 34 deletions
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);