1
0
Fork 0
forked from len0rd/rockbox

added "Auto scan presets" option to radio menu

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7917 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Anton Oleynikov 2005-11-16 23:36:35 +00:00
parent df0e5effc5
commit d79f3a1e84
2 changed files with 119 additions and 5 deletions

View file

@ -1714,9 +1714,9 @@ voice: ""
new:
id: LANG_FM_NO_PRESETS
desc: DEPRECATED
eng: ""
voice: ""
desc: error when preset list is empty
eng: "No presets"
voice: "No presets"
new:
id: LANG_FM_NO_FREE_PRESETS
@ -3384,7 +3384,7 @@ voice: ""
new:
id: LANG_FM_FREEZE
desc: error message when preset list is empty
desc: splash screen during freeze in radio mode
eng: "Screen frozen!"
voice: ""
new:
@ -3400,3 +3400,34 @@ desc: in the sound settings menu
eng: "Crossfeed"
voice:
new:
id: LANG_FM_SCAN_PRESETS
desc: in radio menu
eng: "Auto scan presets"
voice: "Auto scan presets"
new:
id: LANG_FM_SCANNING
desc: during auto scan
eng: "Scanning %d.%dMHz"
voice: ""
new:
id: LANG_FM_DEFAULT_PRESET_NAME
desc: default preset name for auto scan mode
eng: "%d.%dMHz"
voice:
new:
id: LANG_FM_ADD_PRESET
desc: in radio menu
eng: "Add preset"
voice: "Add preset"
new:
id: LANG_FM_CLEAR_PRESETS
desc: confirmation if presets can be cleared
eng: "Clear current presets?"
voice: "Clear current presets?"
new:

View file

@ -625,6 +625,11 @@ bool radio_screen(void)
)
break;
#endif
if(num_presets < 1){
gui_syncsplash(HZ, true, str(LANG_FM_NO_PRESETS));
update_screen = true;
break;
}
handle_radio_presets();
curr_preset = find_preset(curr_freq);
FOR_NB_SCREENS(i){
@ -1178,6 +1183,83 @@ static bool toggle_mono_mode(void)
}
static bool scan_presets(void)
{
bool exit = false;
bool tuned = false;
char buf[32];
int freq, i;
FOR_NB_SCREENS(i){
gui_textarea_clear(&screens[i]);
screens[i].puts_scroll(0,0,str(LANG_FM_CLEAR_PRESETS));
screens[i].puts_scroll(0,2,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
screens[i].puts_scroll(0,3,str(LANG_CANCEL_WITH_ANY_RECORDER));
gui_textarea_update(&screens[i]);
}
while (!exit) {
int btn = button_get(true);
switch (btn) {
case SETTINGS_OK:
FOR_NB_SCREENS(i)
gui_textarea_clear(&screens[i]);
curr_freq = MIN_FREQ;
num_presets = 0;
while(curr_freq <= MAX_FREQ){
if (num_presets >= MAX_PRESETS)
break;
freq = curr_freq /100000;
snprintf(buf, 32, str(LANG_FM_SCANNING), freq/10, freq % 10);
gui_syncsplash(0, true, buf);
/* Tune in and delay */
radio_set(RADIO_FREQUENCY, curr_freq);
sleep(1);
/* Start IF measurement */
radio_set(RADIO_IF_MEASUREMENT, 1);
sleep(1);
/* Now check how close to the IF frequency we are */
tuned = radio_get(RADIO_TUNED);
/* add preset */
if(tuned){
snprintf(buf, 32, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10);
strcpy(presets[num_presets].name, buf);
presets[num_presets].frequency = curr_freq;
menu_insert(preset_menu, -1,
presets[num_presets].name, 0);
num_presets++;
}
curr_freq += FREQ_STEP;
}
rebuild_preset_menu();
radio_save_presets();
if(num_presets > 0 ){
curr_freq = presets[0].frequency;
radio_set(RADIO_FREQUENCY, curr_freq);
remember_frequency();
}
exit = true;
break;
default:
/* ignore button releases */
if (!(btn & BUTTON_REL))
exit = true;
break;
}
}
return true;
}
/* button preprocessor for the main menu */
int radio_menu_cb(int key, int m)
{
@ -1218,13 +1300,14 @@ bool radio_menu(void)
{ ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets },
#endif
#ifndef FM_PRESET_ADD
{ ID2P(LANG_FM_BUTTONBAR_ADD) , radio_add_preset },
{ ID2P(LANG_FM_ADD_PRESET) , radio_add_preset },
#endif
{ monomode_menu_string , toggle_mono_mode },
{ ID2P(LANG_SOUND_SETTINGS) , sound_menu },
#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
{ ID2P(LANG_RECORDING_SETTINGS) , fm_recording_settings},
#endif
{ ID2P(LANG_FM_SCAN_PRESETS) , scan_presets},
};
create_monomode_menu();