summaryrefslogtreecommitdiff
path: root/apps/menus/radio_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/menus/radio_menu.c')
-rw-r--r--apps/menus/radio_menu.c145
1 files changed, 145 insertions, 0 deletions
diff --git a/apps/menus/radio_menu.c b/apps/menus/radio_menu.c
new file mode 100644
index 0000000000..2a15fe8ee5
--- /dev/null
+++ b/apps/menus/radio_menu.c
@@ -0,0 +1,145 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2003 Linus Nielsen Feltzing
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdio.h>
23#include "config.h"
24#include "menu.h"
25#include "icon.h"
26#include "radio.h"
27#include "lang.h"
28#include "settings.h"
29#include "presets.h"
30#include "exported_menus.h"
31#include "recording.h" /* recording_screen() */
32#include "sound_menu.h" /* recording_menu() */
33
34
35#if defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC
36#define FM_RECORDING_SCREEN
37static int fm_recording_screen(void)
38{
39 bool ret;
40
41 /* switch recording source to FMRADIO for the duration */
42 int rec_source = global_settings.rec_source;
43 global_settings.rec_source = AUDIO_SRC_FMRADIO;
44 ret = recording_screen(true);
45
46 /* safe to reset as changing sources is prohibited here */
47 global_settings.rec_source = rec_source;
48
49 return ret;
50}
51
52MENUITEM_FUNCTION(recscreen_item, 0, ID2P(LANG_RECORDING),
53 fm_recording_screen, NULL, NULL, Icon_Recording);
54#endif /* defined(HAVE_FMRADIO_REC) && CONFIG_CODEC == SWCODEC */
55
56#if defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC
57#define FM_RECORDING_SETTINGS
58static int fm_recording_settings(void)
59{
60 bool ret = recording_menu(true);
61
62#if CONFIG_CODEC != SWCODEC
63 if (!ret)
64 {
65 struct audio_recording_options rec_options;
66 rec_init_recording_options(&rec_options);
67 rec_options.rec_source = AUDIO_SRC_LINEIN;
68 rec_set_recording_options(&rec_options);
69 }
70#endif
71
72 return ret;
73}
74
75MENUITEM_FUNCTION(recsettings_item, 0, ID2P(LANG_RECORDING_SETTINGS),
76 fm_recording_settings, NULL, NULL, Icon_Recording);
77#endif /* defined(HAVE_FMRADIO_REC) || CONFIG_CODEC != SWCODEC */
78
79#ifndef FM_PRESET
80MENUITEM_FUNCTION(radio_presets_item, 0, ID2P(LANG_PRESET),
81 handle_radio_presets, NULL, NULL, Icon_NOICON);
82#endif
83#ifndef FM_PRESET_ADD
84MENUITEM_FUNCTION(radio_addpreset_item, 0, ID2P(LANG_FM_ADD_PRESET),
85 handle_radio_add_preset, NULL, NULL, Icon_NOICON);
86#endif
87
88MENUITEM_FUNCTION(presetload_item, 0, ID2P(LANG_FM_PRESET_LOAD),
89 preset_list_load, NULL, NULL, Icon_NOICON);
90MENUITEM_FUNCTION(presetsave_item, 0, ID2P(LANG_FM_PRESET_SAVE),
91 preset_list_save, NULL, NULL, Icon_NOICON);
92MENUITEM_FUNCTION(presetclear_item, 0, ID2P(LANG_FM_PRESET_CLEAR),
93 preset_list_clear, NULL, NULL, Icon_NOICON);
94
95MENUITEM_SETTING(set_region, &global_settings.fm_region, NULL);
96MENUITEM_SETTING(force_mono, &global_settings.fm_force_mono, NULL);
97
98#ifndef FM_MODE
99extern int radio_mode;
100static char* get_mode_text(int selected_item, void * data, char *buffer)
101{
102 (void)selected_item;
103 (void)data;
104 snprintf(buffer, MAX_PATH, "%s %s", str(LANG_MODE),
105 radio_mode ? str(LANG_PRESET) :
106 str(LANG_RADIO_SCAN_MODE));
107 return buffer;
108}
109static int toggle_radio_mode(void)
110{
111 radio_mode = (radio_mode == RADIO_SCAN_MODE) ?
112 RADIO_PRESET_MODE : RADIO_SCAN_MODE;
113 return 0;
114}
115MENUITEM_FUNCTION_DYNTEXT(radio_mode_item, 0,
116 toggle_radio_mode, NULL,
117 get_mode_text, NULL, NULL, NULL, Icon_NOICON);
118#endif
119
120MENUITEM_FUNCTION(scan_presets_item, MENU_FUNC_USEPARAM,
121 ID2P(LANG_FM_SCAN_PRESETS),
122 presets_scan, NULL, NULL, Icon_NOICON);
123
124MAKE_MENU(radio_settings_menu, ID2P(LANG_FM_MENU), NULL,
125 Icon_Radio_screen,
126#ifndef FM_PRESET
127 &radio_presets_item,
128#endif
129#ifndef FM_PRESET_ADD
130 &radio_addpreset_item,
131#endif
132 &presetload_item, &presetsave_item, &presetclear_item,
133 &force_mono,
134#ifndef FM_MODE
135 &radio_mode_item,
136#endif
137 &set_region, &sound_settings,
138#ifdef FM_RECORDING_SCREEN
139 &recscreen_item,
140#endif
141#ifdef FM_RECORDING_SETTINGS
142 &recsettings_item,
143#endif
144 &scan_presets_item);
145