summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-02-27 09:06:30 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-02-27 09:06:30 +0000
commit2816dc9c13f204234b613db5199d2c787a11f0d8 (patch)
tree841dfbbccd0b621de0b5257c1ecf15d5aa8171a1
parent93712c97eef684c75b542ca1a30c4e9d1f3fc3fc (diff)
downloadrockbox-2816dc9c13f204234b613db5199d2c787a11f0d8.tar.gz
rockbox-2816dc9c13f204234b613db5199d2c787a11f0d8.zip
Convert the radio menus to the new system.
Change the way the presets are done (in code). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12500 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/keymaps/keymap-ondio.c7
-rw-r--r--apps/lang/english.lang14
-rw-r--r--apps/menu.c3
-rw-r--r--apps/recorder/radio.c397
-rw-r--r--apps/recorder/radio.h4
-rw-r--r--apps/settings_list.c10
6 files changed, 182 insertions, 253 deletions
diff --git a/apps/keymaps/keymap-ondio.c b/apps/keymaps/keymap-ondio.c
index 4274afc29e..401742b363 100644
--- a/apps/keymaps/keymap-ondio.c
+++ b/apps/keymaps/keymap-ondio.c
@@ -159,7 +159,7 @@ static const struct button_mapping button_context_keyboard[] = {
159 159
160 LAST_ITEM_IN_LIST 160 LAST_ITEM_IN_LIST
161}; /* button_context_keyboard */ 161}; /* button_context_keyboard */
162 162#if CONFIG_TUNER
163static const struct button_mapping button_context_radio[] = { 163static const struct button_mapping button_context_radio[] = {
164 { ACTION_FM_MENU, BUTTON_MENU | BUTTON_REPEAT, BUTTON_NONE }, 164 { ACTION_FM_MENU, BUTTON_MENU | BUTTON_REPEAT, BUTTON_NONE },
165 { ACTION_FM_RECORD_DBLPRE, BUTTON_MENU, BUTTON_NONE}, 165 { ACTION_FM_RECORD_DBLPRE, BUTTON_MENU, BUTTON_NONE},
@@ -176,7 +176,7 @@ static const struct button_mapping button_context_radio[] = {
176 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) 176 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
177 177
178}; 178};
179 179#endif
180const struct button_mapping* get_context_mapping( int context ) 180const struct button_mapping* get_context_mapping( int context )
181{ 181{
182 switch( context ) 182 switch( context )
@@ -207,9 +207,10 @@ const struct button_mapping* get_context_mapping( int context )
207 return button_context_recscreen; 207 return button_context_recscreen;
208 case CONTEXT_KEYBOARD: 208 case CONTEXT_KEYBOARD:
209 return button_context_keyboard; 209 return button_context_keyboard;
210#if CONFIG_TUNER
210 case CONTEXT_FM: 211 case CONTEXT_FM:
211 return button_context_radio; 212 return button_context_radio;
212 213#endif
213 case CONTEXT_LIST: 214 case CONTEXT_LIST:
214 case CONTEXT_MAINMENU: 215 case CONTEXT_MAINMENU:
215 default: 216 default:
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index d43317a0d4..c081e53ea7 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -10547,3 +10547,17 @@
10547 *: "Cuesheet Support" 10547 *: "Cuesheet Support"
10548 </voice> 10548 </voice>
10549</phrase> 10549</phrase>
10550<phrase>
10551 id: LANG_FM_MENU
10552 desc: fm menu title
10553 user:
10554 <source>
10555 *: "FM Radio Menu"
10556 </source>
10557 <dest>
10558 *: "FM Radio Menu"
10559 </dest>
10560 <voice>
10561 *: "FM Radio Menu"
10562 </voice>
10563</phrase>
diff --git a/apps/menu.c b/apps/menu.c
index a66652b608..986c6b7034 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -314,6 +314,9 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer)
314 /* only MT_MENU or MT_RETURN_ID is allowed in here */ 314 /* only MT_MENU or MT_RETURN_ID is allowed in here */
315 if (type == MT_RETURN_ID) 315 if (type == MT_RETURN_ID)
316 { 316 {
317 if (menu->flags&MENU_DYNAMIC_DESC)
318 return menu->menu_get_name_and_icon->list_get_name(selected_item,
319 menu->menu_get_name_and_icon->list_get_name_data, buffer);
317 return (char*)menu->strings[selected_item]; 320 return (char*)menu->strings[selected_item];
318 } 321 }
319 322
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 5ee5be14fd..555c3493a0 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -60,6 +60,8 @@
60#include "tree.h" 60#include "tree.h"
61#include "dir.h" 61#include "dir.h"
62#include "action.h" 62#include "action.h"
63#include "list.h"
64#include "menus/exported_menus.h"
63 65
64#if CONFIG_TUNER 66#if CONFIG_TUNER
65 67
@@ -101,13 +103,13 @@
101#endif 103#endif
102static struct fm_region_setting fm_region[] = { 104static struct fm_region_setting fm_region[] = {
103 /* Europe */ 105 /* Europe */
104 { LANG_FM_EUROPE, 87500000, 108000000, 50000, DEEMPH_50 BAND_LIM_EU }, 106 { 87500000, 108000000, 50000, DEEMPH_50 BAND_LIM_EU },
105 /* US / Canada */ 107 /* US / Canada */
106 { LANG_FM_US, 87900000, 107900000, 200000, DEEMPH_75 BAND_LIM_EU }, 108 { 87900000, 107900000, 200000, DEEMPH_75 BAND_LIM_EU },
107 /* Japan */ 109 /* Japan */
108 { LANG_FM_JAPAN, 76000000, 90000000, 100000, DEEMPH_50 BAND_LIM_JP }, 110 { 76000000, 90000000, 100000, DEEMPH_50 BAND_LIM_JP },
109 /* Korea */ 111 /* Korea */
110 { LANG_FM_KOREA, 87500000, 108000000, 100000, DEEMPH_50 BAND_LIM_EU }, 112 { 87500000, 108000000, 100000, DEEMPH_50 BAND_LIM_EU },
111 }; 113 };
112 114
113static int curr_preset = -1; 115static int curr_preset = -1;
@@ -123,19 +125,17 @@ static struct fmstation presets[MAX_PRESETS];
123 125
124static char filepreset[MAX_PATH]; /* preset filename variable */ 126static char filepreset[MAX_PATH]; /* preset filename variable */
125 127
126static int preset_menu; /* The menu index of the preset list */
127static struct menu_item preset_menu_items[MAX_PRESETS];
128static int num_presets = 0; /* The number of presets in the preset list */ 128static int num_presets = 0; /* The number of presets in the preset list */
129 129
130static void radio_save_presets(void); 130static void radio_save_presets(void);
131static bool handle_radio_presets(void); 131static int handle_radio_presets(void);
132static bool radio_menu(void); 132static bool radio_menu(void);
133static bool radio_add_preset(void); 133static int radio_add_preset(void);
134static bool save_preset_list(void); 134static int save_preset_list(void);
135static bool load_preset_list(void); 135static int load_preset_list(void);
136static bool clear_preset_list(void); 136static int clear_preset_list(void);
137 137
138static bool scan_presets(void); 138static int scan_presets(void);
139 139
140#ifdef SIMULATOR 140#ifdef SIMULATOR
141void radio_set(int setting, int value); 141void radio_set(int setting, int value);
@@ -1058,16 +1058,8 @@ void radio_load_presets(char *filename)
1058 presets_changed = false; 1058 presets_changed = false;
1059} 1059}
1060 1060
1061static void rebuild_preset_menu(void)
1062{
1063 int i;
1064 for(i = 0;i < num_presets;i++)
1065 {
1066 preset_menu_items[i].desc = presets[i].name;
1067 }
1068}
1069 1061
1070static bool radio_add_preset(void) 1062static int radio_add_preset(void)
1071{ 1063{
1072 char buf[MAX_FMPRESET_LEN]; 1064 char buf[MAX_FMPRESET_LEN];
1073 1065
@@ -1083,9 +1075,6 @@ static bool radio_add_preset(void)
1083#ifdef FM_PRESET_ADD /* only for archos */ 1075#ifdef FM_PRESET_ADD /* only for archos */
1084 menu_insert(preset_menu, -1, 1076 menu_insert(preset_menu, -1,
1085 presets[num_presets].name, 0); 1077 presets[num_presets].name, 0);
1086 /* We must still rebuild the menu table, since the
1087 item name pointers must be updated */
1088 rebuild_preset_menu();
1089#endif 1078#endif
1090 num_presets++; 1079 num_presets++;
1091 presets_changed = true; 1080 presets_changed = true;
@@ -1100,52 +1089,32 @@ static bool radio_add_preset(void)
1100 return true; 1089 return true;
1101} 1090}
1102 1091
1103/* button preprocessor for preset option submenu */ 1092/* needed to know which preset we are edit/delete-ing */
1104static int handle_radio_presets_menu_cb(int key, int m) 1093static int selected_preset = 0;
1105{ 1094static int radio_edit_preset(void)
1106 (void)m;
1107#ifdef FM_PRESET_ACTION
1108 switch(key)
1109 {
1110 case ACTION_F3:
1111 key = ACTION_STD_CANCEL; /* Fake an exit */
1112 action_signalscreenchange();
1113 break;
1114 }
1115#endif
1116 return key;
1117}
1118
1119static bool radio_edit_preset(void)
1120{ 1095{
1121 int pos = menu_cursor(preset_menu);
1122 char buf[MAX_FMPRESET_LEN]; 1096 char buf[MAX_FMPRESET_LEN];
1123 1097
1124 strncpy(buf, menu_description(preset_menu, pos), MAX_FMPRESET_LEN); 1098 strncpy(buf, presets[selected_preset].name, MAX_FMPRESET_LEN);
1125 1099
1126 if (!kbd_input(buf, MAX_FMPRESET_LEN)) 1100 if (!kbd_input(buf, MAX_FMPRESET_LEN))
1127 { 1101 {
1128 buf[MAX_FMPRESET_LEN] = 0; 1102 buf[MAX_FMPRESET_LEN] = 0;
1129 strcpy(presets[pos].name, buf); 1103 strcpy(presets[selected_preset].name, buf);
1130 presets_changed = true; 1104 presets_changed = true;
1131 } 1105 }
1132 return true; 1106 return true;
1133} 1107}
1134 1108
1135static bool radio_delete_preset(void) 1109static int radio_delete_preset(void)
1136{ 1110{
1137 int pos = menu_cursor(preset_menu); 1111 int pos = selected_preset;
1138 int i; 1112 int i;
1139 1113
1140 for(i = pos;i < num_presets;i++) 1114 for(i = pos;i < num_presets;i++)
1141 presets[i] = presets[i+1]; 1115 presets[i] = presets[i+1];
1142 num_presets--; 1116 num_presets--;
1143 1117
1144 menu_delete(preset_menu, pos);
1145 /* We must still rebuild the menu table, since the
1146 item name pointers must be updated */
1147 rebuild_preset_menu();
1148
1149 /* Don't ask to save when all presets are deleted. */ 1118 /* Don't ask to save when all presets are deleted. */
1150 if(num_presets > 0) 1119 if(num_presets > 0)
1151 presets_changed = true; 1120 presets_changed = true;
@@ -1160,12 +1129,12 @@ static bool radio_delete_preset(void)
1160 return true; /* Make the menu return immediately */ 1129 return true; /* Make the menu return immediately */
1161} 1130}
1162 1131
1163static bool load_preset_list(void) 1132static int load_preset_list(void)
1164{ 1133{
1165 return !rockbox_browse(FMPRESET_PATH, SHOW_FMR); 1134 return !rockbox_browse(FMPRESET_PATH, SHOW_FMR);
1166} 1135}
1167 1136
1168static bool save_preset_list(void) 1137static int save_preset_list(void)
1169{ 1138{
1170 if(num_presets != 0) 1139 if(num_presets != 0)
1171 { 1140 {
@@ -1218,7 +1187,7 @@ static bool save_preset_list(void)
1218 return true; 1187 return true;
1219} 1188}
1220 1189
1221static bool clear_preset_list(void) 1190static int clear_preset_list(void)
1222{ 1191{
1223 int i; 1192 int i;
1224 1193
@@ -1238,171 +1207,132 @@ static bool clear_preset_list(void)
1238 return true; 1207 return true;
1239} 1208}
1240 1209
1241/* little menu on what to do with a preset entry */ 1210MENUITEM_FUNCTION(radio_edit_preset_item, ID2P(LANG_FM_EDIT_PRESET),
1242static bool handle_radio_presets_menu(void) 1211 radio_edit_preset, NULL, NOICON);
1212MENUITEM_FUNCTION(radio_delete_preset_item, ID2P(LANG_FM_DELETE_PRESET),
1213 radio_delete_preset, NULL, NOICON);
1214MAKE_MENU(handle_radio_preset_menu, ID2P(LANG_FM_BUTTONBAR_PRESETS),
1215 NULL, NOICON, &radio_edit_preset_item, &radio_delete_preset_item);
1216/* present a list of preset stations */
1217char * presets_get_name(int selected_item, void * data, char *buffer)
1243{ 1218{
1244 static const struct menu_item preset_menu_items[] = { 1219 (void)data;
1245 { ID2P(LANG_FM_EDIT_PRESET), radio_edit_preset }, 1220 (void)buffer;
1246 { ID2P(LANG_FM_DELETE_PRESET), radio_delete_preset }, 1221 return presets[selected_item].name;
1247 };
1248 int m;
1249
1250 m = menu_init( preset_menu_items,
1251 sizeof preset_menu_items / sizeof(struct menu_item),
1252 handle_radio_presets_menu_cb,
1253 NULL, NULL, str(LANG_FM_BUTTONBAR_EXIT));
1254 menu_run(m);
1255 menu_exit(m);
1256 return false;
1257} 1222}
1258 1223
1259/* button preprocessor for list of preset stations menu */ 1224static int handle_radio_presets(void)
1260static int handle_radio_presets_cb(int key, int m)
1261{ 1225{
1262 (void)m; 1226 struct gui_synclist lists;
1263 1227 int result = 0;
1264 switch(key) 1228 int action = ACTION_NONE;
1265 { 1229#ifdef HAS_BUTTONBAR
1266#ifdef FM_PRESET_ADD 1230 struct gui_buttonbar buttonbar;
1267 case ACTION_STD_MENU:
1268 radio_add_preset();
1269 menu_draw(m);
1270 key = BUTTON_NONE;
1271 break;
1272#endif
1273#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
1274#ifdef FM_PRESET
1275 case ACTION_STD_QUICKSCREEN:
1276 menu_draw(m);
1277 key = ACTION_STD_CANCEL; /* Fake an exit */
1278 break;
1279#endif
1280#endif 1231#endif
1281 case ACTION_F3:
1282 case ACTION_STD_CONTEXT:
1283 {
1284 bool ret;
1285 ret = handle_radio_presets_menu();
1286 menu_draw(m);
1287 if(ret)
1288 key = SYS_USB_CONNECTED;
1289 else
1290 key = ACTION_NONE;
1291 break;
1292 }
1293 }
1294 return key;
1295}
1296 1232
1297/* present a list of preset stations */ 1233 if(presets_loaded == false)
1298static bool handle_radio_presets(void) 1234 return result;
1299{
1300 int result;
1301 bool reload_dir = false;
1302 1235
1303 if(presets_loaded) 1236#ifdef HAS_BUTTONBAR
1304 { 1237 gui_buttonbar_init(&buttonbar);
1305 rebuild_preset_menu(); 1238 gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
1306 1239 gui_buttonbar_set(&buttonbar, str(LANG_FM_BUTTONBAR_ADD),
1307 /* DIY menu handling, since we want to exit after selection */
1308 preset_menu = menu_init( preset_menu_items, num_presets,
1309 handle_radio_presets_cb,
1310 str(LANG_FM_BUTTONBAR_ADD),
1311 str(LANG_FM_BUTTONBAR_EXIT), 1240 str(LANG_FM_BUTTONBAR_EXIT),
1312 str(LANG_FM_BUTTONBAR_ACTION)); 1241 str(LANG_FM_BUTTONBAR_ACTION));
1313 if (curr_preset >= 0) 1242 gui_buttonbar_draw(&buttonbar);
1314 menu_set_cursor(preset_menu, curr_preset); 1243#endif
1315 result = menu_show(preset_menu); 1244 gui_synclist_init(&lists, presets_get_name, NULL, false, 1);
1316 menu_exit(preset_menu); 1245 gui_synclist_set_title(&lists, str(LANG_FM_BUTTONBAR_PRESETS), NOICON);
1317 if (result == MENU_SELECTED_EXIT) 1246 gui_synclist_set_icon_callback(&lists, NULL);
1318 return false; 1247 gui_synclist_set_nb_items(&lists, num_presets);
1319 else if (result == MENU_ATTACHED_USB) 1248 gui_synclist_select_item(&lists, curr_preset<0 ? 0 : curr_preset);
1320 reload_dir = true; 1249
1321 1250 action_signalscreenchange();
1322 if (result >= 0) /* A preset was selected */ 1251 while (result == 0)
1252 {
1253 gui_synclist_draw(&lists);
1254 gui_syncstatusbar_draw(&statusbars, true);
1255 action = get_action(CONTEXT_STD, HZ);
1256
1257 gui_synclist_do_button(&lists, action, LIST_WRAP_UNLESS_HELD);
1258 switch (action)
1323 { 1259 {
1324 curr_preset = menu_cursor(preset_menu); 1260 case ACTION_STD_MENU:
1325 curr_freq = presets[curr_preset].frequency; 1261 radio_add_preset();
1326 radio_set(RADIO_FREQUENCY, curr_freq); 1262 break;
1327 remember_frequency(); 1263 case ACTION_STD_CANCEL:
1264 result = 1;
1265 break;
1266 case ACTION_STD_OK:
1267 curr_preset = gui_synclist_get_sel_pos(&lists);
1268 curr_freq = presets[curr_preset].frequency;
1269 radio_set(RADIO_FREQUENCY, curr_freq);
1270 remember_frequency();
1271 result = 1;
1272 break;
1273 case ACTION_F3:
1274 case ACTION_STD_CONTEXT:
1275 selected_preset = gui_synclist_get_sel_pos(&lists);
1276 do_menu(&handle_radio_preset_menu);
1277 break;
1278 default:
1279 if(default_event_handler(action) == SYS_USB_CONNECTED)
1280 result = 2;
1328 } 1281 }
1329 } 1282 }
1330 1283 action_signalscreenchange();
1331 return reload_dir; 1284 return result - 1;
1332}
1333
1334static char monomode_menu_string[32];
1335
1336static void create_monomode_menu(void)
1337{
1338 snprintf(monomode_menu_string, sizeof monomode_menu_string,
1339 "%s: %s", str(LANG_FM_MONO_MODE),
1340 global_settings.fm_force_mono?
1341 str(LANG_SET_BOOL_YES):str(LANG_SET_BOOL_NO));
1342}
1343
1344static bool toggle_mono_mode(void)
1345{
1346 global_settings.fm_force_mono = !global_settings.fm_force_mono;
1347 radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
1348 settings_save();
1349 create_monomode_menu();
1350 return false;
1351} 1285}
1352 1286
1353static char region_menu_string[32]; 1287void toggle_mono_mode(bool mono)
1354static void create_region_menu(void)
1355{ 1288{
1356 snprintf(region_menu_string, sizeof(region_menu_string), 1289 radio_set(RADIO_FORCE_MONO, mono);
1357 "%s: %s", str(LANG_FM_REGION),
1358 str(fm_region[global_settings.fm_region].lang));
1359} 1290}
1360 1291
1361static bool toggle_region_mode(void) 1292void set_radio_region(int region)
1362{ 1293{
1363 global_settings.fm_region++;
1364 if(global_settings.fm_region >=
1365 (int)(sizeof(fm_region) / sizeof(struct fm_region_setting)))
1366 global_settings.fm_region = 0;
1367#if (CONFIG_TUNER & TEA5767) 1294#if (CONFIG_TUNER & TEA5767)
1368 radio_set(RADIO_SET_DEEMPHASIS, 1295 radio_set(RADIO_SET_DEEMPHASIS,
1369 fm_region[global_settings.fm_region].deemphasis); 1296 fm_region[region].deemphasis);
1370 radio_set(RADIO_SET_BAND, fm_region[global_settings.fm_region].band); 1297 radio_set(RADIO_SET_BAND, fm_region[region].band);
1371#endif 1298#endif
1372 /* make sure the current frequency is in the region range */ 1299 /* make sure the current frequency is in the region range */
1373 curr_freq -= (curr_freq - fm_region[global_settings.fm_region].freq_min) 1300 curr_freq -= (curr_freq - fm_region[region].freq_min)
1374 % fm_region[global_settings.fm_region].freq_step; 1301 % fm_region[region].freq_step;
1375 if(curr_freq < fm_region[global_settings.fm_region].freq_min) 1302 if(curr_freq < fm_region[region].freq_min)
1376 curr_freq = fm_region[global_settings.fm_region].freq_min; 1303 curr_freq = fm_region[region].freq_min;
1377 if(curr_freq > fm_region[global_settings.fm_region].freq_max) 1304 if(curr_freq > fm_region[region].freq_max)
1378 curr_freq = fm_region[global_settings.fm_region].freq_max; 1305 curr_freq = fm_region[region].freq_max;
1379 radio_set(RADIO_FREQUENCY, curr_freq); 1306 radio_set(RADIO_FREQUENCY, curr_freq);
1380 1307
1381 remember_frequency(); 1308 remember_frequency();
1382 create_region_menu();
1383 return false;
1384} 1309}
1385 1310
1386#ifndef FM_MODE 1311MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL);
1387static char radiomode_menu_string[32]; 1312MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
1388 1313
1389static void create_radiomode_menu(void) 1314#ifndef FM_MODE
1315char* get_mode_text(int selected_item, void * data, char *buffer)
1390{ 1316{
1391 snprintf(radiomode_menu_string, 32, "%s %s", str(LANG_FM_TUNE_MODE), 1317 (void)selected_item;
1318 (void)data;
1319 snprintf(buffer, MAX_PATH, "%s %s", str(LANG_FM_TUNE_MODE),
1392 radio_mode ? str(LANG_RADIO_PRESET_MODE) : 1320 radio_mode ? str(LANG_RADIO_PRESET_MODE) :
1393 str(LANG_RADIO_SCAN_MODE)); 1321 str(LANG_RADIO_SCAN_MODE));
1322 return buffer;
1394} 1323}
1395 1324static int toggle_radio_mode(void* param)
1396static bool toggle_radio_mode(void)
1397{ 1325{
1326 (void)param;
1398 radio_mode = (radio_mode == RADIO_SCAN_MODE) ? 1327 radio_mode = (radio_mode == RADIO_SCAN_MODE) ?
1399 RADIO_PRESET_MODE : RADIO_SCAN_MODE; 1328 RADIO_PRESET_MODE : RADIO_SCAN_MODE;
1400 create_radiomode_menu(); 1329 return 0;
1401 return false;
1402} 1330}
1331MENUITEM_FUNCTION_WPARAM_DYNTEXT(radio_mode_item, toggle_radio_mode, NULL, NULL,
1332 get_mode_text, NULL, NOICON);
1403#endif 1333#endif
1404 1334
1405static bool scan_presets(void) 1335static int scan_presets(void)
1406{ 1336{
1407 bool tuned = false, do_scan = true; 1337 bool tuned = false, do_scan = true;
1408 char buf[MAX_FMPRESET_LEN]; 1338 char buf[MAX_FMPRESET_LEN];
@@ -1473,41 +1403,13 @@ static bool scan_presets(void)
1473 return true; 1403 return true;
1474} 1404}
1475 1405
1476/* button preprocessor for the main menu */
1477static int radio_menu_cb(int key, int m)
1478{
1479 (void)m;
1480#if 0 /* this screen needs fixing! */
1481 switch(key)
1482 {
1483#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
1484#ifdef MENU_ENTER2
1485 case MENU_ENTER2:
1486#endif
1487#endif
1488 case MENU_ENTER:
1489 key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */
1490 break;
1491
1492#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
1493#ifdef MENU_ENTER2
1494 case MENU_ENTER2 | BUTTON_REL:
1495#endif
1496#endif
1497 case MENU_ENTER | BUTTON_REL:
1498 key = MENU_ENTER; /* fake downpress, next menu doesn't like release */
1499 break;
1500 }
1501#endif
1502 return key;
1503}
1504 1406
1505#ifndef SIMULATOR 1407#ifndef SIMULATOR
1506#ifdef HAVE_RECORDING 1408#ifdef HAVE_RECORDING
1507 1409
1508#if defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC 1410#if defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC
1509#define FM_RECORDING_SCREEN 1411#define FM_RECORDING_SCREEN
1510static bool fm_recording_screen(void) 1412static int fm_recording_screen(void)
1511{ 1413{
1512 bool ret; 1414 bool ret;
1513 1415
@@ -1516,7 +1418,7 @@ static bool fm_recording_screen(void)
1516 global_settings.rec_source = AUDIO_SRC_FMRADIO; 1418 global_settings.rec_source = AUDIO_SRC_FMRADIO;
1517 1419
1518 /* clearing queue seems to cure a spontaneous abort during record */ 1420 /* clearing queue seems to cure a spontaneous abort during record */
1519 while (button_get(false) != BUTTON_NONE); 1421 action_signalscreenchange();
1520 1422
1521 ret = recording_screen(true); 1423 ret = recording_screen(true);
1522 1424
@@ -1525,11 +1427,13 @@ static bool fm_recording_screen(void)
1525 1427
1526 return ret; 1428 return ret;
1527} 1429}
1430MENUITEM_FUNCTION(recscreen_item, ID2P(LANG_RECORDING_MENU),
1431 fm_recording_screen, NULL, NOICON);
1528#endif /* defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC */ 1432#endif /* defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC */
1529 1433
1530#if defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC 1434#if defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC
1531#define FM_RECORDING_SETTINGS 1435#define FM_RECORDING_SETTINGS
1532static bool fm_recording_settings(void) 1436static int fm_recording_settings(void)
1533{ 1437{
1534 bool ret = recording_menu(true); 1438 bool ret = recording_menu(true);
1535 1439
@@ -1545,54 +1449,55 @@ static bool fm_recording_settings(void)
1545 1449
1546 return ret; 1450 return ret;
1547} 1451}
1452MENUITEM_FUNCTION(recsettings_item, ID2P(LANG_RECORDING_SETTINGS),
1453 fm_recording_settings, NULL, NOICON);
1548#endif /* defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC */ 1454#endif /* defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC */
1549#endif /* HAVE_RECORDING */ 1455#endif /* HAVE_RECORDING */
1550#endif /* SIMULATOR */ 1456#endif /* SIMULATOR */
1457#ifndef FM_PRESET
1458MENUITEM_FUNCTION(radio_presets_item, ID2P(LANG_FM_BUTTONBAR_PRESETS),
1459 handle_radio_presets, NULL, NOICON);
1460#endif
1461#ifndef FM_PRESET_ADD
1462MENUITEM_FUNCTION(radio_addpreset_item, ID2P(LANG_FM_ADD_PRESET),
1463 radio_add_preset, NULL, NOICON);
1464#endif
1551 1465
1552 1466
1553/* main menu of the radio screen */ 1467MENUITEM_FUNCTION(presetload_item, ID2P(LANG_FM_PRESET_LOAD),
1554static bool radio_menu(void) 1468 load_preset_list, NULL, NOICON);
1555{ 1469MENUITEM_FUNCTION(presetsave_item, ID2P(LANG_FM_PRESET_SAVE),
1556 int m; 1470 save_preset_list, NULL, NOICON);
1557 bool result; 1471MENUITEM_FUNCTION(presetclear_item, ID2P(LANG_FM_PRESET_CLEAR),
1558 1472 clear_preset_list, NULL, NOICON);
1559 static const struct menu_item items[] = { 1473MENUITEM_FUNCTION(scan_presets_item, ID2P(LANG_FM_SCAN_PRESETS),
1560/* Add functions not accessible via buttons */ 1474 scan_presets, NULL, NOICON);
1475
1476MAKE_MENU(radio_menu_items, ID2P(LANG_FM_MENU), NULL,
1477 bitmap_icons_6x8[Icon_Radio_screen],
1561#ifndef FM_PRESET 1478#ifndef FM_PRESET
1562 { ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets }, 1479 &radio_presets_item,
1563#endif 1480#endif
1564#ifndef FM_PRESET_ADD 1481#ifndef FM_PRESET_ADD
1565 { ID2P(LANG_FM_ADD_PRESET) , radio_add_preset }, 1482 &radio_addpreset_item,
1566#endif 1483#endif
1567 { ID2P(LANG_FM_PRESET_LOAD) , load_preset_list }, 1484 &presetload_item, &presetsave_item, &presetclear_item,
1568 { ID2P(LANG_FM_PRESET_SAVE) , save_preset_list }, 1485 &force_mono,
1569 { ID2P(LANG_FM_PRESET_CLEAR) , clear_preset_list },
1570
1571 { monomode_menu_string , toggle_mono_mode },
1572#ifndef FM_MODE 1486#ifndef FM_MODE
1573 { radiomode_menu_string , toggle_radio_mode }, 1487 &radio_mode_item,
1574#endif 1488#endif
1575 { region_menu_string , toggle_region_mode }, 1489 &set_region, &sound_settings,
1576 { ID2P(LANG_SOUND_SETTINGS) , sound_menu },
1577#ifdef FM_RECORDING_SCREEN 1490#ifdef FM_RECORDING_SCREEN
1578 { ID2P(LANG_RECORDING_MENU) , fm_recording_screen }, 1491 &LANG_RECORDING_MENU,
1579#endif 1492#endif
1580#ifdef FM_RECORDING_SETTINGS 1493#ifdef FM_RECORDING_SETTINGS
1581 { ID2P(LANG_RECORDING_SETTINGS) , fm_recording_settings }, 1494 &recsettings_item,
1582#endif
1583 { ID2P(LANG_FM_SCAN_PRESETS) , scan_presets },
1584 };
1585
1586 create_monomode_menu();
1587 create_region_menu();
1588#ifndef FM_MODE
1589 create_radiomode_menu();
1590#endif 1495#endif
1591 m = menu_init(items, sizeof(items) / sizeof(*items), 1496 &scan_presets_item);
1592 radio_menu_cb, NULL, NULL, NULL); 1497/* main menu of the radio screen */
1593 result = menu_run(m); 1498static bool radio_menu(void)
1594 menu_exit(m); 1499{
1595 return result; 1500 return (bool)do_menu(&radio_menu_items);
1596} 1501}
1597 1502
1598#endif 1503#endif
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h
index bbc35b71aa..4647ae2756 100644
--- a/apps/recorder/radio.h
+++ b/apps/recorder/radio.h
@@ -32,6 +32,9 @@ void radio_pause(void);
32void radio_stop(void); 32void radio_stop(void);
33bool radio_hardware_present(void); 33bool radio_hardware_present(void);
34bool in_radio_screen(void); 34bool in_radio_screen(void);
35/* callbacks for the radio settings */
36void set_radio_region(int region);
37void toggle_mono_mode(bool mono);
35 38
36#define MAX_FMPRESET_LEN 27 39#define MAX_FMPRESET_LEN 27
37 40
@@ -43,7 +46,6 @@ struct fmstation
43 46
44struct fm_region_setting 47struct fm_region_setting
45{ 48{
46 int lang;
47 int freq_min; 49 int freq_min;
48 int freq_max; 50 int freq_max;
49 int freq_step; 51 int freq_step;
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 4442e3181f..b3a48553f1 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -43,6 +43,9 @@
43#include "peakmeter.h" 43#include "peakmeter.h"
44#endif 44#endif
45#include "menus/eq_menu.h" 45#include "menus/eq_menu.h"
46#if CONFIG_TUNER
47#include "radio.h"
48#endif
46 49
47/* some sets of values which are used more than once, to save memory */ 50/* some sets of values which are used more than once, to save memory */
48static const char off_on[] = "off,on"; 51static const char off_on[] = "off,on";
@@ -474,7 +477,7 @@ const struct settings_list settings[] = {
474 /* tuner */ 477 /* tuner */
475#if CONFIG_TUNER 478#if CONFIG_TUNER
476 OFFON_SETTING(0,fm_force_mono, LANG_FM_MONO_MODE, 479 OFFON_SETTING(0,fm_force_mono, LANG_FM_MONO_MODE,
477 false,"force fm mono", NULL), 480 false, "force fm mono", toggle_mono_mode),
478 SYSTEM_SETTING(NVRAM(4),last_frequency,0), 481 SYSTEM_SETTING(NVRAM(4),last_frequency,0),
479#endif 482#endif
480 483
@@ -1046,8 +1049,9 @@ const struct settings_list settings[] = {
1046 "disable autoresume if phones not present",NULL), 1049 "disable autoresume if phones not present",NULL),
1047#endif 1050#endif
1048#if CONFIG_TUNER 1051#if CONFIG_TUNER
1049 {F_T_INT,&global_settings.fm_region,LANG_FM_REGION,INT(0), 1052 CHOICE_SETTING(0, fm_region, LANG_FM_REGION, 0,
1050 "fm_region","eu,us,jp,kr",UNUSED}, 1053 "fm_region", "eu,us,jp,kr", set_radio_region, 4, ID2P(LANG_FM_EUROPE),
1054 ID2P(LANG_FM_US), ID2P(LANG_FM_JAPAN), ID2P(LANG_FM_KOREA)),
1051#endif 1055#endif
1052 1056
1053 OFFON_SETTING(0,audioscrobbler,LANG_AUDIOSCROBBLER, 1057 OFFON_SETTING(0,audioscrobbler,LANG_AUDIOSCROBBLER,