summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/SOURCES1
-rw-r--r--apps/gui/color_picker.c261
-rw-r--r--apps/gui/color_picker.h25
-rw-r--r--apps/gui/splash.h1
-rw-r--r--apps/lang/english.lang30
-rw-r--r--apps/plugin.c5
-rw-r--r--apps/settings.c61
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_menu.c41
-rw-r--r--firmware/export/lcd.h9
10 files changed, 436 insertions, 2 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index ef65789588..f34cac9654 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -58,6 +58,7 @@ recorder/peakmeter.c
58recorder/widgets.c 58recorder/widgets.c
59#ifdef HAVE_LCD_COLOR 59#ifdef HAVE_LCD_COLOR
60recorder/backdrop.c 60recorder/backdrop.c
61gui/color_picker.c
61#endif 62#endif
62#endif 63#endif
63#ifdef CONFIG_TUNER 64#ifdef CONFIG_TUNER
diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c
new file mode 100644
index 0000000000..2f851d269e
--- /dev/null
+++ b/apps/gui/color_picker.c
@@ -0,0 +1,261 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:
9 *
10 * Copyright (C) Jonathan Gordon (2006)
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "stdarg.h"
20#include "string.h"
21#include "stdio.h"
22#include "kernel.h"
23#include "system.h"
24#include "screen_access.h"
25#include "debug.h"
26#include "misc.h"
27#include "settings.h"
28#include "scrollbar.h"
29#include "lang.h"
30
31#define TEXT_MARGIN display->char_width+2
32#define SLIDER_START 20
33
34#if (CONFIG_KEYPAD == IRIVER_H300_PAD)
35#define SLIDER_UP BUTTON_UP
36#define SLIDER_DOWN BUTTON_DOWN
37#define SLIDER_LEFT BUTTON_LEFT
38#define SLIDER_RIGHT BUTTON_RIGHT
39#define SLIDER_OK BUTTON_ON
40#define SLIDER_CANCEL BUTTON_OFF
41
42#define SLIDER_RC_UP BUTTON_RC_REW
43#define SLIDER_RC_DOWN BUTTON_RC_FF
44#define SLIDER_RC_LEFT BUTTON_RC_SOURCE
45#define SLIDER_RC_RIGHT BUTTON_RC_BITRATE
46#define SLIDER_RC_OK BUTTON_RC_ON
47#define SLIDER_RC_CANCEL BUTTON_RC_STOP
48
49#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
50#define SLIDER_UP BUTTON_LEFT
51#define SLIDER_DOWN BUTTON_RIGHT
52#define SLIDER_LEFT BUTTON_SCROLL_BACK
53#define SLIDER_RIGHT BUTTON_SCROLL_FWD
54#define SLIDER_OK BUTTON_SELECT
55#define SLIDER_CANCEL BUTTON_MENU
56#endif
57
58static const int max_val[3] = {LCD_MAX_RED,LCD_MAX_GREEN,LCD_MAX_BLUE};
59
60static void draw_screen(struct screen *display, char *title,
61 int *rgb_val, int color, int row)
62{
63 int i;
64 char *textrgb = str(LANG_COLOR_RGB_LABELS), rgb_dummy[2] = {0,0};
65 int text_top;
66 int text_centre, bg_col;
67 char buf[32];
68 int slider_width = (display->width-SLIDER_START-(display->char_width*5));
69 int background_color = global_settings.bg_color;
70 int text_color = global_settings.fg_color;
71
72 display->clear_display();
73
74 if (display->depth > 1) {
75 display->set_foreground(text_color);
76 }
77
78 i = display->getstringsize(title,0,0);
79 display->putsxy((display->width-i)/2,6,title );
80
81 for (i=0;i<3;i++)
82 {
83 text_top =display->char_height*((i*2)+2);
84
85 if (i==row)
86 {
87 if (global_settings.invert_cursor)
88 {
89 display->fillrect(0,text_top-1,display->width,display->char_height+2);
90 bg_col = text_color;
91 }
92 else
93 {
94 display->putsxy(0,text_top,">");
95 display->putsxy(display->width-TEXT_MARGIN,text_top,"<");
96 bg_col = background_color;
97 }
98 if (display->depth > 1)
99 {
100 if (i==0)
101 display->set_foreground(LCD_RGBPACK(255, 0, 0));
102 else if (i==1)
103 display->set_foreground(LCD_RGBPACK(0, 255, 0));
104 else if (i==2)
105 display->set_foreground(LCD_RGBPACK(0 ,0 ,255));
106 }
107 }
108 else
109 {
110 if (display->depth > 1)
111 display->set_foreground(text_color);
112 bg_col = background_color;
113 }
114
115 if (display->depth > 1)
116 display->set_background(bg_col);
117
118 text_centre = text_top+(display->char_height/2);
119 rgb_dummy[0] = textrgb[i];
120 display->putsxy(TEXT_MARGIN,text_top,rgb_dummy);
121 snprintf(buf,3,"%02d",rgb_val[i]);
122 display->putsxy(display->width-(display->char_width*4),text_top,buf);
123
124 text_top += display->char_height/4;
125
126 gui_scrollbar_draw(display,SLIDER_START,text_top,slider_width,
127 display->char_height/2,
128 max_val[i],0,rgb_val[i],HORIZONTAL);
129 }
130
131 if (display->depth > 1) {
132 display->set_background(background_color);
133 display->set_foreground(text_color);
134 }
135
136 if (text_top + (display->char_height*2) < (LCD_HEIGHT-40-display->char_height))
137 text_top += (display->char_height*2);
138 else text_top += (display->char_height);
139
140 /* Display RGB: #rrggbb */
141 snprintf(buf,sizeof(buf),str(LANG_COLOR_RGB_VALUE),
142 RGB_UNPACK_RED(color),
143 RGB_UNPACK_GREEN(color),
144 RGB_UNPACK_BLUE(color));
145
146 display->putsxy((LCD_WIDTH-(display->char_width*21))/2,text_top,buf);
147
148 if (display->depth > 1) {
149 display->set_foreground(color);
150 display->fillrect(SLIDER_START,LCD_HEIGHT-40,slider_width,35);
151
152 display->set_foreground(LCD_BLACK);
153 display->drawrect(SLIDER_START-1,LCD_HEIGHT-41,slider_width+2,37);
154 }
155
156 display->update();
157}
158
159/***********
160 set_color
161 returns true if USB was inserted, false otherwise
162 color is a pointer to the colour (in native format) to modify
163 ***********/
164bool set_color(struct screen *display,char *title, int* color)
165{
166 int exit = 0, button, slider=0;
167 int rgb_val[3]; /* native depth r,g,b*/;
168 int fgcolor = display->get_foreground();
169 int newcolor = *color;
170 int i;
171
172#if LCD_PIXELFORMAT == RGB565
173 rgb_val[0] = ((*color)&0xf800) >> 11;
174 rgb_val[1] = ((*color)&0x07e0) >> 5;
175 rgb_val[2] = ((*color)&0x001f);
176#elif LCD_PIXELFORMAT == RGB565SWAPPED
177 rgb_val[0] = ((swap16(*color))&0xf800) >> 11;
178 rgb_val[1] = ((swap16(*color))&0x07e0) >> 5;
179 rgb_val[2] = ((swap16(*color))&0x001f);
180#endif
181
182 while (!exit)
183 {
184 /* We need to maintain three versions of the colour:
185
186 rgb_val[3] - the native depth RGB values
187 newcolor - the native format packed colour
188 */
189
190#if LCD_PIXELFORMAT == RGB565
191 newcolor = (rgb_val[0] << 11) | (rgb_val[1] << 5) | (rgb_val[2]);
192#elif LCD_PIXELFORMAT == RGB565SWAPPED
193 newcolor = swap16((rgb_val[0] << 11) | (rgb_val[1] << 5) | (rgb_val[2]));
194#endif
195 FOR_NB_SCREENS(i)
196 draw_screen(&screens[i], title, rgb_val, newcolor, slider);
197
198 button = button_get(true);
199 switch (button)
200 {
201 case SLIDER_UP:
202#ifdef HAVE_LCD_REMOTE
203 case SLIDER_RC_UP:
204#endif
205 slider = (slider+2)%3;
206 break;
207
208 case SLIDER_DOWN:
209#ifdef HAVE_LCD_REMOTE
210 case SLIDER_RC_DOWN:
211#endif
212 slider = (slider+1)%3;
213 break;
214
215 case SLIDER_RIGHT:
216 case SLIDER_RIGHT|BUTTON_REPEAT:
217#ifdef HAVE_LCD_REMOTE
218 case SLIDER_RC_RIGHT:
219 case SLIDER_RC_RIGHT|BUTTON_REPEAT:
220#endif
221 if (rgb_val[slider] < max_val[slider])
222 rgb_val[slider]++;
223 break;
224
225 case SLIDER_LEFT:
226 case SLIDER_LEFT|BUTTON_REPEAT:
227#ifdef HAVE_LCD_REMOTE
228 case SLIDER_RC_LEFT:
229 case SLIDER_RC_LEFT|BUTTON_REPEAT:
230#endif
231 if (rgb_val[slider] > 0)
232 rgb_val[slider]--;
233 break;
234
235 case SLIDER_OK:
236#ifdef HAVE_LCD_REMOTE
237 case SLIDER_RC_OK:
238#endif
239 *color = newcolor;
240 exit = 1;
241 break;
242
243 case SLIDER_CANCEL:
244#ifdef HAVE_LCD_REMOTE
245 case SLIDER_RC_CANCEL:
246#endif
247 exit = 1;
248 break;
249
250 default:
251 if(default_event_handler(button) == SYS_USB_CONNECTED) {
252 display->set_foreground(fgcolor);
253 return true;
254 }
255 break;
256 }
257 }
258 display->set_foreground(fgcolor);
259
260 return false;
261}
diff --git a/apps/gui/color_picker.h b/apps/gui/color_picker.h
new file mode 100644
index 0000000000..1fa35f0c70
--- /dev/null
+++ b/apps/gui/color_picker.h
@@ -0,0 +1,25 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) Jonathan Gordon (2006)
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "screen_access.h"
20
21#ifdef HAVE_LCD_COLOR /* this file is a bit useless on non color lcds.. */
22
23bool set_color(struct screen *display,char *title, int* color);
24
25#endif
diff --git a/apps/gui/splash.h b/apps/gui/splash.h
index 9d8def16f8..b1ac15c537 100644
--- a/apps/gui/splash.h
+++ b/apps/gui/splash.h
@@ -20,6 +20,7 @@
20#ifndef _GUI_SPLASH_H_ 20#ifndef _GUI_SPLASH_H_
21#define _GUI_SPLASH_H_ 21#define _GUI_SPLASH_H_
22#include "screen_access.h" 22#include "screen_access.h"
23
23/* 24/*
24 * Puts a splash message on the given screen for a given period 25 * Puts a splash message on the given screen for a given period
25 * - screen : the screen to put the splash on 26 * - screen : the screen to put the splash on
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index dcb7c07cc6..bd7973ef73 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3748,3 +3748,33 @@ desc: in record settings menu.
3748eng: "Main and remote unit" 3748eng: "Main and remote unit"
3749voice: "Main and remote unit" 3749voice: "Main and remote unit"
3750new: 3750new:
3751
3752id: LANG_COLOR_RGB_LABELS
3753desc: what to show for the 'R' 'G' 'B' ONE LETTER EACH
3754eng: "RGB"
3755voice:
3756new:
3757
3758id: LANG_COLOR_RGB_VALUE
3759desc: in color screen
3760eng: "RGB: %02X%02X%02X"
3761voice:
3762new:
3763
3764id: LANG_BACKGROUND_COLOR
3765desc: menu entry to set the background color
3766eng: "Background Colour"
3767voice:
3768new:
3769
3770id: LANG_FOREGROUND_COLOR
3771desc: menu entry to set the foreground color
3772eng: "Foreground Colour"
3773voice:
3774new:
3775
3776id: LANG_RESET_COLORS
3777desc: menu
3778eng: "Reset Colours"
3779voice:
3780new:
diff --git a/apps/plugin.c b/apps/plugin.c
index c9fb0ac8f5..61396b4357 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -515,7 +515,12 @@ int plugin_load(const char* plugin, void* parameter)
515 515
516#ifdef HAVE_LCD_BITMAP 516#ifdef HAVE_LCD_BITMAP
517#if LCD_DEPTH > 1 517#if LCD_DEPTH > 1
518#ifdef HAVE_LCD_COLOR
519 lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color,
520 global_settings.bg_color);
521#else
518 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG); 522 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
523#endif
519#else /* LCD_DEPTH == 1 */ 524#else /* LCD_DEPTH == 1 */
520 lcd_set_drawmode(DRMODE_SOLID); 525 lcd_set_drawmode(DRMODE_SOLID);
521#endif /* LCD_DEPTH */ 526#endif /* LCD_DEPTH */
diff --git a/apps/settings.c b/apps/settings.c
index 72939e5aac..5a42b17651 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -89,7 +89,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
89#include "dsp.h" 89#include "dsp.h"
90#endif 90#endif
91 91
92#define CONFIG_BLOCK_VERSION 36 92#define CONFIG_BLOCK_VERSION 37
93#define CONFIG_BLOCK_SIZE 512 93#define CONFIG_BLOCK_SIZE 512
94#define RTC_BLOCK_SIZE 44 94#define RTC_BLOCK_SIZE 44
95 95
@@ -122,7 +122,7 @@ struct bit_entry
122 int default_val; /* min 15 bit */ 122 int default_val; /* min 15 bit */
123 /* variable name in a .cfg file, NULL if not to be saved */ 123 /* variable name in a .cfg file, NULL if not to be saved */
124 const char* cfg_name; 124 const char* cfg_name;
125 /* set of values, or NULL for a numerical value */ 125 /* set of values, "rgb" for a color, or NULL for a numerical value */
126 const char* cfg_val; 126 const char* cfg_val;
127}; 127};
128 128
@@ -545,6 +545,10 @@ static const struct bit_entry hd_bits[] =
545 {2, S_O(cliplight), 0, "cliplight", "off,main,both,remote" }, 545 {2, S_O(cliplight), 0, "cliplight", "off,main,both,remote" },
546#endif /* CONFIG_BACKLIGHT */ 546#endif /* CONFIG_BACKLIGHT */
547#endif /*HAVE_RECORDING*/ 547#endif /*HAVE_RECORDING*/
548#ifdef HAVE_LCD_COLOR
549 {LCD_DEPTH,S_O(fg_color),LCD_DEFAULT_FG,"foreground color","rgb"},
550 {LCD_DEPTH,S_O(bg_color),LCD_DEFAULT_BG,"background color","rgb"},
551#endif
548 /* If values are just added to the end, no need to bump the version. */ 552 /* If values are just added to the end, no need to bump the version. */
549 /* new stuff to be added at the end */ 553 /* new stuff to be added at the end */
550 554
@@ -596,6 +600,39 @@ static void set_bits(
596 p[long_index] = (p[long_index] & ~mask) | (value << bit_index); 600 p[long_index] = (p[long_index] & ~mask) | (value << bit_index);
597} 601}
598 602
603#ifdef HAVE_LCD_COLOR
604/*
605 * Helper function to convert a string of 6 hex digits to a native colour
606 */
607
608#define hex2dec(c) (((c) >= '0' && ((c) <= '9')) ? (toupper(c)) - '0' : \
609 (toupper(c)) - 'A' + 10)
610
611int hex_to_rgb(const char* hex)
612{ int ok = 1;
613 int i;
614 int red, green, blue;
615
616 if (strlen(hex) == 6) {
617 for (i=0; i < 6; i++ ) {
618 if (!isxdigit(hex[i])) {
619 ok=0;
620 break;
621 }
622 }
623
624 if (ok) {
625 red = (hex2dec(hex[0]) << 4) | hex2dec(hex[1]);
626 green = (hex2dec(hex[2]) << 4) | hex2dec(hex[3]);
627 blue = (hex2dec(hex[4]) << 4) | hex2dec(hex[5]);
628 return LCD_RGBPACK(red,green,blue);
629 }
630 }
631
632 return 0;
633}
634#endif
635
599/* 636/*
600 * Calculates the checksum for the config block and returns it 637 * Calculates the checksum for the config block and returns it
601 */ 638 */
@@ -1013,6 +1050,8 @@ void settings_apply(void)
1013 } else { 1050 } else {
1014 lcd_set_backdrop(NULL); 1051 lcd_set_backdrop(NULL);
1015 } 1052 }
1053 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
1054 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
1016#endif 1055#endif
1017 1056
1018#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) 1057#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
@@ -1225,6 +1264,12 @@ static int load_cfg_table(
1225 { /* numerical value, just convert the string */ 1264 { /* numerical value, just convert the string */
1226 val = atoi(value); 1265 val = atoi(value);
1227 } 1266 }
1267#if HAVE_LCD_COLOR
1268 else if (!strncasecmp(p_table[i].cfg_val,"rgb",4))
1269 {
1270 val = hex_to_rgb(value);
1271 }
1272#endif
1228 else 1273 else
1229 { /* set of string values, find the index */ 1274 { /* set of string values, find the index */
1230 const char* item; 1275 const char* item;
@@ -1410,6 +1455,15 @@ static void save_cfg_table(const struct bit_entry* p_table, int count, int fd)
1410 { 1455 {
1411 fdprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value); 1456 fdprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value);
1412 } 1457 }
1458#ifdef HAVE_LCD_COLOR
1459 else if (!strcasecmp(p_run->cfg_val, "rgb"))
1460 {
1461 fdprintf(fd, "%s: %02x%02x%02x\r\n", p_run->cfg_name,
1462 (int)RGB_UNPACK_RED(value),
1463 (int)RGB_UNPACK_GREEN(value),
1464 (int)RGB_UNPACK_BLUE(value));
1465 }
1466#endif
1413 else /* write as item */ 1467 else /* write as item */
1414 { 1468 {
1415 const char* p = p_run->cfg_val; 1469 const char* p = p_run->cfg_val;
@@ -1566,6 +1620,9 @@ void settings_reset(void) {
1566 global_settings.lang_file[0] = '\0'; 1620 global_settings.lang_file[0] = '\0';
1567#ifdef HAVE_LCD_COLOR 1621#ifdef HAVE_LCD_COLOR
1568 global_settings.backdrop_file[0] = '\0'; 1622 global_settings.backdrop_file[0] = '\0';
1623
1624 global_settings.fg_color = LCD_DEFAULT_FG;
1625 global_settings.bg_color = LCD_DEFAULT_BG;
1569#endif 1626#endif
1570 1627
1571} 1628}
diff --git a/apps/settings.h b/apps/settings.h
index 753f067234..87020a1094 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -465,6 +465,10 @@ struct user_settings
465 465
466 bool warnon_erase_dynplaylist; /* warn when erasing dynamic playlist */ 466 bool warnon_erase_dynplaylist; /* warn when erasing dynamic playlist */
467 bool scroll_paginated; /* 0=dont 1=do */ 467 bool scroll_paginated; /* 0=dont 1=do */
468#ifdef HAVE_LCD_COLOR
469 int bg_color; /* background color native format */
470 int fg_color; /* foreground color native format */
471#endif
468}; 472};
469 473
470enum optiontype { INT, BOOL }; 474enum optiontype { INT, BOOL };
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 6ac0b6feb2..d089960e9d 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -54,6 +54,7 @@
54#include "splash.h" 54#include "splash.h"
55#include "yesno.h" 55#include "yesno.h"
56#include "list.h" 56#include "list.h"
57#include "color_picker.h"
57 58
58#ifdef HAVE_LCD_BITMAP 59#ifdef HAVE_LCD_BITMAP
59#include "peakmeter.h" 60#include "peakmeter.h"
@@ -319,6 +320,43 @@ static bool clear_main_backdrop(void)
319 lcd_set_backdrop(NULL); 320 lcd_set_backdrop(NULL);
320 return true; 321 return true;
321} 322}
323
324/**
325 * Menu for fore/back colors
326 */
327static bool set_fg_color(void)
328{
329 bool res;
330
331 res = set_color(&screens[SCREEN_MAIN],str(LANG_FOREGROUND_COLOR),
332 &global_settings.fg_color);
333
334 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
335
336 return res;
337}
338
339static bool set_bg_color(void)
340{
341 bool res;
342
343 res = set_color(&screens[SCREEN_MAIN],str(LANG_BACKGROUND_COLOR),
344 &global_settings.bg_color);
345
346 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
347
348 return res;
349}
350
351static bool reset_color(void)
352{
353 global_settings.fg_color = LCD_DEFAULT_FG;
354 global_settings.bg_color = LCD_DEFAULT_BG;
355
356 screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
357 screens[SCREEN_MAIN].set_background(global_settings.bg_color);
358 return false;
359}
322#endif 360#endif
323 361
324/** 362/**
@@ -1586,6 +1624,9 @@ static bool lcd_settings_menu(void)
1586#endif 1624#endif
1587#ifdef HAVE_LCD_COLOR 1625#ifdef HAVE_LCD_COLOR
1588 { ID2P(LANG_CLEAR_BACKDROP), clear_main_backdrop }, 1626 { ID2P(LANG_CLEAR_BACKDROP), clear_main_backdrop },
1627 { ID2P(LANG_BACKGROUND_COLOR), set_bg_color },
1628 { ID2P(LANG_FOREGROUND_COLOR), set_fg_color },
1629 { ID2P(LANG_RESET_COLORS), reset_color },
1589#endif 1630#endif
1590 }; 1631 };
1591 1632
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index ba0e216990..6f7fef94ee 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -150,6 +150,9 @@ typedef void lcd_fastpixelfunc_type(fb_data *address);
150#define LCD_MAX_RED 31 150#define LCD_MAX_RED 31
151#define LCD_MAX_GREEN 63 151#define LCD_MAX_GREEN 63
152#define LCD_MAX_BLUE 31 152#define LCD_MAX_BLUE 31
153#define _RGB_UNPACK_RED(x) ((((x) >> 8) & 0xf8) | ((x) >> 13))
154#define _RGB_UNPACK_GREEN(x) ((((x) >> 3) & 0xfc) | (((x) >> 9) & 0x03))
155#define _RGB_UNPACK_BLUE(x) ((((x) << 3) & 0xf8) | (((x) >> 2) & 0x07))
153#define _RGBPACK(r, g, b) ( ((((r) * (31*257) + (127*257)) >> 16) << 11) \ 156#define _RGBPACK(r, g, b) ( ((((r) * (31*257) + (127*257)) >> 16) << 11) \
154 |((((g) * (63*257) + (127*257)) >> 16) << 5) \ 157 |((((g) * (63*257) + (127*257)) >> 16) << 5) \
155 | (((b) * (31*257) + (127*257)) >> 16)) 158 | (((b) * (31*257) + (127*257)) >> 16))
@@ -158,8 +161,14 @@ typedef void lcd_fastpixelfunc_type(fb_data *address);
158#if (LCD_PIXELFORMAT == RGB565SWAPPED) 161#if (LCD_PIXELFORMAT == RGB565SWAPPED)
159#define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \ 162#define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \
160 |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8)) 163 |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8))
164#define RGB_UNPACK_RED(x) _RGB_UNPACK_RED(swap16(x))
165#define RGB_UNPACK_GREEN(x) _RGB_UNPACK_GREEN(swap16(x))
166#define RGB_UNPACK_BLUE(x) _RGB_UNPACK_BLUE(swap16(x))
161#else 167#else
162#define LCD_RGBPACK(r, g, b) _RGBPACK((r), (g), (b)) 168#define LCD_RGBPACK(r, g, b) _RGBPACK((r), (g), (b))
169#define RGB_UNPACK_RED(x) _RGB_UNPACK_RED(x)
170#define RGB_UNPACK_GREEN(x) _RGB_UNPACK_GREEN(x)
171#define RGB_UNPACK_BLUE(x) _RGB_UNPACK_BLUE(x)
163#endif 172#endif
164#elif LCD_DEPTH == 18 173#elif LCD_DEPTH == 18
165#define LCD_MAX_RED 63 174#define LCD_MAX_RED 63