summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c61
1 files changed, 59 insertions, 2 deletions
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}