Patch #2711 by Alexander Spyridakis with some changes by me: adds load/save of presets to different files;

Also fix the preset menu context menu not working on the remote


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9425 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Hristo Kovachev 2006-04-02 12:23:08 +00:00
parent b0b333f95e
commit 009853f40e
10 changed files with 419 additions and 86 deletions

View file

@ -45,6 +45,10 @@
#include "keyboard.h"
#endif
#ifdef CONFIG_TUNER
#include "radio.h"
#endif
#ifndef SIMULATOR
static int boot_size = 0;
static int boot_cluster;
@ -277,6 +281,9 @@ int ft_load(struct tree_context* c, const char* tempdir)
(*c->dirfilter == SHOW_WPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_WPS) ||
#ifdef HAVE_REMOTE_LCD
(*c->dirfilter == SHOW_RWPS && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_RWPS) ||
#endif
#ifdef CONFIG_TUNER
(*c->dirfilter == SHOW_FMR && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_FMR) ||
#endif
(*c->dirfilter == SHOW_CFG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_CFG) ||
(*c->dirfilter == SHOW_LNG && (dptr->attr & TREE_ATTR_MASK) != TREE_ATTR_LNG) ||
@ -418,6 +425,34 @@ int ft_enter(struct tree_context* c)
}
break;
#ifdef CONFIG_TUNER
/* fmr preset file */
case TREE_ATTR_FMR:
/* Preset inside the default folder. */
if(!strncasecmp(FMPRESET_PATH, buf, strlen(FMPRESET_PATH)))
{
set_file(buf, global_settings.fmr_file, MAX_FILENAME);
radio_load_presets(global_settings.fmr_file);
if(get_radio_status() != FMRADIO_PLAYING &&
get_radio_status() != FMRADIO_PAUSED)
radio_screen();
}
/*
* Preset outside default folder, we can choose such only
* if we are out of the radio screen, so the check for the
* radio status isn't neccessary
*/
else
{
radio_load_presets(buf);
radio_screen();
}
break;
#endif
/* wps config file */
case TREE_ATTR_WPS:
wps_data_load(gui_wps[0].data, buf, true);

View file

@ -3677,3 +3677,47 @@ desc: possible answers to resume question
eng: "(PLAY/STOP)"
voice: ""
new:
id: LANG_FM_NO_PRESETS
desc: error when preset list is empty
eng: "No presets"
voice: "No presets"
new:
id: LANG_FM_PRESET_LOAD
desc: load preset list in fm radio
eng: "Load Preset List"
voice: "Load Preset List"
new:
id: LANG_FM_PRESET_SAVE
desc: Save preset list in fm radio
eng: "Save Preset List"
voice: "Save Preset List"
new:
id: LANG_FM_PRESET_CLEAR
desc: clear preset list in fm radio
eng: "Clear Preset List"
voice: "Clear Preset List"
new:
id: LANG_FMR
desc: Used when you need to say Preset List, also voiced
eng: "Preset List"
voice: "Preset List"
new:
id: LANG_FM_FIRST_AUTOSCAN
desc: When you run the radio without an fmr file in settings
eng: "No Settings found, AutoScan?"
voice: "No Settings found, AutoScan?"
new:
id: LANG_FM_SAVE_CHANGES
desc: When you try to exit radio to confirm save
eng: "Save Changes?"
voice: "Save Changes?"
new:

View file

@ -47,6 +47,7 @@ const unsigned char bitmap_icons_6x8[][6] =
{ 0x4e, 0x51, 0x51, 0x40, 0x55, 0x55 }, /* Config file */
{ 0x0a, 0x0a, 0x5f, 0x4e, 0x24, 0x18 }, /* Plugin file */
{ 0xff, 0x81, 0xaf, 0xaa, 0x8c, 0xf8 }, /* Bookmark file */
{ 0x5f, 0x45, 0x5b, 0x40, 0x55, 0x55 }, /* Preset file */
{ 0x77, 0x55, 0x55, 0x55, 0x55, 0x77 }, /* Queued Item */
{ 0x3e, 0x41, 0x3e, 0x1c, 0x1c, 0x08 }, /* Moving Item */
{ 0x7f, 0x7f, 0x1c, 0x3e, 0x77, 0x63 }, /* Keyboard file */

