New way of handling integer settings with variable steps: table settings (FS #8186, with fixes by me). This allows to get rid of those synchronised tables in firmware/ and apps/, making things more flexible and less error prone. First application: backlight timeouts. * Make some more things 'const'.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15803 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
54ecc698a5
commit
d490f44112
7 changed files with 223 additions and 121 deletions
|
@ -2009,8 +2009,7 @@ bool gui_wps_refresh(struct gui_wps *gwps,
|
|||
{
|
||||
/* turn on backlight n seconds before track ends, and turn it off n
|
||||
seconds into the new track. n == backlight_timeout, or 5s */
|
||||
int n = backlight_timeout_value[global_settings.backlight_timeout]
|
||||
* 1000;
|
||||
int n = global_settings.backlight_timeout * 1000;
|
||||
|
||||
if ( n < 1000 )
|
||||
n = 5000; /* use 5s if backlight is always on or off */
|
||||
|
@ -2027,8 +2026,7 @@ bool gui_wps_refresh(struct gui_wps *gwps,
|
|||
/* turn on remote backlight n seconds before track ends, and turn it
|
||||
off n seconds into the new track. n == remote_backlight_timeout,
|
||||
or 5s */
|
||||
int n = backlight_timeout_value[global_settings.remote_backlight_timeout]
|
||||
* 1000;
|
||||
int n = global_settings.remote_backlight_timeout * 1000;
|
||||
|
||||
if ( n < 1000 )
|
||||
n = 5000; /* use 5s if backlight is always on or off */
|
||||
|
|
|
@ -57,7 +57,9 @@ static const char *unit_strings[] =
|
|||
[UNIT_MB] = "MB", [UNIT_KBIT] = "kb/s",
|
||||
[UNIT_PM_TICK] = "units/10ms",
|
||||
};
|
||||
|
||||
/* these two vars are needed so arbitrary values can be added to the
|
||||
TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
|
||||
static int table_setting_oldval = 0, table_setting_array_position = 0;
|
||||
static char *option_get_valuestring(struct settings_list *setting,
|
||||
char *buffer, int buf_len,
|
||||
intptr_t temp_var)
|
||||
|
@ -77,16 +79,27 @@ static char *option_get_valuestring(struct settings_list *setting,
|
|||
(char*)temp_var, info->suffix);
|
||||
}
|
||||
#endif
|
||||
else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
|
||||
else if (((setting->flags & F_INT_SETTING) == F_INT_SETTING) ||
|
||||
((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING))
|
||||
{
|
||||
struct int_setting *info = setting->int_setting;
|
||||
if (info->formatter)
|
||||
info->formatter(buffer, buf_len, (int)temp_var,
|
||||
unit_strings[info->unit]);
|
||||
const struct int_setting *int_info = setting->int_setting;
|
||||
const struct table_setting *tbl_info = setting->table_setting;
|
||||
const char *unit;
|
||||
void (*formatter)(char*, size_t, int, const char*);
|
||||
if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
|
||||
{
|
||||
formatter = int_info->formatter;
|
||||
unit = unit_strings[int_info->unit];
|
||||
}
|
||||
else
|
||||
snprintf(buffer, buf_len, "%d %s", (int)temp_var,
|
||||
unit_strings[info->unit]?
|
||||
unit_strings[info->unit]:"");
|
||||
{
|
||||
formatter = tbl_info->formatter;
|
||||
unit = unit_strings[tbl_info->unit];
|
||||
}
|
||||
if (formatter)
|
||||
formatter(buffer, buf_len, (int)temp_var, unit);
|
||||
else
|
||||
snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:"");
|
||||
}
|
||||
else if ((setting->flags & F_T_SOUND) == F_T_SOUND)
|
||||
{
|
||||
|
@ -113,7 +126,7 @@ static char *option_get_valuestring(struct settings_list *setting,
|
|||
if (setting->flags & F_CHOICETALKS)
|
||||
{
|
||||
int setting_id;
|
||||
struct choice_setting *info = setting->choice_setting;
|
||||
const struct choice_setting *info = setting->choice_setting;
|
||||
if (info->talks[(int)temp_var] < LANG_LAST_INDEX_IN_ARRAY)
|
||||
{
|
||||
snprintf(buffer, buf_len, "%s", str(info->talks[(int)temp_var]));
|
||||
|
@ -149,13 +162,27 @@ static int option_talk(int selected_item, void * data)
|
|||
{
|
||||
}
|
||||
#endif
|
||||
else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
|
||||
else if (((setting->flags & F_INT_SETTING) == F_INT_SETTING) ||
|
||||
((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING))
|
||||
{
|
||||
struct int_setting *info = setting->int_setting;
|
||||
if (info->get_talk_id)
|
||||
talk_id(info->get_talk_id(temp_var), false);
|
||||
else
|
||||
talk_value(temp_var, info->unit, false);
|
||||
const struct int_setting *int_info = setting->int_setting;
|
||||
const struct table_setting *tbl_info = setting->table_setting;
|
||||
int unit;
|
||||
long (*get_talk_id)(int);
|
||||
if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
|
||||
{
|
||||
unit = int_info->unit;
|
||||
get_talk_id = int_info->get_talk_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
unit = tbl_info->unit;
|
||||
get_talk_id = tbl_info->get_talk_id;
|
||||
}
|
||||
if (get_talk_id)
|
||||
talk_id(get_talk_id((int)temp_var), false);
|
||||
else
|
||||
talk_value((int)temp_var, unit, false);
|
||||
}
|
||||
else if ((setting->flags & F_T_SOUND) == F_T_SOUND)
|
||||
{
|
||||
|
@ -261,6 +288,20 @@ static int selection_to_val(struct settings_list *setting, int selection)
|
|||
if (((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) ||
|
||||
((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING))
|
||||
return selection;
|
||||
else if ((setting->flags & F_TABLE_SETTING) == F_TABLE_SETTING)
|
||||
{
|
||||
const struct table_setting *info = setting->table_setting;
|
||||
if (setting->flags&F_ALLOW_ARBITRARY_VALS &&
|
||||
table_setting_array_position != -1 &&
|
||||
(selection >= table_setting_array_position))
|
||||
{
|
||||
if (selection == table_setting_array_position)
|
||||
return table_setting_oldval;
|
||||
return info->values[selection-1];
|
||||
}
|
||||
else
|
||||
return info->values[selection];
|
||||
}
|
||||
else if ((setting->flags & F_T_SOUND) == F_T_SOUND)
|
||||
{
|
||||
int setting_id = setting->sound_setting->setting;
|
||||
|
@ -276,7 +317,7 @@ static int selection_to_val(struct settings_list *setting, int selection)
|
|||
}
|
||||
else if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
|
||||
{
|
||||
struct int_setting *info = setting->int_setting;
|
||||
const struct int_setting *info = setting->int_setting;
|
||||
#ifndef ASCENDING_INT_SETTINGS
|
||||
min = info->min;
|
||||
max = info->max;
|
||||
|
@ -331,7 +372,7 @@ bool option_screen(struct settings_list *setting,
|
|||
temp_var = oldvalue = *(bool*)setting->setting?1:0;
|
||||
}
|
||||
else return false; /* only int/bools can go here */
|
||||
gui_synclist_init(&lists, value_setting_get_name_cb,
|
||||
gui_synclist_init(&lists, value_setting_get_name_cb,
|
||||
(void*)setting, false, 1);
|
||||
if (setting->lang_id == -1)
|
||||
title = (char*)setting->cfg_vals;
|
||||
|
@ -352,6 +393,28 @@ bool option_screen(struct settings_list *setting,
|
|||
selected = oldvalue;
|
||||
function = setting->choice_setting->option_callback;
|
||||
}
|
||||
else if (setting->flags&F_TABLE_SETTING)
|
||||
{
|
||||
const struct table_setting *info = setting->table_setting;
|
||||
int i;
|
||||
nb_items = info->count;
|
||||
selected = 0;
|
||||
table_setting_array_position = -1;
|
||||
for (i=0;selected==0 && i<nb_items;i++)
|
||||
{
|
||||
if (setting->flags&F_ALLOW_ARBITRARY_VALS &&
|
||||
(oldvalue < info->values[i]))
|
||||
{
|
||||
table_setting_oldval = oldvalue;
|
||||
table_setting_array_position = i;
|
||||
selected = i;
|
||||
nb_items++;
|
||||
}
|
||||
else if (oldvalue == info->values[i])
|
||||
selected = i;
|
||||
}
|
||||
function = info->option_callback;
|
||||
}
|
||||
else if (setting->flags&F_T_SOUND)
|
||||
{
|
||||
int setting_id = setting->sound_setting->setting;
|
||||
|
@ -368,7 +431,7 @@ bool option_screen(struct settings_list *setting,
|
|||
}
|
||||
else
|
||||
{
|
||||
struct int_setting *info = setting->int_setting;
|
||||
const struct int_setting *info = setting->int_setting;
|
||||
int min, max, step;
|
||||
max = info->max;
|
||||
min = info->min;
|
||||
|
@ -390,7 +453,6 @@ bool option_screen(struct settings_list *setting,
|
|||
if (boolfunction)
|
||||
function = bool_funcwrapper;
|
||||
}
|
||||
|
||||
gui_synclist_set_nb_items(&lists, nb_items);
|
||||
gui_synclist_select_item(&lists, selected);
|
||||
|
||||
|
|
|
@ -299,7 +299,17 @@ bool settings_load_config(const char* file, bool apply)
|
|||
}
|
||||
else
|
||||
{
|
||||
cfg_string_to_int(i,(int*)settings[i].setting,value);
|
||||
int temp, *v = (int*)settings[i].setting;
|
||||
bool found = cfg_string_to_int(i, &temp, value);
|
||||
if (found)
|
||||
{
|
||||
if (settings[i].flags&F_TABLE_SETTING)
|
||||
*v = settings[i].table_setting->values[temp];
|
||||
else
|
||||
*v = temp;
|
||||
}
|
||||
else
|
||||
*v = atoi(value);
|
||||
}
|
||||
break;
|
||||
case F_T_BOOL:
|
||||
|
@ -353,9 +363,40 @@ bool settings_load_config(const char* file, bool apply)
|
|||
|
||||
bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
|
||||
{
|
||||
int flags = settings[setting_id].flags;
|
||||
const char* start = settings[setting_id].cfg_vals;
|
||||
char* end = NULL;
|
||||
int count = 0;
|
||||
|
||||
if ((flags&F_T_MASK)==F_T_INT &&
|
||||
flags&F_TABLE_SETTING)
|
||||
{
|
||||
const int *value = settings[setting_id].table_setting->values;
|
||||
while (start)
|
||||
{
|
||||
end = strchr(start,',');
|
||||
if (value[count] == val)
|
||||
{
|
||||
if (end == NULL)
|
||||
strncpy(buf, start, buf_len);
|
||||
else
|
||||
{
|
||||
int len = (buf_len > (end-start))? end-start: buf_len;
|
||||
strncpy(buf, start, len);
|
||||
buf[len] = '\0';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
count++;
|
||||
|
||||
if (end)
|
||||
start = end+1;
|
||||
else
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
while (count < val)
|
||||
{
|
||||
start = strchr(start,',');
|
||||
|
@ -457,8 +498,11 @@ static bool settings_write_config(char* filename, int options)
|
|||
}
|
||||
else
|
||||
{
|
||||
cfg_int_to_string(i, *(int*)settings[i].setting,
|
||||
value, MAX_PATH);
|
||||
if (cfg_int_to_string(i, *(int*)settings[i].setting,
|
||||
value, MAX_PATH) == false)
|
||||
{
|
||||
snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case F_T_BOOL:
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "system.h"
|
||||
#include "ata.h"
|
||||
#include "lang.h"
|
||||
#include "talk.h"
|
||||
|
@ -103,7 +104,7 @@
|
|||
#define FILENAME_SETTING(flags,var,name,default,prefix,suffix,len) \
|
||||
{flags|F_T_UCHARPTR, &global_settings.var,-1, \
|
||||
CHARPTR(default),name,NULL, \
|
||||
{.filename_setting= \
|
||||
{.filename_setting= \
|
||||
(struct filename_setting[]){{prefix,suffix,len}}} }
|
||||
|
||||
/* Used for settings which use the set_option() setting screen.
|
||||
|
@ -111,18 +112,18 @@
|
|||
These can either be literal strings, or ID2P(LANG_*) */
|
||||
#define CHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \
|
||||
{flags|F_CHOICE_SETTING|F_T_INT, &global_settings.var, lang_id, \
|
||||
INT(default), name, cfg_vals, \
|
||||
{.choice_setting = (struct choice_setting[]){ \
|
||||
{cb, count, {.desc = (unsigned char*[]){__VA_ARGS__}}}}}}
|
||||
INT(default), name, cfg_vals, \
|
||||
{.choice_setting = (struct choice_setting[]){ \
|
||||
{cb, count, {.desc = (const unsigned char*[]){__VA_ARGS__}}}}}}
|
||||
|
||||
/* Similar to above, except the strings to display are taken from cfg_vals,
|
||||
the ... arg is a list of ID's to talk for the strings... can use TALK_ID()'s */
|
||||
#define STRINGCHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \
|
||||
{flags|F_CHOICE_SETTING|F_T_INT|F_CHOICETALKS, \
|
||||
&global_settings.var, lang_id, \
|
||||
INT(default), name, cfg_vals, \
|
||||
{.choice_setting = (struct choice_setting[]){ \
|
||||
{cb, count, {.talks = (int[]){__VA_ARGS__}}}}}}
|
||||
{flags|F_CHOICE_SETTING|F_T_INT|F_CHOICETALKS, \
|
||||
&global_settings.var, lang_id, \
|
||||
INT(default), name, cfg_vals, \
|
||||
{.choice_setting = (struct choice_setting[]){ \
|
||||
{cb, count, {.talks = (const int[]){__VA_ARGS__}}}}}}
|
||||
|
||||
/* for settings which use the set_int() setting screen.
|
||||
unit is the UNIT_ define to display/talk.
|
||||
|
@ -134,14 +135,20 @@
|
|||
lang_id, INT(default), name, cfg_vals, \
|
||||
{.int_setting = (struct int_setting[]){ \
|
||||
{cb, unit, min, max, step, formatter, get_talk_id}}}}
|
||||
#define INT_SETTING(flags, var, lang_id, default, name, \
|
||||
unit, min, max, step, formatter, get_talk_id, cb) \
|
||||
#define INT_SETTING(flags, var, lang_id, default, name, \
|
||||
unit, min, max, step, formatter, get_talk_id, cb) \
|
||||
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
|
||||
lang_id, INT(default), name, NULL, \
|
||||
lang_id, INT(default), name, NULL, \
|
||||
{.int_setting = (struct int_setting[]){ \
|
||||
{cb, unit, min, max, step, formatter, get_talk_id}}}}
|
||||
|
||||
|
||||
#define TABLE_SETTING(flags, var, lang_id, default, name, cfg_vals, \
|
||||
unit, formatter, get_talk_id, cb, count, ...) \
|
||||
{flags|F_TABLE_SETTING|F_T_INT, &global_settings.var, \
|
||||
lang_id, INT(default), name, cfg_vals, \
|
||||
{.table_setting = (struct table_setting[]) { \
|
||||
{cb, formatter, get_talk_id, unit, count, \
|
||||
(const int[]){__VA_ARGS__}}}}}
|
||||
|
||||
/* some sets of values which are used more than once, to save memory */
|
||||
static const char off_on[] = "off,on";
|
||||
|
@ -204,26 +211,24 @@ static void rectime_formatter(char *buffer, size_t buffer_size,
|
|||
#endif /* HAVE_RECORDING */
|
||||
|
||||
#ifdef HAVE_BACKLIGHT
|
||||
static const char backlight_times_conf [] =
|
||||
"off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90";
|
||||
static void backlight_formatter(char *buffer, size_t buffer_size,
|
||||
static void backlight_formatter(char *buffer, size_t buffer_size,
|
||||
int val, const char *unit)
|
||||
{
|
||||
(void)unit;
|
||||
if (val == 0)
|
||||
if (val == -1)
|
||||
strcpy(buffer, str(LANG_OFF));
|
||||
else if (val == 1)
|
||||
else if (val == 0)
|
||||
strcpy(buffer, str(LANG_ON));
|
||||
else
|
||||
snprintf(buffer, buffer_size, "%d s", backlight_timeout_value[val]);
|
||||
snprintf(buffer, buffer_size, "%d s", val);
|
||||
}
|
||||
static int32_t backlight_getlang(int value)
|
||||
{
|
||||
if (value == 0)
|
||||
if (value == -1)
|
||||
return LANG_OFF;
|
||||
else if (value == 1)
|
||||
else if (value == 0)
|
||||
return LANG_ON;
|
||||
return TALK_ID(backlight_timeout_value[value], UNIT_SEC);
|
||||
return TALK_ID(value, UNIT_SEC);
|
||||
}
|
||||
#endif
|
||||
/* ffwd/rewind and scan acceleration stuff */
|
||||
|
@ -424,16 +429,17 @@ const struct settings_list settings[] = {
|
|||
MAX_CONTRAST_SETTING, 1, NULL, NULL}}}},
|
||||
#endif
|
||||
#ifdef HAVE_BACKLIGHT
|
||||
INT_SETTING_W_CFGVALS(0, backlight_timeout, LANG_BACKLIGHT, 6,
|
||||
"backlight timeout", backlight_times_conf, UNIT_SEC,
|
||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
backlight_set_timeout),
|
||||
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, backlight_timeout, LANG_BACKLIGHT, 5,
|
||||
"backlight timeout", off_on, UNIT_SEC, backlight_formatter,
|
||||
backlight_getlang, backlight_set_timeout, 20,
|
||||
-1,0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,120),
|
||||
#if CONFIG_CHARGING
|
||||
INT_SETTING_W_CFGVALS(0, backlight_timeout_plugged,
|
||||
LANG_BACKLIGHT_ON_WHEN_CHARGING, 11,
|
||||
"backlight timeout plugged", backlight_times_conf, UNIT_SEC,
|
||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
backlight_set_timeout_plugged),
|
||||
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, backlight_timeout_plugged,
|
||||
LANG_BACKLIGHT_ON_WHEN_CHARGING, 10,
|
||||
"backlight timeout plugged", off_on, UNIT_SEC,
|
||||
backlight_formatter, backlight_getlang,
|
||||
backlight_set_timeout_plugged, 20,
|
||||
-1,0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,120),
|
||||
#endif
|
||||
#endif /* HAVE_BACKLIGHT */
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
|
@ -527,16 +533,17 @@ const struct settings_list settings[] = {
|
|||
LANG_INVERT_LCD_INVERSE, LANG_NORMAL, lcd_remote_set_invert_display),
|
||||
OFFON_SETTING(0,remote_flip_display, LANG_FLIP_DISPLAY,
|
||||
false,"remote flip display", NULL),
|
||||
INT_SETTING_W_CFGVALS(0, remote_backlight_timeout, LANG_BACKLIGHT, 6,
|
||||
"remote backlight timeout", backlight_times_conf, UNIT_SEC,
|
||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
remote_backlight_set_timeout),
|
||||
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, remote_backlight_timeout,
|
||||
LANG_BACKLIGHT, 5, "remote backlight timeout", off_on,
|
||||
UNIT_SEC, backlight_formatter, backlight_getlang,
|
||||
remote_backlight_set_timeout, 20,
|
||||
-1,0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,120),
|
||||
#if CONFIG_CHARGING
|
||||
INT_SETTING_W_CFGVALS(0, remote_backlight_timeout_plugged,
|
||||
LANG_BACKLIGHT_ON_WHEN_CHARGING, 11,
|
||||
"remote backlight timeout plugged", backlight_times_conf, UNIT_SEC,
|
||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
remote_backlight_set_timeout_plugged),
|
||||
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, remote_backlight_timeout_plugged,
|
||||
LANG_BACKLIGHT, 10, "remote backlight timeout plugged",
|
||||
off_on, UNIT_SEC, backlight_formatter, backlight_getlang,
|
||||
remote_backlight_set_timeout_plugged, 20,
|
||||
-1,0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,120),
|
||||
#endif
|
||||
#ifdef HAVE_REMOTE_LCD_TICKING
|
||||
OFFON_SETTING(0,remote_reduce_ticking, LANG_REDUCE_TICKING,
|
||||
|
@ -1196,11 +1203,11 @@ const struct settings_list settings[] = {
|
|||
THEME_DIR "/", ".colours", MAX_FILENAME+1),
|
||||
#endif
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
INT_SETTING_W_CFGVALS(0, buttonlight_timeout,
|
||||
LANG_BUTTONLIGHT_TIMEOUT, 6,
|
||||
"button light timeout", backlight_times_conf, UNIT_SEC,
|
||||
0, 18, 1, backlight_formatter, backlight_getlang,
|
||||
buttonlight_set_timeout),
|
||||
TABLE_SETTING(F_ALLOW_ARBITRARY_VALS, buttonlight_timeout,
|
||||
LANG_BUTTONLIGHT_TIMEOUT, 5, "button light timeout", off_on,
|
||||
UNIT_SEC, backlight_formatter, backlight_getlang,
|
||||
buttonlight_set_timeout, 20,
|
||||
-1,0,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,120),
|
||||
#endif
|
||||
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
INT_SETTING(0, buttonlight_brightness, LANG_BUTTONLIGHT_BRIGHTNESS, DEFAULT_BRIGHTNESS_SETTING,
|
||||
|
|
|
@ -78,13 +78,24 @@ struct choice_setting {
|
|||
void (*option_callback)(int);
|
||||
int count;
|
||||
union {
|
||||
unsigned char **desc;
|
||||
int *talks;
|
||||
const unsigned char **desc;
|
||||
const int *talks;
|
||||
};
|
||||
};
|
||||
#define F_CHOICE_SETTING 0x100
|
||||
#define F_CHOICETALKS 0x200 /* uses .talks in the above struct for the talks */
|
||||
/* and cfg_vals for the strings to display */
|
||||
|
||||
struct table_setting {
|
||||
void (*option_callback)(int);
|
||||
void (*formatter)(char*, size_t, int, const char*);
|
||||
long (*get_talk_id)(int);
|
||||
int unit;
|
||||
int count;
|
||||
const int * values;
|
||||
};
|
||||
#define F_TABLE_SETTING 0x2000
|
||||
#define F_ALLOW_ARBITRARY_VALS 0x4000
|
||||
/* these use the _isfunc_type type for the function */
|
||||
/* typedef int (*_isfunc_type)(void); */
|
||||
#define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */
|
||||
|
@ -94,8 +105,8 @@ struct choice_setting {
|
|||
#define F_THEMESETTING 0x0800000
|
||||
#define F_RECSETTING 0x1000000
|
||||
|
||||
#define F_NVRAM_BYTES_MASK 0xE000 /*0-4 bytes can be stored */
|
||||
#define F_NVRAM_MASK_SHIFT 13
|
||||
#define F_NVRAM_BYTES_MASK 0xE0000 /*0-4 bytes can be stored */
|
||||
#define F_NVRAM_MASK_SHIFT 17
|
||||
#define NVRAM_CONFIG_VERSION 4
|
||||
/* Above define should be bumped if
|
||||
- a new NVRAM setting is added between 2 other NVRAM settings
|
||||
|
@ -107,7 +118,7 @@ struct choice_setting {
|
|||
#define F_NO_WRAP 0x1000 /* used if the list should not wrap */
|
||||
|
||||
struct settings_list {
|
||||
uint32_t flags; /* ____ ___R TFFF ____ NNN_ PTVC IFRB STTT */
|
||||
uint32_t flags; /* ____ ___R TFFF NNN_ _ATW PTVC IFRB STTT */
|
||||
void *setting;
|
||||
int lang_id; /* -1 for none */
|
||||
union storage_type default_val;
|
||||
|
@ -115,12 +126,13 @@ struct settings_list {
|
|||
const char *cfg_vals; /*comma seperated legal values, or NULL */
|
||||
/* used with F_T_UCHARPTR this is the folder prefix */
|
||||
union {
|
||||
void *RESERVED; /* to stop compile errors, will be removed */
|
||||
struct sound_setting *sound_setting; /* use F_T_SOUND for this */
|
||||
struct bool_setting *bool_setting; /* F_BOOL_SETTING */
|
||||
struct filename_setting *filename_setting; /* use F_FILENAME */
|
||||
struct int_setting *int_setting; /* use F_INT_SETTING */
|
||||
struct choice_setting *choice_setting; /* F_CHOICE_SETTING */
|
||||
const void *RESERVED; /* to stop compile errors, will be removed */
|
||||
const struct sound_setting *sound_setting; /* use F_T_SOUND for this */
|
||||
const struct bool_setting *bool_setting; /* F_BOOL_SETTING */
|
||||
const struct filename_setting *filename_setting; /* use F_FILENAME */
|
||||
const struct int_setting *int_setting; /* use F_INT_SETTING */
|
||||
const struct choice_setting *choice_setting; /* F_CHOICE_SETTING */
|
||||
const struct table_setting *table_setting; /* F_TABLE_SETTING */
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -89,11 +89,6 @@ static inline void _remote_backlight_off(void)
|
|||
|
||||
#if defined(HAVE_BACKLIGHT) && !defined(BOOTLOADER)
|
||||
|
||||
const signed char backlight_timeout_value[19] =
|
||||
{
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 45, 60, 90
|
||||
};
|
||||
|
||||
enum {
|
||||
BACKLIGHT_ON,
|
||||
BACKLIGHT_OFF,
|
||||
|
@ -159,12 +154,9 @@ void buttonlight_off(void)
|
|||
queue_post(&backlight_queue, BUTTON_LIGHT_OFF, 0);
|
||||
}
|
||||
|
||||
void buttonlight_set_timeout(int index)
|
||||
void buttonlight_set_timeout(int value)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index = 6;
|
||||
_buttonlight_timeout = HZ * backlight_timeout_value[index];
|
||||
_buttonlight_timeout = HZ * value;
|
||||
buttonlight_update_state();
|
||||
}
|
||||
|
||||
|
@ -638,22 +630,16 @@ int backlight_get_current_timeout(void)
|
|||
return backlight_timeout;
|
||||
}
|
||||
|
||||
void backlight_set_timeout(int index)
|
||||
void backlight_set_timeout(int value)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index = 6;
|
||||
backlight_timeout_normal = HZ * backlight_timeout_value[index];
|
||||
backlight_timeout_normal = HZ * value;
|
||||
backlight_update_state();
|
||||
}
|
||||
|
||||
#if CONFIG_CHARGING
|
||||
void backlight_set_timeout_plugged(int index)
|
||||
void backlight_set_timeout_plugged(int value)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index = 6;
|
||||
backlight_timeout_plugged = HZ * backlight_timeout_value[index];
|
||||
backlight_timeout_plugged = HZ * value;
|
||||
backlight_update_state();
|
||||
}
|
||||
#endif /* CONFIG_CHARGING */
|
||||
|
@ -710,22 +696,16 @@ void remote_backlight_off(void)
|
|||
queue_post(&backlight_queue, REMOTE_BACKLIGHT_OFF, 0);
|
||||
}
|
||||
|
||||
void remote_backlight_set_timeout(int index)
|
||||
void remote_backlight_set_timeout(int value)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index=6;
|
||||
remote_backlight_timeout_normal = HZ * backlight_timeout_value[index];
|
||||
remote_backlight_timeout_normal = HZ * value;
|
||||
remote_backlight_update_state();
|
||||
}
|
||||
|
||||
#if CONFIG_CHARGING
|
||||
void remote_backlight_set_timeout_plugged(int index)
|
||||
void remote_backlight_set_timeout_plugged(int value)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use default */
|
||||
index=6;
|
||||
remote_backlight_timeout_plugged = HZ * backlight_timeout_value[index];
|
||||
remote_backlight_timeout_plugged = HZ * value;
|
||||
remote_backlight_update_state();
|
||||
}
|
||||
#endif /* CONFIG_CHARGING */
|
||||
|
@ -805,12 +785,12 @@ void backlight_init(void)
|
|||
void backlight_on(void) {}
|
||||
void backlight_off(void) {}
|
||||
void buttonlight_on(void) {}
|
||||
void backlight_set_timeout(int index) {(void)index;}
|
||||
void backlight_set_timeout(int value) {(void)value;}
|
||||
bool is_backlight_on(void) {return true;}
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void remote_backlight_on(void) {}
|
||||
void remote_backlight_off(void) {}
|
||||
void remote_backlight_set_timeout(int index) {(void)index;}
|
||||
void remote_backlight_set_timeout(int value) {(void)value;}
|
||||
bool is_remote_backlight_on(void) {return true;}
|
||||
#endif /* HAVE_REMOTE_LCD */
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
bool is_backlight_on(void);
|
||||
void backlight_on(void);
|
||||
void backlight_off(void);
|
||||
void backlight_set_timeout(int index);
|
||||
void backlight_set_timeout(int value);
|
||||
|
||||
#ifdef HAVE_BACKLIGHT
|
||||
void backlight_init(void);
|
||||
|
@ -36,8 +36,7 @@ void backlight_set_fade_in(int index);
|
|||
void backlight_set_fade_out(int index);
|
||||
#endif
|
||||
|
||||
void backlight_set_timeout_plugged(int index);
|
||||
extern const signed char backlight_timeout_value[];
|
||||
void backlight_set_timeout_plugged(int value);
|
||||
|
||||
#ifdef HAS_BUTTON_HOLD
|
||||
void backlight_hold_changed(bool hold_button);
|
||||
|
@ -56,8 +55,8 @@ extern const signed char lcd_sleep_timeout_value[];
|
|||
#ifdef HAVE_REMOTE_LCD
|
||||
void remote_backlight_on(void);
|
||||
void remote_backlight_off(void);
|
||||
void remote_backlight_set_timeout(int index);
|
||||
void remote_backlight_set_timeout_plugged(int index);
|
||||
void remote_backlight_set_timeout(int value);
|
||||
void remote_backlight_set_timeout_plugged(int value);
|
||||
bool is_remote_backlight_on(void);
|
||||
|
||||
#ifdef HAS_REMOTE_BUTTON_HOLD
|
||||
|
@ -82,7 +81,7 @@ void buttonlight_set_brightness(int val);
|
|||
#ifdef HAVE_BUTTON_LIGHT
|
||||
void buttonlight_on(void);
|
||||
void buttonlight_off(void);
|
||||
void buttonlight_set_timeout(int index);
|
||||
void buttonlight_set_timeout(int value);
|
||||
#endif
|
||||
|
||||
/* Private API for use in target tree backlight code only */
|
||||
|
|
Loading…
Reference in a new issue