Save some bytes and reuse the settings saving code for eq preset saving.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15891 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
05007e1a79
commit
5886efabf5
|
@ -596,50 +596,17 @@ bool eq_menu_graphical(void)
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Preset saver.
|
||||
* TODO: Can the settings system be used to do this instead?
|
||||
*/
|
||||
static bool eq_save_preset(void)
|
||||
{
|
||||
int fd, i;
|
||||
char filename[MAX_PATH];
|
||||
int *setting;
|
||||
|
||||
create_numbered_filename(filename, EQS_DIR, "eq", ".cfg", 2
|
||||
IF_CNFN_NUM_(, NULL));
|
||||
|
||||
/* allow user to modify filename */
|
||||
while (true) {
|
||||
if (!kbd_input(filename, sizeof filename)) {
|
||||
fd = creat(filename);
|
||||
if (fd < 0)
|
||||
gui_syncsplash(HZ, ID2P(LANG_FAILED));
|
||||
else
|
||||
break;
|
||||
}
|
||||
else {
|
||||
gui_syncsplash(HZ, ID2P(LANG_CANCEL));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO: Should we really do this? */
|
||||
fdprintf(fd, "eq enabled: on\r\n");
|
||||
fdprintf(fd, "eq precut: %d\r\n", global_settings.eq_precut);
|
||||
/* make sure that the eq is enabled for setting saving */
|
||||
bool enabled = global_settings.eq_enabled;
|
||||
global_settings.eq_enabled = true;
|
||||
|
||||
setting = &global_settings.eq_band0_cutoff;
|
||||
bool result = settings_save_config(SETTINGS_SAVE_EQPRESET);
|
||||
|
||||
for(i = 0; i < 5; ++i) {
|
||||
fdprintf(fd, "eq band %d cutoff: %d\r\n", i, *setting++);
|
||||
fdprintf(fd, "eq band %d q: %d\r\n", i, *setting++);
|
||||
fdprintf(fd, "eq band %d gain: %d\r\n", i, *setting++);
|
||||
}
|
||||
global_settings.eq_enabled = enabled;
|
||||
|
||||
close(fd);
|
||||
|
||||
gui_syncsplash(HZ, ID2P(LANG_SETTINGS_SAVED));
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Allows browsing of preset files */
|
||||
|
@ -648,7 +615,6 @@ bool eq_browse_presets(void)
|
|||
return rockbox_browse(EQS_DIR, SHOW_CFG);
|
||||
}
|
||||
|
||||
|
||||
MENUITEM_FUNCTION(eq_graphical, 0, ID2P(LANG_EQUALIZER_GRAPHICAL),
|
||||
(int(*)(void))eq_menu_graphical, NULL, NULL,
|
||||
Icon_EQ);
|
||||
|
|
|
@ -476,6 +476,11 @@ static bool settings_write_config(char* filename, int options)
|
|||
else if ((options == SETTINGS_SAVE_RECPRESETS) &&
|
||||
((settings[i].flags&F_RECSETTING) == 0))
|
||||
continue;
|
||||
#endif
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
else if ((options == SETTINGS_SAVE_EQPRESET) &&
|
||||
((settings[i].flags&F_EQSETTING) == 0))
|
||||
continue;
|
||||
#endif
|
||||
switch (settings[i].flags&F_T_MASK)
|
||||
{
|
||||
|
@ -613,6 +618,11 @@ bool settings_save_config(int options)
|
|||
case SETTINGS_SAVE_RECPRESETS:
|
||||
folder = RECPRESETS_DIR;
|
||||
break;
|
||||
#endif
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
case SETTINGS_SAVE_EQPRESET:
|
||||
folder = EQS_DIR;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
folder = ROCKBOX_DIR;
|
||||
|
|
|
@ -207,6 +207,9 @@ enum {
|
|||
#ifdef HAVE_RECORDING
|
||||
SETTINGS_SAVE_RECPRESETS,
|
||||
#endif
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
SETTINGS_SAVE_EQPRESET,
|
||||
#endif
|
||||
};
|
||||
bool settings_save_config(int options);
|
||||
|
||||
|
|
|
@ -906,58 +906,61 @@ const struct settings_list settings[] = {
|
|||
INT_SETTING_NOWRAP(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF, 700,
|
||||
"crossfeed hf cutoff", UNIT_HERTZ, 500, 2000, 100,
|
||||
NULL, NULL, crossfeed_cross_set),
|
||||
|
||||
/* equalizer */
|
||||
OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_precut, LANG_EQUALIZER_PRECUT, 0, "eq precut",
|
||||
UNIT_DB, 0, 240, 5, eq_precut_format, NULL, dsp_set_eq_precut),
|
||||
OFFON_SETTING(F_EQSETTING, eq_enabled, LANG_EQUALIZER_ENABLED, false,
|
||||
"eq enabled", NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_precut, LANG_EQUALIZER_PRECUT, 0,
|
||||
"eq precut", UNIT_DB, 0, 240, 5, eq_precut_format, NULL,
|
||||
dsp_set_eq_precut),
|
||||
/* 0..32768 Hz */
|
||||
INT_SETTING_NOWRAP(0, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 60,
|
||||
"eq band 0 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_cutoff, LANG_EQUALIZER_BAND_CUTOFF,
|
||||
60, "eq band 0 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band1_cutoff, LANG_EQUALIZER_BAND_CENTER, 200,
|
||||
"eq band 1 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_cutoff, LANG_EQUALIZER_BAND_CENTER,
|
||||
200, "eq band 1 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band2_cutoff, LANG_EQUALIZER_BAND_CENTER, 800,
|
||||
"eq band 2 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_cutoff, LANG_EQUALIZER_BAND_CENTER,
|
||||
800, "eq band 2 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band3_cutoff, LANG_EQUALIZER_BAND_CENTER, 4000,
|
||||
"eq band 3 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_cutoff, LANG_EQUALIZER_BAND_CENTER,
|
||||
4000, "eq band 3 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF, 12000,
|
||||
"eq band 4 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_cutoff, LANG_EQUALIZER_BAND_CUTOFF,
|
||||
12000, "eq band 4 cutoff", UNIT_HERTZ, EQ_CUTOFF_MIN,
|
||||
EQ_CUTOFF_MAX, EQ_CUTOFF_STEP, NULL, NULL, NULL),
|
||||
/* 0..64 (or 0.0 to 6.4) */
|
||||
INT_SETTING_NOWRAP(0, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 0 q",
|
||||
UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_q, LANG_EQUALIZER_BAND_Q, 7,
|
||||
"eq band 0 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
eq_q_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 1 q",
|
||||
UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_q, LANG_EQUALIZER_BAND_Q, 10,
|
||||
"eq band 1 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
eq_q_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 2 q",
|
||||
UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_q, LANG_EQUALIZER_BAND_Q, 10,
|
||||
"eq band 2 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
eq_q_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10, "eq band 3 q",
|
||||
UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_q, LANG_EQUALIZER_BAND_Q, 10,
|
||||
"eq band 3 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
eq_q_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7, "eq band 4 q",
|
||||
UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_q, LANG_EQUALIZER_BAND_Q, 7,
|
||||
"eq band 4 q", UNIT_INT, EQ_Q_MIN, EQ_Q_MAX, EQ_Q_STEP,
|
||||
eq_q_format, NULL, NULL),
|
||||
/* -240..240 (or -24db to +24db) */
|
||||
INT_SETTING_NOWRAP(0, eq_band0_gain, LANG_GAIN, 0, "eq band 0 gain",
|
||||
UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
|
||||
eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band1_gain, LANG_GAIN, 0, "eq band 1 gain",
|
||||
UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
|
||||
eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band2_gain, LANG_GAIN, 0, "eq band 2 gain",
|
||||
UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
|
||||
eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band3_gain, LANG_GAIN, 0, "eq band 3 gain",
|
||||
UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
|
||||
eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(0, eq_band4_gain, LANG_GAIN, 0, "eq band 4 gain",
|
||||
UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX, EQ_GAIN_STEP,
|
||||
eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band0_gain, LANG_GAIN, 0,
|
||||
"eq band 0 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
|
||||
EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band1_gain, LANG_GAIN, 0,
|
||||
"eq band 1 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
|
||||
EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band2_gain, LANG_GAIN, 0,
|
||||
"eq band 2 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
|
||||
EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band3_gain, LANG_GAIN, 0,
|
||||
"eq band 3 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
|
||||
EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
|
||||
INT_SETTING_NOWRAP(F_EQSETTING, eq_band4_gain, LANG_GAIN, 0,
|
||||
"eq band 4 gain", UNIT_DB, EQ_GAIN_MIN, EQ_GAIN_MAX,
|
||||
EQ_GAIN_STEP, eq_gain_format, NULL, NULL),
|
||||
|
||||
/* dithering */
|
||||
OFFON_SETTING(0, dithering_enabled, LANG_DITHERING,
|
||||
|
|
|
@ -104,6 +104,7 @@ struct table_setting {
|
|||
|
||||
#define F_THEMESETTING 0x0800000
|
||||
#define F_RECSETTING 0x1000000
|
||||
#define F_EQSETTING 0x2000000
|
||||
|
||||
#define F_NVRAM_BYTES_MASK 0xE0000 /*0-4 bytes can be stored */
|
||||
#define F_NVRAM_MASK_SHIFT 17
|
||||
|
|
Loading…
Reference in New Issue
Block a user