View file

@ -54,6 +54,7 @@ enum icons_6x8 {
Icon_Config,
Icon_Plugin,
Icon_Bookmark,
Icon_Preset,
Icon_Queued,
Icon_Moving,
Icon_Keyboard,

View file

@ -58,6 +58,8 @@
#include "yesno.h"
#include "buttonbar.h"
#include "power.h"
#include "tree.h"
#include "dir.h"
#ifdef CONFIG_TUNER
@ -130,19 +132,24 @@ static int radio_mode = RADIO_SCAN_MODE;
static int radio_status = FMRADIO_OFF;
#define MAX_PRESETS 64
static bool presets_loaded = false;
static bool presets_loaded = false, presets_changed = false;
static struct fmstation presets[MAX_PRESETS];
static const char default_filename[] = "/.rockbox/fm-presets-default.fmr";
static char filepreset[MAX_PATH]; /* preset filename variable */
static int preset_menu; /* The menu index of the preset list */
static struct menu_item preset_menu_items[MAX_PRESETS];
static int num_presets; /* The number of presets in the preset list */
static int num_presets = 0; /* The number of presets in the preset list */
void radio_load_presets(void);
void radio_save_presets(void);
bool handle_radio_presets(void);
bool radio_menu(void);
bool radio_add_preset(void);
bool save_preset_list(void);
bool load_preset_list(void);
bool clear_preset_list(void);
static bool scan_presets(void);
#ifdef SIMULATOR
void radio_set(int setting, int value);
@ -160,6 +167,19 @@ int (*radio_get)(int setting);
#endif
#endif
/* Function to manipulate all yesno dialogues.
This function needs the output text as an argument. */
bool yesno_pop(char* text)
{
int i;
char *lines[]={text};
struct text_message message={lines, 1};
bool ret = (gui_syncyesno_run(&message,NULL,NULL)== YESNO_YES);
FOR_NB_SCREENS(i)
gui_textarea_clear(&screens[i]);
return ret;
}
void radio_init(void)
{
#ifndef SIMULATOR
@ -185,7 +205,7 @@ int get_radio_status(void)
}
void radio_stop(void)
{
{
radio_set(RADIO_MUTE, 1);
radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
radio_status = FMRADIO_OFF;
@ -208,6 +228,8 @@ bool radio_hardware_present(void)
static int find_preset(int freq)
{
int i;
if(num_presets < 1)
return -1;
for(i = 0;i < MAX_PRESETS;i++)
{
if(freq == presets[i].frequency)
@ -253,31 +275,27 @@ void next_preset(int direction)
{
if (num_presets < 1)
return;
curr_preset = find_preset(curr_freq);
if(curr_preset == -1)
curr_preset = find_closest_preset(curr_freq);
else if ((curr_preset < (num_presets-1) && direction > 0) ||
((curr_preset > 0) && direction < 0))
{
if (direction > 0)
curr_preset++;
if(direction > 0)
if(curr_preset == num_presets - 1)
curr_preset = 0;
else
curr_preset--;
}
else if (num_presets > 1)
{
if (direction > 0)
curr_preset = 0;
else
curr_preset = num_presets - 1;
}
curr_preset++;
else
return;
if(curr_preset == 0)
curr_preset = num_presets - 1;
else
curr_preset--;
curr_freq = presets[curr_preset].frequency;
radio_set(RADIO_FREQUENCY, curr_freq);
remember_frequency();
}
bool radio_screen(void)
{
char buf[MAX_PATH];
@ -313,11 +331,12 @@ bool radio_screen(void)
#endif
/* always display status bar in radio screen for now */
global_settings.statusbar = true;
FOR_NB_SCREENS(i){
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0);
}
gui_syncstatusbar_draw(&statusbars,true);
fh = font_get(FONT_UI)->height;
@ -326,21 +345,30 @@ bool radio_screen(void)
if(fh < 10)
top_of_screen = 1;
radio_load_presets();
if(!num_presets)
{
memset(presets, 0, sizeof(presets));
radio_load_presets(global_settings.fmr_file);
}
#ifndef SIMULATOR
#if CONFIG_CODEC != SWCODEC
if(rec_create_directory() > 0)
have_recorded = true;
#endif
audio_stop();
if(radio_status == FMRADIO_PLAYING_OUT)
radio_status = FMRADIO_PLAYING;
else if(radio_status == FMRADIO_PAUSED_OUT)
radio_status = FMRADIO_PAUSED;
if(radio_status == FMRADIO_OFF)
audio_stop();
#if CONFIG_CODEC != SWCODEC
audio_init_recording();
sound_settings_apply();
/* Yes, we use the D/A for monitoring */
peak_meter_playback(true);
@ -373,7 +401,8 @@ bool radio_screen(void)
curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ;
if(radio_status != FMRADIO_PLAYING){
if(radio_status == FMRADIO_OFF)
{
radio_power(true);
radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
radio_set(RADIO_FREQUENCY, curr_freq);
@ -391,6 +420,9 @@ bool radio_screen(void)
radio_set(RADIO_MUTE, 0);
radio_status = FMRADIO_PLAYING;
}
if(num_presets == 0 && yesno_pop(str(LANG_FM_FIRST_AUTOSCAN)))
scan_presets();
curr_preset = find_preset(curr_freq);
if(curr_preset != -1)
@ -402,7 +434,7 @@ bool radio_screen(void)
#endif
cpu_idle_mode(true);
while(!done)
{
if(search_dir)
@ -463,6 +495,18 @@ bool radio_screen(void)
#endif
{
done = true;
if(presets_changed)
{
if(yesno_pop(str(LANG_FM_SAVE_CHANGES)))
{
if(filepreset[0] == '\0')
save_preset_list();
else
radio_save_presets();
}
}
/* Clear the preset list on exit. */
clear_preset_list();
}
update_screen = true;
break;
@ -517,6 +561,21 @@ bool radio_screen(void)
#endif
keep_playing = true;
done = true;
if(presets_changed)
{
if(yesno_pop(str(LANG_FM_SAVE_CHANGES)))
{
if(filepreset[0] == '\0')
save_preset_list();
else
radio_save_presets();
}
}
/* Clear the preset list on exit. */
clear_preset_list();
break;
#ifdef BUTTON_RC_REW
@ -563,6 +622,12 @@ bool radio_screen(void)
case BUTTON_LEFT | BUTTON_REPEAT:
if(radio_mode == RADIO_SCAN_MODE)
search_dir = -1;
else
{
next_preset(-1);
update_screen = true;
}
break;
#ifdef BUTTON_RC_FF
@ -571,6 +636,12 @@ bool radio_screen(void)
case BUTTON_RIGHT | BUTTON_REPEAT:
if(radio_mode == RADIO_SCAN_MODE)
search_dir = 1;
else
{
next_preset(1);
update_screen = true;
}
break;
#ifdef BUTTON_RC_VOL_UP
@ -671,16 +742,25 @@ bool radio_screen(void)
)
break;
#endif
if(num_presets < 1){
if(num_presets < 1)
{
gui_syncsplash(HZ, true, str(LANG_FM_NO_PRESETS));
update_screen = true;
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0);
gui_textarea_update(&screens[i]);
}
break;
}
handle_radio_presets();
curr_preset = find_preset(curr_freq);
FOR_NB_SCREENS(i){
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0);
gui_textarea_update(&screens[i]);
}
#ifdef HAS_BUTTONBAR
gui_buttonbar_set(&buttonbar,
@ -729,10 +809,14 @@ bool radio_screen(void)
)
{
if(radio_mode == RADIO_SCAN_MODE)
radio_mode = RADIO_PRESET_MODE;
{
/* Force scan mode if there are no presets. */
if(num_presets > 0)
radio_mode = RADIO_PRESET_MODE;
}
else
radio_mode = RADIO_SCAN_MODE;
update_screen = true;
update_screen = true;
}
break;
#endif
@ -899,26 +983,34 @@ bool radio_screen(void)
#endif
sound_settings_apply();
#endif /* SIMULATOR */
if(keep_playing)
{
/* Catch FMRADIO_PLAYING_OUT status for the sim. */
#ifndef SIMULATOR
#if CONFIG_CODEC != SWCODEC
/* Enable the Left and right A/D Converter */
audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
mas_codec_writereg(6, 0x4000);
#endif
#endif
if(radio_status == FMRADIO_PAUSED)
radio_status = FMRADIO_PAUSED_OUT;
else
radio_status = FMRADIO_PLAYING_OUT;
}
else
{
radio_stop();
#ifndef SIMULATOR /* SIMULATOR. Catch FMRADIO_OFF status for the sim. */
#if CONFIG_CODEC == SWCODEC
pcm_rec_mux(0); /* Line In */
peak_meter_enabled = true;
#endif
#endif /* SIMULATOR */
}
#endif
cpu_idle_mode(false);
@ -932,8 +1024,8 @@ void radio_save_presets(void)
{
int fd;
int i;
fd = creat(default_filename, O_WRONLY);
fd = creat(filepreset, O_WRONLY);
if(fd >= 0)
{
for(i = 0;i < num_presets;i++)
@ -941,14 +1033,18 @@ void radio_save_presets(void)
fdprintf(fd, "%d:%s\n", presets[i].frequency, presets[i].name);
}
close(fd);
if(!strncasecmp(FMPRESET_PATH, filepreset, strlen(FMPRESET_PATH)))
set_file(filepreset, global_settings.fmr_file, MAX_FILENAME);
presets_changed = false;
}
else
{
gui_syncsplash(HZ*2, true, str(LANG_FM_PRESET_SAVE_FAILED));
}
gui_syncsplash(HZ, true, str(LANG_FM_PRESET_SAVE_FAILED));
}
}
void radio_load_presets(void)
void radio_load_presets(char *filename)
{
int fd;
int rc;
@ -958,38 +1054,58 @@ void radio_load_presets(void)
bool done = false;
int f;
if(!presets_loaded)
{
memset(presets, 0, sizeof(presets));
num_presets = 0;
memset(presets, 0, sizeof(presets));
num_presets = 0;
/* No Preset in configuration. */
if(filename[0] == '\0')
{
filepreset[0] = '\0';
return;
}
/* Temporary preset, loaded until player shuts down. */
else if(filename[0] == '/')
strncpy(filepreset, filename, sizeof(filepreset));
/* Preset from default directory. */
else
snprintf(filepreset, sizeof(filepreset), "%s/%s.fmr",
FMPRESET_PATH, filename);
fd = open(default_filename, O_RDONLY);
if(fd >= 0)
fd = open(filepreset, O_RDONLY);
if(fd >= 0)
{
while(!done && num_presets < MAX_PRESETS)
{
while(!done && num_presets < MAX_PRESETS)
rc = read_line(fd, buf, 128);
if(rc > 0)
{
rc = read_line(fd, buf, 128);
if(rc > 0)
if(settings_parseline(buf, &freq, &name))
{
if(settings_parseline(buf, &freq, &name))
f = atoi(freq);
if(f) /* For backwards compatibility */
{
f = atoi(freq);
if(f) /* For backwards compatibility */
{
presets[num_presets].frequency = f;
strncpy(presets[num_presets].name, name, 27);
presets[num_presets].name[27] = 0;
num_presets++;
}
presets[num_presets].frequency = f;
strncpy(presets[num_presets].name, name, 27);
presets[num_presets].name[27] = 0;
num_presets++;
}
}
else
done = true;
}
close(fd);
else
done = true;
}
close(fd);
}
presets_loaded = true;
else /* invalid file name? */
filepreset[0] = '\0';
if(num_presets > 0)
presets_loaded = true;
else
presets_loaded = false;
presets_changed = false;
}
static void rebuild_preset_menu(void)
@ -1022,12 +1138,14 @@ bool radio_add_preset(void)
rebuild_preset_menu();
#endif
num_presets++;
radio_save_presets();
presets_changed = true;
if(num_presets > 0)
presets_loaded = true;
}
}
else
{
gui_syncsplash(HZ*2, true, str(LANG_FM_NO_FREE_PRESETS));
gui_syncsplash(HZ, true, str(LANG_FM_NO_FREE_PRESETS));
}
return true;
}
@ -1063,7 +1181,7 @@ static bool radio_edit_preset(void)
{
buf[27] = 0;
strcpy(presets[pos].name, buf);
radio_save_presets();
presets_changed = true;
}
return true;
}
@ -1081,11 +1199,64 @@ bool radio_delete_preset(void)
/* We must still rebuild the menu table, since the
item name pointers must be updated */
rebuild_preset_menu();
radio_save_presets();
/* Don't ask to save when all presets are deleted. */
if(num_presets > 0)
presets_changed = true;
else
{
presets_changed = false;
/* The preset list will be cleared, switch to Scan Mode. */
radio_mode = RADIO_SCAN_MODE;
presets_loaded = false;
}
return true; /* Make the menu return immediately */
}
bool load_preset_list(void)
{
return !rockbox_browse(FMPRESET_PATH, SHOW_FMR);
}
bool save_preset_list(void)
{
if(num_presets != 0)
{
if(!opendir(FMPRESET_PATH)) /* Check if there is preset folder */
mkdir(FMPRESET_PATH, 0);
create_numbered_filename(filepreset, FMPRESET_PATH, "preset", ".fmr", 2);
if (!kbd_input(filepreset, sizeof(filepreset)))
radio_save_presets();
}
else
gui_syncsplash(HZ,true,str(LANG_FM_NO_PRESETS));
return true;
}
bool clear_preset_list(void)
{
int i;
/* Clear all the preset entries */
for(i = 0;i <= num_presets;i++){
presets[i].name[0] = '\0';
presets[i].frequency = 0;
}
num_presets = 0;
presets_loaded = false;
/* The preset list will be cleared switch to Scan Mode. */
radio_mode = RADIO_SCAN_MODE;
presets_changed = false; /* Don't ask to save when clearing the list. */
return true;
}
/* little menu on what to do with a preset entry */
bool handle_radio_presets_menu(void)
{
@ -1128,6 +1299,12 @@ int handle_radio_presets_cb(int key, int m)
#ifdef FM_PRESET_ACTION
case FM_PRESET_ACTION:
#endif
#ifdef MENU_RC_ENTER
case MENU_RC_ENTER | BUTTON_REPEAT:
#endif
#ifdef MENU_RC_ENTER2
case MENU_RC_ENTER2 | BUTTON_REPEAT:
#endif
#ifdef MENU_ENTER2
case MENU_ENTER2 | BUTTON_REPEAT:
#endif
@ -1142,17 +1319,31 @@ int handle_radio_presets_cb(int key, int m)
key = BUTTON_NONE;
break;
}
#ifdef MENU_RC_ENTER
case MENU_RC_ENTER | BUTTON_REL:
#endif
#ifdef MENU_RC_ENTER2
case MENU_RC_ENTER2 | BUTTON_REL:
#endif
#ifdef MENU_ENTER2
case MENU_ENTER2 | BUTTON_REL:
#endif
case MENU_ENTER | BUTTON_REL:
key = MENU_ENTER; /* fake enter for short press */
break;
/* ignore down events */
#ifdef MENU_RC_ENTER
case MENU_RC_ENTER:
#endif
#ifdef MENU_RC_ENTER2
case MENU_RC_ENTER2:
#endif
#ifdef MENU_ENTER2
case MENU_ENTER2:
#endif
case MENU_ENTER: /* ignore down event */
case MENU_ENTER:
/* Ignore the release events */
#ifdef FM_PRESET_ADD
case FM_PRESET_ADD | BUTTON_REL:
@ -1267,18 +1458,19 @@ static bool toggle_radio_mode(void)
static bool scan_presets(void)
{
bool tuned = false;
bool tuned = false, do_scan = true;
char buf[27];
int freq, i;
char *lines[]={str(LANG_FM_CLEAR_PRESETS)};
struct text_message message={lines, 1};
if(gui_syncyesno_run(&message,NULL,NULL)==YESNO_YES){
FOR_NB_SCREENS(i)
gui_textarea_clear(&screens[i]);
if(num_presets > 0) /* Do that to avoid 2 questions. */
do_scan = yesno_pop(str(LANG_FM_CLEAR_PRESETS));
if(do_scan)
{
curr_freq = MIN_FREQ;
num_presets = 0;
while(curr_freq <= MAX_FREQ){
while(curr_freq <= MAX_FREQ)
{
if (num_presets >= MAX_PRESETS)
break;
@ -1309,14 +1501,25 @@ static bool scan_presets(void)
}
radio_save_presets();
presets_changed = true;
FOR_NB_SCREENS(i)
{
gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0);
gui_textarea_update(&screens[i]);
}
if(num_presets > 0 ){
if(num_presets > 0 )
{
curr_freq = presets[0].frequency;
radio_set(RADIO_FREQUENCY, curr_freq);
remember_frequency();
radio_mode = RADIO_PRESET_MODE;
presets_loaded = true;
}
else
presets_loaded = false;
}
return true;
}
@ -1363,6 +1566,10 @@ bool radio_menu(void)
#ifndef FM_PRESET_ADD
{ ID2P(LANG_FM_ADD_PRESET) , radio_add_preset },
#endif
{ ID2P(LANG_FM_PRESET_LOAD) , load_preset_list },
{ ID2P(LANG_FM_PRESET_SAVE) , save_preset_list },
{ ID2P(LANG_FM_PRESET_CLEAR) , clear_preset_list },
{ monomode_menu_string , toggle_mono_mode },
#ifndef FM_MODE
{ radiomode_menu_string , toggle_radio_mode },

View file

@ -18,12 +18,16 @@
****************************************************************************/
#ifndef RADIO_H
#define RADIO_H
#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
#define FMRADIO_OFF 0
#define FMRADIO_PLAYING 1
#define FMRADIO_PAUSED 2
#define FMRADIO_PLAYING_OUT 2
#define FMRADIO_PAUSED 3
#define FMRADIO_PAUSED_OUT 4
#ifdef CONFIG_TUNER
void radio_load_presets(char *filename);
void radio_init(void);
bool radio_screen(void);
void radio_stop(void);

View file

@ -77,6 +77,10 @@
#include "backdrop.h"
#endif
#ifdef CONFIG_TUNER
#include "radio.h"
#endif
#if CONFIG_CODEC == MAS3507D
void dac_line_in(bool enable);
#endif
@ -150,6 +154,7 @@ modified unless the header & checksum test fails.
Rest of config block, only saved to disk:
0x2C start of 2nd bit-table
...
0xA4 (char[20]) FMR Preset file
0xB8 (char[20]) WPS file
0xCC (char[20]) Lang file
0xE0 (char[20]) Font file
@ -912,6 +917,13 @@ int settings_save( void )
MAX_FILENAME);
i+= MAX_FILENAME;
#endif
#ifdef CONFIG_TUNER
strncpy((char *)&config_block[i], (char *)global_settings.fmr_file,
MAX_FILENAME);
i+= MAX_FILENAME;
#endif
#ifdef HAVE_LCD_COLOR
strncpy((char *)&config_block[i], (char *)global_settings.backdrop_file,
MAX_FILENAME);
@ -1263,6 +1275,13 @@ void settings_load(int which)
MAX_FILENAME);
i+= MAX_FILENAME;
#endif
#ifdef CONFIG_TUNER
strncpy((char *)global_settings.fmr_file, (char *)&config_block[i],
MAX_FILENAME);
i+= MAX_FILENAME;
#endif
#ifdef HAVE_LCD_COLOR
strncpy((char *)global_settings.backdrop_file, (char *)&config_block[i],
MAX_FILENAME);
@ -1433,6 +1452,11 @@ bool settings_load_config(const char* file)
talk_init(); /* use voice of same language */
}
}
#ifdef CONFIG_TUNER
else if (!strcasecmp(name, "fmr")) {
set_file(value, global_settings.fmr_file, MAX_FILENAME);
}
#endif
#ifdef HAVE_LCD_BITMAP
else if (!strcasecmp(name, "font")) {
if (font_load(value))
@ -1580,9 +1604,9 @@ bool settings_save_config(void)
}
fdprintf(fd, "# .cfg file created by rockbox %s - "
"http://www.rockbox.org\r\n#\r\n"
"#\r\n# wps / language / font \r\n#\r\n", appsversion);
"http://www.rockbox.org\r\n#\r\n#\r\n# wps / rwps / language"
" / font / fmpreset / backdrop \r\n#\r\n", appsversion);
if (global_settings.wps_file[0] != 0)
fdprintf(fd, "wps: %s/%s.wps\r\n", WPS_DIR,
global_settings.wps_file);
@ -1609,6 +1633,12 @@ bool settings_save_config(void)
global_settings.backdrop_file);
#endif
#ifdef CONFIG_TUNER
if (global_settings.fmr_file[0] != 0)
fdprintf(fd, "fmr: %s/%s.fmr\r\n", FMPRESET_PATH,
global_settings.fmr_file);
#endif
#ifdef HAVE_LCD_BITMAP
if (global_settings.kbd_file[0] != 0)
fdprintf(fd, "keyboard: %s/%s.kbd\r\n", ROCKBOX_DIR,
@ -1685,6 +1715,10 @@ void settings_reset(void) {
global_settings.superbass = sound_default(SOUND_SUPERBASS);
#endif
global_settings.contrast = lcd_default_contrast();
#ifdef CONFIG_TUNER
global_settings.fmr_file[0] = '\0';
#endif
global_settings.wps_file[0] = '\0';
#ifdef HAVE_REMOTE_LCD
global_settings.rwps_file[0] = '\0';

View file

@ -291,6 +291,9 @@ struct user_settings
int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
>0=shuffled) */
#ifdef CONFIG_TUNER
unsigned char fmr_file[MAX_FILENAME+1]; /* last fmr preset */
#endif
unsigned char font_file[MAX_FILENAME+1]; /* last font */
unsigned char wps_file[MAX_FILENAME+1]; /* last wps */
unsigned char lang_file[MAX_FILENAME+1]; /* last language */
@ -571,7 +574,7 @@ enum
* must be added after NUM_FILTER_MODES. */
enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
NUM_FILTER_MODES,
SHOW_WPS, SHOW_RWPS, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
SHOW_WPS, SHOW_RWPS, SHOW_FMR, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
/* recursive dir insert options */
enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };

View file

@ -105,6 +105,9 @@ const struct filetype filetypes[] = {
#endif
#ifdef HAVE_LCD_COLOR
{ "bmp", TREE_ATTR_BMP, Icon_Wps, VOICE_EXT_WPS },
#endif
#ifdef CONFIG_TUNER
{ "fmr", TREE_ATTR_FMR, Icon_Preset, LANG_FMR },
#endif
{ "lng", TREE_ATTR_LNG, Icon_Language, LANG_LANGUAGE },
{ "rock",TREE_ATTR_ROCK,Icon_Plugin, VOICE_EXT_ROCK },

View file

@ -243,6 +243,7 @@ struct tree_context {
#define TREE_ATTR_RWPS 0x1000 /* remote-wps config file */
#define TREE_ATTR_BMP 0x1100 /* backdrop bmp file */
#define TREE_ATTR_KBD 0x1200 /* keyboard file */
#define TREE_ATTR_FMR 0x1300 /* preset file */
#define TREE_ATTR_MASK 0xFF00 /* which bits tree.c uses for file types */
void tree_get_filetypes(const struct filetype**, int*);