diff options
Diffstat (limited to 'apps/settings.c')
-rw-r--r-- | apps/settings.c | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/apps/settings.c b/apps/settings.c index ad812076a9..ebde692896 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -72,6 +72,7 @@ | |||
72 | #include "statusbar.h" | 72 | #include "statusbar.h" |
73 | #include "splash.h" | 73 | #include "splash.h" |
74 | #include "list.h" | 74 | #include "list.h" |
75 | #include "backdrop.h" | ||
75 | 76 | ||
76 | #if CONFIG_CODEC == MAS3507D | 77 | #if CONFIG_CODEC == MAS3507D |
77 | void dac_line_in(bool enable); | 78 | void dac_line_in(bool enable); |
@@ -149,7 +150,10 @@ Rest of config block, only saved to disk: | |||
149 | 0xB8 (char[20]) WPS file | 150 | 0xB8 (char[20]) WPS file |
150 | 0xCC (char[20]) Lang file | 151 | 0xCC (char[20]) Lang file |
151 | 0xE0 (char[20]) Font file | 152 | 0xE0 (char[20]) Font file |
152 | 0xF4-0xFF <unused> | 153 | ... (char[20]) RWPS file (on targets supporting a Remote WPS) |
154 | ... (char[20]) Main backdrop file (on color LCD targets) | ||
155 | |||
156 | ... to 0x200 <unused> | ||
153 | 157 | ||
154 | *************************************/ | 158 | *************************************/ |
155 | 159 | ||
@@ -771,6 +775,8 @@ void settings_calc_config_sector(void) | |||
771 | */ | 775 | */ |
772 | int settings_save( void ) | 776 | int settings_save( void ) |
773 | { | 777 | { |
778 | int i; | ||
779 | |||
774 | { | 780 | { |
775 | int elapsed_secs; | 781 | int elapsed_secs; |
776 | 782 | ||
@@ -786,15 +792,25 @@ int settings_save( void ) | |||
786 | save_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8); | 792 | save_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8); |
787 | save_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8); | 793 | save_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8); |
788 | 794 | ||
789 | strncpy((char *)&config_block[0xb8], (char *)global_settings.wps_file, | 795 | i = 0xb8; |
796 | strncpy((char *)&config_block[i], (char *)global_settings.wps_file, | ||
790 | MAX_FILENAME); | 797 | MAX_FILENAME); |
791 | strncpy((char *)&config_block[0xcc], (char *)global_settings.lang_file, | 798 | i+= MAX_FILENAME; |
799 | strncpy((char *)&config_block[i], (char *)global_settings.lang_file, | ||
792 | MAX_FILENAME); | 800 | MAX_FILENAME); |
793 | strncpy((char *)&config_block[0xe0], (char *)global_settings.font_file, | 801 | i+= MAX_FILENAME; |
802 | strncpy((char *)&config_block[i], (char *)global_settings.font_file, | ||
794 | MAX_FILENAME); | 803 | MAX_FILENAME); |
804 | i+= MAX_FILENAME; | ||
795 | #ifdef HAVE_REMOTE_LCD | 805 | #ifdef HAVE_REMOTE_LCD |
796 | strncpy((char *)&config_block[0xf4], (char *)global_settings.rwps_file, | 806 | strncpy((char *)&config_block[i], (char *)global_settings.rwps_file, |
807 | MAX_FILENAME); | ||
808 | i+= MAX_FILENAME; | ||
809 | #endif | ||
810 | #ifdef HAVE_LCD_COLOR | ||
811 | strncpy((char *)&config_block[i], (char *)global_settings.backdrop_file, | ||
797 | MAX_FILENAME); | 812 | MAX_FILENAME); |
813 | i+= MAX_FILENAME; | ||
798 | #endif | 814 | #endif |
799 | 815 | ||
800 | if(save_config_buffer()) | 816 | if(save_config_buffer()) |
@@ -945,6 +961,18 @@ void settings_apply(void) | |||
945 | else | 961 | else |
946 | wps_data_init(gui_wps[0].data); | 962 | wps_data_init(gui_wps[0].data); |
947 | 963 | ||
964 | #ifdef HAVE_LCD_COLOR | ||
965 | if ( global_settings.backdrop_file[0] && | ||
966 | global_settings.backdrop_file[0] != 0xff ) { | ||
967 | snprintf(buf, sizeof buf, BACKDROP_DIR "/%s.bmp", | ||
968 | global_settings.backdrop_file); | ||
969 | |||
970 | load_main_backdrop(buf); | ||
971 | } else { | ||
972 | lcd_set_backdrop(NULL); | ||
973 | } | ||
974 | #endif | ||
975 | |||
948 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) | 976 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
949 | if ( global_settings.rwps_file[0] && | 977 | if ( global_settings.rwps_file[0] && |
950 | global_settings.rwps_file[0] != 0xff ) { | 978 | global_settings.rwps_file[0] != 0xff ) { |
@@ -1056,6 +1084,7 @@ static void load_bit_table(const struct bit_entry* p_table, int count, int bitst | |||
1056 | */ | 1084 | */ |
1057 | void settings_load(int which) | 1085 | void settings_load(int which) |
1058 | { | 1086 | { |
1087 | int i; | ||
1059 | DEBUGF( "reload_all_settings()\n" ); | 1088 | DEBUGF( "reload_all_settings()\n" ); |
1060 | 1089 | ||
1061 | /* load the buffer from the RTC (resets it to all-unused if the block | 1090 | /* load the buffer from the RTC (resets it to all-unused if the block |
@@ -1076,15 +1105,25 @@ void settings_load(int which) | |||
1076 | if ( global_settings.contrast < MIN_CONTRAST_SETTING ) | 1105 | if ( global_settings.contrast < MIN_CONTRAST_SETTING ) |
1077 | global_settings.contrast = lcd_default_contrast(); | 1106 | global_settings.contrast = lcd_default_contrast(); |
1078 | 1107 | ||
1079 | strncpy((char *)global_settings.wps_file, (char *)&config_block[0xb8], | 1108 | i = 0xb8; |
1109 | strncpy((char *)global_settings.wps_file, (char *)&config_block[i], | ||
1080 | MAX_FILENAME); | 1110 | MAX_FILENAME); |
1081 | strncpy((char *)global_settings.lang_file, (char *)&config_block[0xcc], | 1111 | i+= MAX_FILENAME; |
1112 | strncpy((char *)global_settings.lang_file, (char *)&config_block[i], | ||
1082 | MAX_FILENAME); | 1113 | MAX_FILENAME); |
1083 | strncpy((char *)global_settings.font_file, (char *)&config_block[0xe0], | 1114 | i+= MAX_FILENAME; |
1115 | strncpy((char *)global_settings.font_file, (char *)&config_block[i], | ||
1084 | MAX_FILENAME); | 1116 | MAX_FILENAME); |
1117 | i+= MAX_FILENAME; | ||
1085 | #ifdef HAVE_REMOTE_LCD | 1118 | #ifdef HAVE_REMOTE_LCD |
1086 | strncpy((char *)global_settings.rwps_file, (char *)&config_block[0xf4], | 1119 | strncpy((char *)global_settings.rwps_file, (char *)&config_block[i], |
1120 | MAX_FILENAME); | ||
1121 | i+= MAX_FILENAME; | ||
1122 | #endif | ||
1123 | #ifdef HAVE_LCD_COLOR | ||
1124 | strncpy((char *)global_settings.backdrop_file, (char *)&config_block[i], | ||
1087 | MAX_FILENAME); | 1125 | MAX_FILENAME); |
1126 | i+= MAX_FILENAME; | ||
1088 | #endif | 1127 | #endif |
1089 | } | 1128 | } |
1090 | } | 1129 | } |
@@ -1246,6 +1285,13 @@ bool settings_load_config(const char* file) | |||
1246 | set_file(value, (char *)global_settings.font_file, MAX_FILENAME); | 1285 | set_file(value, (char *)global_settings.font_file, MAX_FILENAME); |
1247 | } | 1286 | } |
1248 | #endif | 1287 | #endif |
1288 | #ifdef HAVE_LCD_COLOR | ||
1289 | else if (!strcasecmp(name, "backdrop")) { | ||
1290 | if (load_main_backdrop(value)) | ||
1291 | set_file(value, (char *)global_settings.backdrop_file, MAX_FILENAME); | ||
1292 | } | ||
1293 | #endif | ||
1294 | |||
1249 | 1295 | ||
1250 | /* check for scalar values, using the two tables */ | 1296 | /* check for scalar values, using the two tables */ |
1251 | pos = load_cfg_table(table[last_table], ta_size[last_table], | 1297 | pos = load_cfg_table(table[last_table], ta_size[last_table], |
@@ -1388,6 +1434,12 @@ bool settings_save_config(void) | |||
1388 | global_settings.font_file); | 1434 | global_settings.font_file); |
1389 | #endif | 1435 | #endif |
1390 | 1436 | ||
1437 | #ifdef HAVE_LCD_COLOR | ||
1438 | if (global_settings.backdrop_file[0] != 0) | ||
1439 | fdprintf(fd, "backdrop: %s/%s.bmp\r\n", BACKDROP_DIR, | ||
1440 | global_settings.backdrop_file); | ||
1441 | #endif | ||
1442 | |||
1391 | /* here's the action: write values to file, specified via table */ | 1443 | /* here's the action: write values to file, specified via table */ |
1392 | save_cfg_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), fd); | 1444 | save_cfg_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), fd); |
1393 | save_cfg_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), fd); | 1445 | save_cfg_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), fd); |
@@ -1465,6 +1517,9 @@ void settings_reset(void) { | |||
1465 | #endif | 1517 | #endif |
1466 | global_settings.font_file[0] = '\0'; | 1518 | global_settings.font_file[0] = '\0'; |
1467 | global_settings.lang_file[0] = '\0'; | 1519 | global_settings.lang_file[0] = '\0'; |
1520 | #ifdef HAVE_LCD_COLOR | ||
1521 | global_settings.backdrop_file[0] = '\0'; | ||
1522 | #endif | ||
1468 | 1523 | ||
1469 | } | 1524 | } |
1470 | 1525 | ||