summaryrefslogtreecommitdiff
path: root/apps/recorder
diff options
context:
space:
mode:
Diffstat (limited to 'apps/recorder')
-rw-r--r--apps/recorder/radio.c85
1 files changed, 84 insertions, 1 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 1c54602e73..60a14eff3d 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -625,6 +625,11 @@ bool radio_screen(void)
625 ) 625 )
626 break; 626 break;
627#endif 627#endif
628 if(num_presets < 1){
629 gui_syncsplash(HZ, true, str(LANG_FM_NO_PRESETS));
630 update_screen = true;
631 break;
632 }
628 handle_radio_presets(); 633 handle_radio_presets();
629 curr_preset = find_preset(curr_freq); 634 curr_preset = find_preset(curr_freq);
630 FOR_NB_SCREENS(i){ 635 FOR_NB_SCREENS(i){
@@ -1178,6 +1183,83 @@ static bool toggle_mono_mode(void)
1178} 1183}
1179 1184
1180 1185
1186static bool scan_presets(void)
1187{
1188 bool exit = false;
1189 bool tuned = false;
1190 char buf[32];
1191 int freq, i;
1192
1193 FOR_NB_SCREENS(i){
1194 gui_textarea_clear(&screens[i]);
1195 screens[i].puts_scroll(0,0,str(LANG_FM_CLEAR_PRESETS));
1196 screens[i].puts_scroll(0,2,str(LANG_CONFIRM_WITH_PLAY_RECORDER));
1197 screens[i].puts_scroll(0,3,str(LANG_CANCEL_WITH_ANY_RECORDER));
1198 gui_textarea_update(&screens[i]);
1199 }
1200
1201 while (!exit) {
1202 int btn = button_get(true);
1203 switch (btn) {
1204 case SETTINGS_OK:
1205 FOR_NB_SCREENS(i)
1206 gui_textarea_clear(&screens[i]);
1207 curr_freq = MIN_FREQ;
1208 num_presets = 0;
1209 while(curr_freq <= MAX_FREQ){
1210 if (num_presets >= MAX_PRESETS)
1211 break;
1212
1213 freq = curr_freq /100000;
1214 snprintf(buf, 32, str(LANG_FM_SCANNING), freq/10, freq % 10);
1215 gui_syncsplash(0, true, buf);
1216
1217 /* Tune in and delay */
1218 radio_set(RADIO_FREQUENCY, curr_freq);
1219 sleep(1);
1220
1221 /* Start IF measurement */
1222 radio_set(RADIO_IF_MEASUREMENT, 1);
1223 sleep(1);
1224
1225 /* Now check how close to the IF frequency we are */
1226 tuned = radio_get(RADIO_TUNED);
1227
1228 /* add preset */
1229 if(tuned){
1230 snprintf(buf, 32, str(LANG_FM_DEFAULT_PRESET_NAME),freq/10, freq % 10);
1231 strcpy(presets[num_presets].name, buf);
1232 presets[num_presets].frequency = curr_freq;
1233 menu_insert(preset_menu, -1,
1234 presets[num_presets].name, 0);
1235 num_presets++;
1236 }
1237
1238 curr_freq += FREQ_STEP;
1239
1240 }
1241
1242 rebuild_preset_menu();
1243 radio_save_presets();
1244
1245 if(num_presets > 0 ){
1246 curr_freq = presets[0].frequency;
1247 radio_set(RADIO_FREQUENCY, curr_freq);
1248 remember_frequency();
1249 }
1250 exit = true;
1251 break;
1252
1253 default:
1254 /* ignore button releases */
1255 if (!(btn & BUTTON_REL))
1256 exit = true;
1257 break;
1258 }
1259 }
1260 return true;
1261}
1262
1181/* button preprocessor for the main menu */ 1263/* button preprocessor for the main menu */
1182int radio_menu_cb(int key, int m) 1264int radio_menu_cb(int key, int m)
1183{ 1265{
@@ -1218,13 +1300,14 @@ bool radio_menu(void)
1218 { ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets }, 1300 { ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets },
1219#endif 1301#endif
1220#ifndef FM_PRESET_ADD 1302#ifndef FM_PRESET_ADD
1221 { ID2P(LANG_FM_BUTTONBAR_ADD) , radio_add_preset }, 1303 { ID2P(LANG_FM_ADD_PRESET) , radio_add_preset },
1222#endif 1304#endif
1223 { monomode_menu_string , toggle_mono_mode }, 1305 { monomode_menu_string , toggle_mono_mode },
1224 { ID2P(LANG_SOUND_SETTINGS) , sound_menu }, 1306 { ID2P(LANG_SOUND_SETTINGS) , sound_menu },
1225#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC) 1307#if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
1226 { ID2P(LANG_RECORDING_SETTINGS) , fm_recording_settings}, 1308 { ID2P(LANG_RECORDING_SETTINGS) , fm_recording_settings},
1227#endif 1309#endif
1310 { ID2P(LANG_FM_SCAN_PRESETS) , scan_presets},
1228 }; 1311 };
1229 1312
1230 create_monomode_menu(); 1313 create_monomode_menu();