summaryrefslogtreecommitdiff
path: root/apps/settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings.c')
-rw-r--r--apps/settings.c40
1 files changed, 25 insertions, 15 deletions
diff --git a/apps/settings.c b/apps/settings.c
index eed2b3a692..992cc1f391 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -146,7 +146,7 @@ static bool read_nvram_data(char* buf, int max_len)
146 buf[i] = rtc_read(0x14+i); 146 buf[i] = rtc_read(0x14+i);
147#endif 147#endif
148 /* check magic, version */ 148 /* check magic, version */
149 if ((buf[0] != 'R') || (buf[1] != 'b') 149 if ((buf[0] != 'R') || (buf[1] != 'b')
150 || (buf[2] != NVRAM_CONFIG_VERSION)) 150 || (buf[2] != NVRAM_CONFIG_VERSION))
151 return false; 151 return false;
152 /* check crc32 */ 152 /* check crc32 */
@@ -221,7 +221,7 @@ static bool write_nvram_data(char* buf, int max_len)
221 supports that, but this will have to do for now 8-) */ 221 supports that, but this will have to do for now 8-) */
222 for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) { 222 for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) {
223 int r = rtc_write(0x14+i, buf[i]); 223 int r = rtc_write(0x14+i, buf[i]);
224 if (r) 224 if (r)
225 return false; 225 return false;
226 } 226 }
227#endif 227#endif
@@ -307,8 +307,8 @@ bool settings_load_config(const char* file, bool apply)
307#ifdef HAVE_LCD_COLOR 307#ifdef HAVE_LCD_COLOR
308 if (settings[i].flags&F_RGB) 308 if (settings[i].flags&F_RGB)
309 hex_to_rgb(value, (int*)settings[i].setting); 309 hex_to_rgb(value, (int*)settings[i].setting);
310 else 310 else
311#endif 311#endif
312 if (settings[i].cfg_vals == NULL) 312 if (settings[i].cfg_vals == NULL)
313 { 313 {
314 *(int*)settings[i].setting = atoi(value); 314 *(int*)settings[i].setting = atoi(value);
@@ -392,7 +392,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
392 const char* start = settings[setting_id].cfg_vals; 392 const char* start = settings[setting_id].cfg_vals;
393 char* end = NULL; 393 char* end = NULL;
394 int count = 0; 394 int count = 0;
395 395
396 if ((flags&F_T_MASK)==F_T_INT && 396 if ((flags&F_T_MASK)==F_T_INT &&
397 flags&F_TABLE_SETTING) 397 flags&F_TABLE_SETTING)
398 { 398 {
@@ -404,7 +404,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
404 { 404 {
405 if (end == NULL) 405 if (end == NULL)
406 strlcpy(buf, start, buf_len); 406 strlcpy(buf, start, buf_len);
407 else 407 else
408 { 408 {
409 int len = (buf_len > (end-start))? end-start: buf_len; 409 int len = (buf_len > (end-start))? end-start: buf_len;
410 strlcpy(buf, start, len+1); 410 strlcpy(buf, start, len+1);
@@ -412,7 +412,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
412 return true; 412 return true;
413 } 413 }
414 count++; 414 count++;
415 415
416 if (end) 416 if (end)
417 start = end+1; 417 start = end+1;
418 else 418 else
@@ -420,7 +420,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
420 } 420 }
421 return false; 421 return false;
422 } 422 }
423 423
424 while (count < val) 424 while (count < val)
425 { 425 {
426 start = strchr(start,','); 426 start = strchr(start,',');
@@ -432,7 +432,7 @@ bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
432 end = strchr(start,','); 432 end = strchr(start,',');
433 if (end == NULL) 433 if (end == NULL)
434 strlcpy(buf, start, buf_len); 434 strlcpy(buf, start, buf_len);
435 else 435 else
436 { 436 {
437 int len = (buf_len > (end-start))? end-start: buf_len; 437 int len = (buf_len > (end-start))? end-start: buf_len;
438 strlcpy(buf, start, len+1); 438 strlcpy(buf, start, len+1);
@@ -561,7 +561,7 @@ static bool settings_write_config(const char* filename, int options)
561 value[0] = '\0'; 561 value[0] = '\0';
562 if (settings[i].flags & F_DEPRECATED) 562 if (settings[i].flags & F_DEPRECATED)
563 continue; 563 continue;
564 564
565 switch (options) 565 switch (options)
566 { 566 {
567 case SETTINGS_SAVE_CHANGED: 567 case SETTINGS_SAVE_CHANGED:
@@ -939,7 +939,7 @@ void settings_apply(bool read_disk)
939 && global_settings.font_file[0] != '-') { 939 && global_settings.font_file[0] != '-') {
940 int font_ui = screens[SCREEN_MAIN].getuifont(); 940 int font_ui = screens[SCREEN_MAIN].getuifont();
941 const char* loaded_font = font_filename(font_ui); 941 const char* loaded_font = font_filename(font_ui);
942 942
943 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt", 943 snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
944 global_settings.font_file); 944 global_settings.font_file);
945 if (!loaded_font || strcmp(loaded_font, buf)) 945 if (!loaded_font || strcmp(loaded_font, buf))
@@ -953,7 +953,7 @@ void settings_apply(bool read_disk)
953 screens[SCREEN_MAIN].setfont(rc); 953 screens[SCREEN_MAIN].setfont(rc);
954 } 954 }
955 } 955 }
956#ifdef HAVE_REMOTE_LCD 956#ifdef HAVE_REMOTE_LCD
957 if ( global_settings.remote_font_file[0] 957 if ( global_settings.remote_font_file[0]
958 && global_settings.remote_font_file[0] != '-') { 958 && global_settings.remote_font_file[0] != '-') {
959 int font_ui = screens[SCREEN_REMOTE].getuifont(); 959 int font_ui = screens[SCREEN_REMOTE].getuifont();
@@ -1064,17 +1064,27 @@ void settings_apply(bool read_disk)
1064 1064
1065#ifdef HAVE_BACKLIGHT 1065#ifdef HAVE_BACKLIGHT
1066 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress); 1066 set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
1067 set_selective_backlight_actions(global_settings.bl_selective_actions,
1068 global_settings.bl_selective_actions_mask,
1069 global_settings.bl_filter_first_keypress);
1067#ifdef HAVE_REMOTE_LCD 1070#ifdef HAVE_REMOTE_LCD
1068 set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress); 1071 set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
1069#endif 1072#endif
1070#ifdef HAS_BUTTON_HOLD 1073#ifdef HAS_BUTTON_HOLD
1071 backlight_set_on_button_hold(global_settings.backlight_on_button_hold); 1074 backlight_set_on_button_hold(global_settings.backlight_on_button_hold);
1072#endif 1075#endif
1076
1073#ifdef HAVE_LCD_SLEEP_SETTING 1077#ifdef HAVE_LCD_SLEEP_SETTING
1074 lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off); 1078 lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);
1075#endif 1079#endif
1076#endif /* HAVE_BACKLIGHT */ 1080#endif /* HAVE_BACKLIGHT */
1077 1081
1082#ifndef HAS_BUTTON_HOLD
1083 set_selective_softlock_actions(
1084 global_settings.bt_selective_softlock_actions,
1085 global_settings.bt_selective_softlock_actions_mask);
1086#endif
1087
1078#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING 1088#ifdef HAVE_TOUCHPAD_SENSITIVITY_SETTING
1079 touchpad_set_sensitivity(global_settings.touchpad_sensitivity); 1089 touchpad_set_sensitivity(global_settings.touchpad_sensitivity);
1080#endif 1090#endif
@@ -1243,7 +1253,7 @@ bool set_int_ex(const unsigned char* string,
1243 (void)unit; 1253 (void)unit;
1244 struct settings_list item; 1254 struct settings_list item;
1245 struct int_setting data = { 1255 struct int_setting data = {
1246 function, voice_unit, min, max, step, 1256 function, voice_unit, min, max, step,
1247 formatter, get_talk_id 1257 formatter, get_talk_id
1248 }; 1258 };
1249 item.int_setting = &data; 1259 item.int_setting = &data;
@@ -1269,7 +1279,7 @@ static int32_t set_option_get_talk_id(int value, int unit)
1269} 1279}
1270 1280
1271bool set_option(const char* string, const void* variable, enum optiontype type, 1281bool set_option(const char* string, const void* variable, enum optiontype type,
1272 const struct opt_items* options, 1282 const struct opt_items* options,
1273 int numoptions, void (*function)(int)) 1283 int numoptions, void (*function)(int))
1274{ 1284{
1275 int temp; 1285 int temp;
@@ -1287,7 +1297,7 @@ bool set_option(const char* string, const void* variable, enum optiontype type,
1287 item.setting = &temp; 1297 item.setting = &temp;
1288 if (type == BOOL) 1298 if (type == BOOL)
1289 temp = *(bool*)variable? 1: 0; 1299 temp = *(bool*)variable? 1: 0;
1290 else 1300 else
1291 temp = *(int*)variable; 1301 temp = *(int*)variable;
1292 if (!option_screen(&item, NULL, false, NULL)) 1302 if (!option_screen(&item, NULL, false, NULL))
1293 { 1303 {