summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-11-13 21:32:59 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2022-11-20 13:57:09 -0500
commit0661784469c7e903528c1820f94a67c6de69a77f (patch)
tree616111a7ba5bbae9985d157ed3bebcc8317a4f25
parentb7603adc644a0bdf76f3045e69728ca863dc9791 (diff)
downloadrockbox-0661784469c7e903528c1820f94a67c6de69a77f.tar.gz
rockbox-0661784469c7e903528c1820f94a67c6de69a77f.zip
make int_setting step & unit int16_t
since int_setting is the largest struct in the union of settings saving 32 bytes adds up over every setting frees ~200 bytes Change-Id: Id4722262e40db3021c740e138fe7352be10e2c70
-rw-r--r--apps/menus/eq_menu.c6
-rw-r--r--apps/menus/sound_menu.c18
-rw-r--r--apps/settings.c22
-rw-r--r--apps/settings_list.c10
-rw-r--r--apps/settings_list.h5
5 files changed, 38 insertions, 23 deletions
diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c
index a0b00644ec..fd9f484047 100644
--- a/apps/menus/eq_menu.c
+++ b/apps/menus/eq_menu.c
@@ -154,9 +154,9 @@ static int32_t get_dec_talkid(int value, int unit)
static const struct int_setting gain_int_setting = {
.option_callback = NULL,
.unit = UNIT_DB,
+ .step = EQ_GAIN_STEP,
.min = EQ_GAIN_MIN,
.max = EQ_GAIN_MAX,
- .step = EQ_GAIN_STEP,
.formatter = db_format,
.get_talk_id = get_dec_talkid,
};
@@ -164,9 +164,9 @@ static const struct int_setting gain_int_setting = {
static const struct int_setting q_int_setting = {
.option_callback = NULL,
.unit = UNIT_INT,
+ .step = EQ_Q_STEP,
.min = EQ_Q_MIN,
.max = EQ_Q_MAX,
- .step = EQ_Q_STEP,
.formatter = eq_q_format,
.get_talk_id = get_dec_talkid,
};
@@ -174,9 +174,9 @@ static const struct int_setting q_int_setting = {
static const struct int_setting cutoff_int_setting = {
.option_callback = NULL,
.unit = UNIT_HERTZ,
+ .step = EQ_CUTOFF_STEP,
.min = EQ_CUTOFF_MIN,
.max = EQ_CUTOFF_MAX,
- .step = EQ_CUTOFF_STEP,
.formatter = NULL,
.get_talk_id = NULL,
};
diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c
index 6d7ef270cb..d72e3c7fa7 100644
--- a/apps/menus/sound_menu.c
+++ b/apps/menus/sound_menu.c
@@ -54,13 +54,17 @@ static int volume_limit_callback(int action,
(void)this_list;
static struct int_setting volume_limit_int_setting;
- volume_limit_int_setting.option_callback = NULL;
- volume_limit_int_setting.unit = UNIT_DB;
- volume_limit_int_setting.min = sound_min(SOUND_VOLUME);
- volume_limit_int_setting.max = sound_max(SOUND_VOLUME);
- volume_limit_int_setting.step = sound_steps(SOUND_VOLUME);
- volume_limit_int_setting.formatter = vol_limit_format;
- volume_limit_int_setting.get_talk_id = NULL;
+
+ volume_limit_int_setting = (struct int_setting)
+ {
+ .option_callback = NULL,
+ .unit = UNIT_DB,
+ .step = sound_steps(SOUND_VOLUME),
+ .min = sound_min(SOUND_VOLUME),
+ .max = sound_max(SOUND_VOLUME),
+ .formatter = vol_limit_format,
+ .get_talk_id = NULL
+ };
struct settings_list setting;
setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
diff --git a/apps/settings.c b/apps/settings.c
index 7c4dc4d124..3d2c463cdd 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1180,9 +1180,14 @@ bool set_int_ex(const unsigned char* string,
{
(void)unit;
struct settings_list item;
- struct int_setting data = {
- function, voice_unit, min, max, step,
- formatter, get_talk_id
+ const struct int_setting data = {
+ .option_callback = function,
+ .unit = voice_unit,
+ .step = step,
+ .min = min,
+ .max = max,
+ .formatter = formatter,
+ .get_talk_id = get_talk_id,
};
item.int_setting = &data;
item.flags = F_INT_SETTING|F_T_INT;
@@ -1212,9 +1217,14 @@ bool set_option(const char* string, const void* variable, enum optiontype type,
{
int temp;
struct settings_list item;
- struct int_setting data = {
- function, UNIT_INT, 0, numoptions-1, 1,
- set_option_formatter, set_option_get_talk_id
+ const struct int_setting data = {
+ .option_callback = function,
+ .unit = UNIT_INT,
+ .step = 1,
+ .min = 0,
+ .max = numoptions-1,
+ .formatter = set_option_formatter,
+ .get_talk_id = set_option_get_talk_id
};
memset(&item, 0, sizeof(struct settings_list));
set_option_options = options;
diff --git a/apps/settings_list.c b/apps/settings_list.c
index f733ee4f69..5449ade728 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -167,19 +167,19 @@
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
lang_id, INT(default), name, cfg_vals, \
{.int_setting = (struct int_setting[]){ \
- {cb, unit, min, max, step, formatter, get_talk_id}}}}
+ {cb, unit, step, min, max, formatter, get_talk_id}}}}
#define INT_SETTING(flags, var, lang_id, default, name, \
- unit, min, max, step, formatter, get_talk_id, cb) \
+ unit, step, min, max, formatter, get_talk_id, cb) \
{flags|F_INT_SETTING|F_T_INT, &global_settings.var, \
lang_id, INT(default), name, NULL, \
{.int_setting = (struct int_setting[]){ \
- {cb, unit, min, max, step, formatter, get_talk_id}}}}
+ {cb, unit, step, min, max, formatter, get_talk_id}}}}
#define INT_SETTING_NOWRAP(flags, var, lang_id, default, name, \
- unit, min, max, step, formatter, get_talk_id, cb) \
+ unit, step, min, max, formatter, get_talk_id, cb) \
{flags|F_INT_SETTING|F_T_INT|F_NO_WRAP, &global_settings.var, \
lang_id, INT(default), name, NULL, \
{.int_setting = (struct int_setting[]){ \
- {cb, unit, min, max, step, formatter, get_talk_id}}}}
+ {cb, unit, step, min, max, formatter, get_talk_id}}}}
#define TABLE_SETTING(flags, var, lang_id, default, name, cfg_vals, \
unit, formatter, get_talk_id, cb, count, ...) \
diff --git a/apps/settings_list.h b/apps/settings_list.h
index 36c4d8062f..d4862874d5 100644
--- a/apps/settings_list.h
+++ b/apps/settings_list.h
@@ -69,10 +69,11 @@ struct filename_setting {
struct int_setting {
void (*option_callback)(int);
- int unit;
+ int16_t unit;
+ int16_t step;
int min;
int max;
- int step;
+
const char* (*formatter)(char*, size_t, int, const char*);
int32_t (*get_talk_id)(int, int);
};