From 9c16e12390fa78fe7acd1ebbb2454f31221cce8a Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Fri, 14 Feb 2003 14:14:55 +0000 Subject: Expanded .cfg loader to include most settings. Based on Christian Determann's patch. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3260 a1c6a512-1295-4272-9138-f99709370657 --- apps/lang/english.lang | 10 +++ apps/settings.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++ apps/settings.h | 4 +- apps/tree.c | 32 +++++---- docs/CUSTOM_CFG_FORMAT | 114 +++++++++++++++++++++++--------- 5 files changed, 287 insertions(+), 47 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index f272bea888..4539e21aca 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -1381,3 +1381,13 @@ id: LANG_CPU_SLEEP desc: in system_settings_menu() eng: "Power Saving" new: + +id: LANG_SETTINGS_LOADED1 +desc: Feedback shown when a .cfg file is loaded +eng: "Settings" +new: + +id: LANG_SETTINGS_LOADED2 +desc: Feedback shown when a .cfg file is loaded +eng: "loaded" +new: diff --git a/apps/settings.c b/apps/settings.c index c7ab9e411c..946286dc75 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -519,6 +519,8 @@ void settings_apply(void) cpu_sleep(global_settings.cpu_sleep); } +static void set_cfg_bool(bool* variable, char* value); + /* * load settings from disk or RTC RAM */ @@ -527,6 +529,8 @@ void settings_load(void) DEBUGF( "reload_all_settings()\n" ); + // set_cfg_bool(&global_settings.playlist_shuffle, "off"); + /* populate settings with default values */ settings_reset(); @@ -776,6 +780,39 @@ static void set_sound(char* value, int type, int* setting) #endif } +static void set_cfg_bool(bool* variable, char* value) +{ + /* look for the 'n' in 'on' */ + if ((value[1] & 0xdf) == 'N') + *variable = true; + else + *variable = false; +} + +static void set_cfg_int(int* variable, char* value, int min, int max ) +{ + *variable = atoi(value); + + if (*variable < min) + *variable = min; + else + if (*variable > max) + *variable = max; +} + +static void set_cfg_option(int* variable, char* value, + char* options[], int numoptions ) +{ + int i; + + for (i=0; iname); wps_load(buf,true); storefile(file->name, global_settings.wps_file, MAX_FILENAME); @@ -1123,22 +1121,34 @@ bool dirbrowse(char *root) break; case TREE_ATTR_CFG: - snprintf(buf, sizeof buf, "%s/%s", - currdir, file->name); - settings_load_config(buf); + if (!settings_load_config(buf)) + break; + lcd_clear_display(); + lcd_puts(0,0,str(LANG_SETTINGS_LOADED1)); + lcd_puts(0,1,str(LANG_SETTINGS_LOADED2)); +#ifdef HAVE_LCD_BITMAP + lcd_update(); + + /* maybe we have a new font */ + lcd_getstringsize("A", &fw, &fh); + tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh; + /* make sure cursor is on screen */ + while ( dircursor > tree_max_on_screen ) + { + dircursor--; + dirstart++; + } +#endif + sleep(HZ/2); restore = true; break; case TREE_ATTR_TXT: - snprintf(buf, sizeof buf, "%s/%s", - currdir, file->name); viewer_run(buf); restore = true; break; case TREE_ATTR_LNG: - snprintf(buf, sizeof buf, "%s/%s", - currdir, file->name); if(!lang_load(buf)) { storefile(file->name, global_settings.lang_file, @@ -1166,8 +1176,6 @@ bool dirbrowse(char *root) #ifdef HAVE_LCD_BITMAP case TREE_ATTR_FONT: - snprintf(buf, sizeof buf, "%s/%s", - currdir, file->name); font_load(buf); storefile(file->name, global_settings.font_file, MAX_FILENAME); @@ -1186,8 +1194,6 @@ bool dirbrowse(char *root) #ifndef SIMULATOR /* firmware file */ case TREE_ATTR_MOD: - snprintf(buf, sizeof buf, "%s/%s", - currdir, file->name); rolo_load(buf); break; #endif diff --git a/docs/CUSTOM_CFG_FORMAT b/docs/CUSTOM_CFG_FORMAT index 87bc18162a..06b11b8241 100644 --- a/docs/CUSTOM_CFG_FORMAT +++ b/docs/CUSTOM_CFG_FORMAT @@ -1,24 +1,85 @@ -Custom CFG -File Format Specifications +Custom CFG File Format Specification -Description / General Info --------------------------- -* The .cfg file is used on both the Rockbox Player and Recorder, in order to - load custom settings. -* Currently, only sound settings are supported but this will change in the - future. - -File Location -------------- -The files may reside anywhere on the hard disk. The only restriction is that -the filename must end in .cfg +General Info +------------ +The .cfg file is used to load settings from a plain text file. A .cfg file may +reside anywhere on the hard disk. The only restriction is that the filename +must end in .cfg Format Rules ------------ -* Each setting must have it's own line. +* Format: setting: value +* Each setting must be on a separate line. * Lines starting with # are ignored. -* If a value is out of the acceptable range for the device, which can vary - depending on the model, the value will be set to its default value. + +Settings (allowed values) [unit] +-------------------------------- +volume (0 - 100) +bass (-15 - 15) +treble (-15 - 15) +balance (-100 - 100) + +shuffle (on, off) +repeat (off, all, one) +play selected (on, off) +resume (off, ask, on) +scan min step (1, 2, 3, 4, 5, 6, 8, 10, 15, 20, 25) [seconds] +scan accel (0 - 15) [double scan speed every X seconds] +antiskip (0 - 7) [seconds] + +sort case (on, off) +show files (all, supported, music) +follow playlist (on, off) + +scroll speed (1 - 10) [Hz] +start delay (0 - 250) [1/10s] +scroll step (1 - 112) [pixel] +bidir limit (0 - 200) [% of screen width] +contrast (0 - 63) +backlight timeout (off, on, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 15, 20, 30, 45, 60, 90) [seconds] +backlight when plugged (on, off) + +disk spindown (3 - 254) [seconds] +disk poweroff (on, off) +battery capacity (1500 - 2400) [mAh] +idle poweroff (off, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 15, 30, 45, 60) [minutes] + +Recorder-specific settings (allowed values) [unit] +--------------------------------------------------- +loudness (0 - 17) +bass boost (0 - 100) +auto volume (0=off, 1=2s, 2=4s, 3=8s) + +peak meter release (1 - 126) +peak meter hold (off, 200ms, 300ms, 500ms, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 15, 20, 25, 30, 45, 90, + 2min, 3min, 5min, 10min, 20min, 45min, 90min) +peak meter clip hold (on, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 15, 20, 25, 30, 45, 60, 90, + 2min, 3min, 5min, 10min, 20min, 45min, 90min) +peak meter busy (on, off) +peak meter dbfs (on, off) (on = dbfs, off = linear) +peak meter min (0 - 89) [dB] or (0 - 100) [%] +peak meter max (0 - 89) [dB] or (0 - 100) [%] + +volume display (graphic, numeric) +battery display (graphic, numeric) +time format (12hour, 24hour) + +deep discharge (on, off) +trickle charge (on, off) + +rec quality (0 - 7) (0=smallest size, 7=highest quality) +rec frequency (48, 44, 32, 24, 22, 16) [kHz] +rec source (mic, line, spdif) +rec channels (mono, stereo) +rec mic gain (0 to 15) +rec left gain (0 to 15) +rec right gain (0 to 15) + Example File ------------ @@ -26,20 +87,9 @@ volume: 70 bass: 11 treble: 12 balance: 0 -channels: 0 -loudness: 5 -bass boost: 30 -auto volume: 0 - -This sets each line to the respective values after it. +time format: 12hour +volume display: numeric +show files: supported +wps: car +lang: afrikaans -Value ranges ------------- -volume: 0 to 100 -bass: player: -15 to 15, recorder: -12 to 12 -treble: player: -15 to 15, recorder: -12 to 12 -balance: -100 to 100 -channels: 0=Stereo, 1=Mono, 2=Mono Left, 3=Mono Right -loudness: 0 to 17 (recorder only) -bass boost: 0 to 100 (recorder only) -auto volume: 0=off, 1=2s, 2=4s, 3=8s (recorder only) -- cgit v1.2.3