2003-05-03 02:40:09 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Linus Nielsen Feltzing
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2003-05-04 02:23:18 +00:00
|
|
|
#include "sprintf.h"
|
2003-05-03 02:40:09 +00:00
|
|
|
#include "mas.h"
|
|
|
|
#include "settings.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "status.h"
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "mpeg.h"
|
2005-04-04 12:36:06 +00:00
|
|
|
#include "audio.h"
|
2004-01-05 22:46:54 +00:00
|
|
|
#include "mp3_playback.h"
|
2003-05-04 02:23:18 +00:00
|
|
|
#include "ctype.h"
|
|
|
|
#include "file.h"
|
|
|
|
#include "errno.h"
|
|
|
|
#include "atoi.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "radio.h"
|
|
|
|
#include "menu.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "screens.h"
|
2003-11-05 09:46:08 +00:00
|
|
|
#include "peakmeter.h"
|
|
|
|
#include "lang.h"
|
2003-11-06 00:47:47 +00:00
|
|
|
#include "font.h"
|
2003-11-20 00:33:43 +00:00
|
|
|
#include "sound_menu.h"
|
|
|
|
#include "recording.h"
|
2004-03-19 22:15:53 +00:00
|
|
|
#include "talk.h"
|
2004-10-15 21:41:46 +00:00
|
|
|
#include "tuner.h"
|
|
|
|
#include "hwcompat.h"
|
2004-10-17 08:53:18 +00:00
|
|
|
#include "power.h"
|
2005-04-01 14:09:41 +00:00
|
|
|
#include "sound.h"
|
2005-11-13 21:03:53 +00:00
|
|
|
#include "screen_access.h"
|
|
|
|
#include "statusbar.h"
|
|
|
|
#include "textarea.h"
|
|
|
|
#include "splash.h"
|
2005-11-19 14:54:41 +00:00
|
|
|
#include "yesno.h"
|
2005-11-20 01:02:14 +00:00
|
|
|
#include "buttonbar.h"
|
2005-11-19 19:23:44 +00:00
|
|
|
#include "power.h"
|
2006-04-02 12:23:08 +00:00
|
|
|
#include "tree.h"
|
|
|
|
#include "dir.h"
|
2006-09-22 12:18:58 +00:00
|
|
|
#include "action.h"
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2004-09-28 22:13:26 +00:00
|
|
|
#ifdef CONFIG_TUNER
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2004-10-10 17:12:43 +00:00
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2006-09-22 12:18:58 +00:00
|
|
|
#define FM_RECORD
|
|
|
|
#define FM_PRESET_ADD
|
|
|
|
#define FM_PRESET_ACTION
|
|
|
|
#define FM_PRESET
|
2006-09-23 11:05:13 +00:00
|
|
|
#define FM_MODE
|
2005-11-29 15:10:07 +00:00
|
|
|
|
2005-12-15 01:11:19 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2006-09-22 12:18:58 +00:00
|
|
|
#define FM_PRESET
|
2006-09-23 11:05:13 +00:00
|
|
|
#define FM_MODE
|
2006-09-23 12:22:01 +00:00
|
|
|
#define FM_NEXT_PRESET
|
|
|
|
#define FM_PREV_PRESET
|
2005-11-29 15:10:07 +00:00
|
|
|
|
2006-07-21 08:42:28 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
|
2006-09-22 12:18:58 +00:00
|
|
|
#define FM_PRESET
|
2006-09-23 11:05:13 +00:00
|
|
|
#define FM_MODE
|
2006-09-22 12:18:58 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
|
|
#define FM_RECORD_DBLPRE
|
|
|
|
#define FM_RECORD
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
#define RADIO_SCAN_MODE 0
|
|
|
|
#define RADIO_PRESET_MODE 1
|
|
|
|
|
2006-10-05 12:40:13 +00:00
|
|
|
#if (CONFIG_TUNER & TEA5767)
|
|
|
|
#define DEEMPH_50 0,
|
|
|
|
#define DEEMPH_75 1,
|
|
|
|
#define BAND_LIM_EU 0
|
|
|
|
#define BAND_LIM_JP 1
|
|
|
|
#else
|
|
|
|
#define DEEMPH_50
|
|
|
|
#define DEEMPH_75
|
|
|
|
#define BAND_LIM_EU
|
|
|
|
#define BAND_LIM_JP
|
|
|
|
#endif
|
|
|
|
static struct fm_region_setting fm_region[] = {
|
|
|
|
/* Europe */
|
|
|
|
{ LANG_FM_EUROPE, 87500000, 108000000, 50000, DEEMPH_50 BAND_LIM_EU },
|
|
|
|
/* US / Canada */
|
|
|
|
{ LANG_FM_US, 87900000, 107900000, 200000, DEEMPH_75 BAND_LIM_EU },
|
|
|
|
/* Japan */
|
|
|
|
{ LANG_FM_JAPAN, 76000000, 90000000, 100000, DEEMPH_50 BAND_LIM_JP },
|
|
|
|
/* Korea */
|
|
|
|
{ LANG_FM_KOREA, 87500000, 108000000, 100000, DEEMPH_50 BAND_LIM_EU },
|
|
|
|
};
|
|
|
|
|
2003-05-04 02:23:18 +00:00
|
|
|
static int curr_preset = -1;
|
2004-07-12 13:28:44 +00:00
|
|
|
static int curr_freq;
|
2005-11-13 21:03:53 +00:00
|
|
|
static int radio_mode = RADIO_SCAN_MODE;
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2005-11-19 19:23:44 +00:00
|
|
|
static int radio_status = FMRADIO_OFF;
|
2006-08-28 22:38:41 +00:00
|
|
|
static bool in_screen = false;
|
2005-11-19 19:23:44 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
#define MAX_PRESETS 64
|
2006-04-02 12:23:08 +00:00
|
|
|
static bool presets_loaded = false, presets_changed = false;
|
2003-05-04 02:23:18 +00:00
|
|
|
static struct fmstation presets[MAX_PRESETS];
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
static char filepreset[MAX_PATH]; /* preset filename variable */
|
2003-05-04 22:58:12 +00:00
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
static int preset_menu; /* The menu index of the preset list */
|
|
|
|
static struct menu_item preset_menu_items[MAX_PRESETS];
|
2006-04-02 12:23:08 +00:00
|
|
|
static int num_presets = 0; /* The number of presets in the preset list */
|
2004-07-05 14:30:17 +00:00
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static void radio_save_presets(void);
|
|
|
|
static bool handle_radio_presets(void);
|
|
|
|
static bool radio_menu(void);
|
|
|
|
static bool radio_add_preset(void);
|
|
|
|
static bool save_preset_list(void);
|
|
|
|
static bool load_preset_list(void);
|
|
|
|
static bool clear_preset_list(void);
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
static bool scan_presets(void);
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2005-08-16 06:50:25 +00:00
|
|
|
#ifdef SIMULATOR
|
|
|
|
void radio_set(int setting, int value);
|
|
|
|
int radio_get(int setting);
|
|
|
|
#else
|
2004-10-19 18:00:41 +00:00
|
|
|
#if CONFIG_TUNER == S1A0903X01 /* FM recorder */
|
2004-10-15 21:41:46 +00:00
|
|
|
#define radio_set samsung_set
|
|
|
|
#define radio_get samsung_get
|
2006-07-21 08:42:28 +00:00
|
|
|
#elif CONFIG_TUNER == TEA5767 /* iriver, iaudio */
|
2004-10-15 21:41:46 +00:00
|
|
|
#define radio_set philips_set
|
|
|
|
#define radio_get philips_get
|
2004-10-19 18:00:41 +00:00
|
|
|
#elif CONFIG_TUNER == (S1A0903X01 | TEA5767) /* OndioFM */
|
2006-12-25 14:01:47 +00:00
|
|
|
static void (*radio_set)(int setting, int value);
|
|
|
|
static int (*radio_get)(int setting);
|
2004-10-15 21:41:46 +00:00
|
|
|
#endif
|
2005-08-16 06:50:25 +00:00
|
|
|
#endif
|
2004-10-15 21:41:46 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
/* Function to manipulate all yesno dialogues.
|
|
|
|
This function needs the output text as an argument. */
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool yesno_pop(char* text)
|
2006-04-02 12:23:08 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-15 21:41:46 +00:00
|
|
|
void radio_init(void)
|
2003-05-09 00:14:59 +00:00
|
|
|
{
|
2005-08-16 06:50:25 +00:00
|
|
|
#ifndef SIMULATOR
|
2004-10-15 21:41:46 +00:00
|
|
|
#if CONFIG_TUNER == (S1A0903X01 | TEA5767)
|
|
|
|
if (read_hw_mask() & TUNER_MODEL)
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
2004-10-15 21:41:46 +00:00
|
|
|
radio_set = philips_set;
|
|
|
|
radio_get = philips_get;
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
2004-10-15 21:41:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
radio_set = samsung_set;
|
|
|
|
radio_get = samsung_get;
|
|
|
|
}
|
2005-08-16 06:50:25 +00:00
|
|
|
#endif
|
2004-10-15 21:41:46 +00:00
|
|
|
#endif
|
2004-11-22 06:34:14 +00:00
|
|
|
radio_stop();
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
2003-05-09 00:14:59 +00:00
|
|
|
|
2005-11-19 19:23:44 +00:00
|
|
|
int get_radio_status(void)
|
|
|
|
{
|
|
|
|
return radio_status;
|
|
|
|
}
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
bool in_radio_screen(void)
|
|
|
|
{
|
|
|
|
return in_screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* secret flag for starting paused - prevents unmute */
|
|
|
|
#define FMRADIO_START_PAUSED 0x8000
|
|
|
|
void radio_start(void)
|
|
|
|
{
|
|
|
|
bool start_paused;
|
|
|
|
int mute_timeout;
|
|
|
|
|
|
|
|
if(radio_status == FMRADIO_PLAYING)
|
|
|
|
return;
|
|
|
|
|
|
|
|
start_paused = radio_status & FMRADIO_START_PAUSED;
|
|
|
|
/* clear flag before any yielding */
|
|
|
|
radio_status &= ~FMRADIO_START_PAUSED;
|
|
|
|
|
|
|
|
if(radio_status == FMRADIO_OFF)
|
|
|
|
radio_power(true);
|
|
|
|
|
2007-01-24 02:19:22 +00:00
|
|
|
curr_freq = global_status.last_frequency
|
2006-10-05 12:40:13 +00:00
|
|
|
* fm_region[global_settings.fm_region].freq_step
|
|
|
|
+ fm_region[global_settings.fm_region].freq_min;
|
2006-08-28 22:38:41 +00:00
|
|
|
|
|
|
|
radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
|
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
|
|
|
|
if(radio_status == FMRADIO_OFF)
|
|
|
|
{
|
|
|
|
radio_set(RADIO_IF_MEASUREMENT, 0);
|
|
|
|
radio_set(RADIO_SENSITIVITY, 0);
|
|
|
|
radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
|
2006-10-12 19:27:00 +00:00
|
|
|
#if (CONFIG_TUNER & TEA5767)
|
|
|
|
radio_set(RADIO_SET_DEEMPHASIS,
|
|
|
|
fm_region[global_settings.fm_region].deemphasis);
|
|
|
|
radio_set(RADIO_SET_BAND, fm_region[global_settings.fm_region].band);
|
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
mute_timeout = current_tick + 1*HZ;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* paused */
|
|
|
|
mute_timeout = current_tick + 2*HZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!radio_get(RADIO_STEREO) && !radio_get(RADIO_TUNED))
|
|
|
|
{
|
|
|
|
if(TIME_AFTER(current_tick, mute_timeout))
|
|
|
|
break;
|
|
|
|
yield();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* keep radio from sounding initially */
|
|
|
|
if(!start_paused)
|
|
|
|
radio_set(RADIO_MUTE, 0);
|
|
|
|
|
|
|
|
radio_status = FMRADIO_PLAYING;
|
|
|
|
} /* radio_start */
|
|
|
|
|
|
|
|
void radio_pause(void)
|
|
|
|
{
|
|
|
|
if(radio_status == FMRADIO_PAUSED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(radio_status == FMRADIO_OFF)
|
|
|
|
{
|
|
|
|
radio_status |= FMRADIO_START_PAUSED;
|
|
|
|
radio_start();
|
|
|
|
}
|
|
|
|
|
|
|
|
radio_set(RADIO_MUTE, 1);
|
|
|
|
radio_set(RADIO_SLEEP, 1);
|
|
|
|
|
|
|
|
radio_status = FMRADIO_PAUSED;
|
|
|
|
} /* radio_pause */
|
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
void radio_stop(void)
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
|
|
|
if(radio_status == FMRADIO_OFF)
|
|
|
|
return;
|
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
radio_set(RADIO_MUTE, 1);
|
2004-10-19 08:20:38 +00:00
|
|
|
radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
|
2005-11-19 19:23:44 +00:00
|
|
|
radio_status = FMRADIO_OFF;
|
|
|
|
radio_power(false); /* status update, power off if avail. */
|
2006-08-28 22:38:41 +00:00
|
|
|
} /* radio_stop */
|
2003-05-09 00:14:59 +00:00
|
|
|
|
2003-12-19 01:24:02 +00:00
|
|
|
bool radio_hardware_present(void)
|
|
|
|
{
|
2004-10-17 17:49:30 +00:00
|
|
|
#ifdef HAVE_TUNER_PWR_CTRL
|
|
|
|
bool ret;
|
2005-11-19 19:23:44 +00:00
|
|
|
bool fmstatus = radio_power(true); /* power it up */
|
2004-10-17 17:49:30 +00:00
|
|
|
ret = radio_get(RADIO_PRESENT);
|
2005-11-19 19:23:44 +00:00
|
|
|
radio_power(fmstatus); /* restore previous state */
|
2004-10-17 17:49:30 +00:00
|
|
|
return ret;
|
|
|
|
#else
|
2004-10-15 21:41:46 +00:00
|
|
|
return radio_get(RADIO_PRESENT);
|
2004-10-17 17:49:30 +00:00
|
|
|
#endif
|
2003-12-19 01:24:02 +00:00
|
|
|
}
|
|
|
|
|
2003-05-04 02:23:18 +00:00
|
|
|
static int find_preset(int freq)
|
|
|
|
{
|
|
|
|
int i;
|
2006-04-02 12:23:08 +00:00
|
|
|
if(num_presets < 1)
|
|
|
|
return -1;
|
2003-05-04 13:05:30 +00:00
|
|
|
for(i = 0;i < MAX_PRESETS;i++)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2003-05-04 13:05:30 +00:00
|
|
|
if(freq == presets[i].frequency)
|
|
|
|
return i;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
static int find_closest_preset(int freq)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int diff;
|
2006-10-05 12:40:13 +00:00
|
|
|
int min_diff = fm_region[global_settings.fm_region].freq_min;
|
2005-11-13 21:03:53 +00:00
|
|
|
int preset = -1;
|
|
|
|
|
|
|
|
for(i = 0;i < MAX_PRESETS;i++)
|
|
|
|
{
|
|
|
|
diff = freq - presets[i].frequency;
|
|
|
|
if(diff==0)
|
|
|
|
return i;
|
|
|
|
if(diff < 0)
|
|
|
|
diff = -diff;
|
2006-08-28 22:38:41 +00:00
|
|
|
if(diff < min_diff)
|
2005-11-13 21:03:53 +00:00
|
|
|
{
|
|
|
|
preset = i;
|
2006-08-28 22:38:41 +00:00
|
|
|
min_diff = diff;
|
2005-11-13 21:03:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return preset;
|
|
|
|
}
|
|
|
|
|
2004-07-12 13:28:44 +00:00
|
|
|
static void remember_frequency(void)
|
|
|
|
{
|
2007-01-24 02:19:22 +00:00
|
|
|
global_status.last_frequency = (curr_freq
|
2006-10-05 12:40:13 +00:00
|
|
|
- fm_region[global_settings.fm_region].freq_min)
|
|
|
|
/ fm_region[global_settings.fm_region].freq_step;
|
2007-01-24 02:19:22 +00:00
|
|
|
status_save();
|
2004-07-12 13:28:44 +00:00
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static void next_preset(int direction)
|
2005-11-13 21:03:53 +00:00
|
|
|
{
|
|
|
|
if (num_presets < 1)
|
|
|
|
return;
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
if(curr_preset == -1)
|
|
|
|
curr_preset = find_closest_preset(curr_freq);
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
if(direction > 0)
|
|
|
|
if(curr_preset == num_presets - 1)
|
|
|
|
curr_preset = 0;
|
2005-11-13 21:03:53 +00:00
|
|
|
else
|
2006-04-02 12:23:08 +00:00
|
|
|
curr_preset++;
|
2005-11-13 21:03:53 +00:00
|
|
|
else
|
2006-04-02 12:23:08 +00:00
|
|
|
if(curr_preset == 0)
|
|
|
|
curr_preset = num_presets - 1;
|
|
|
|
else
|
|
|
|
curr_preset--;
|
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
curr_freq = presets[curr_preset].frequency;
|
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
remember_frequency();
|
|
|
|
}
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
bool radio_screen(void)
|
|
|
|
{
|
2004-01-21 14:58:40 +00:00
|
|
|
char buf[MAX_PATH];
|
2003-05-03 02:40:09 +00:00
|
|
|
bool done = false;
|
2005-08-13 17:35:02 +00:00
|
|
|
int button, lastbutton = BUTTON_NONE;
|
2005-09-05 19:17:23 +00:00
|
|
|
#ifdef FM_RECORD_DBLPRE
|
|
|
|
unsigned long rec_lastclick = 0;
|
|
|
|
#endif
|
2005-11-13 21:03:53 +00:00
|
|
|
int freq, i;
|
2004-10-19 08:20:38 +00:00
|
|
|
bool tuned;
|
2003-11-06 00:47:47 +00:00
|
|
|
bool stereo = false;
|
2003-05-03 02:40:09 +00:00
|
|
|
int search_dir = 0;
|
2005-11-13 21:03:53 +00:00
|
|
|
int fh;
|
2004-07-02 07:43:49 +00:00
|
|
|
bool last_stereo_status = false;
|
2003-11-06 00:47:47 +00:00
|
|
|
int top_of_screen = 0;
|
2003-11-05 09:46:08 +00:00
|
|
|
bool update_screen = true;
|
|
|
|
int timeout = current_tick + HZ/10;
|
2003-11-06 00:47:47 +00:00
|
|
|
bool screen_freeze = false;
|
2003-11-20 00:33:43 +00:00
|
|
|
bool have_recorded = false;
|
2005-08-13 17:35:02 +00:00
|
|
|
unsigned int seconds = 0;
|
2003-11-20 00:33:43 +00:00
|
|
|
unsigned int last_seconds = 0;
|
2006-03-03 19:41:16 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2003-11-20 00:33:43 +00:00
|
|
|
int hours, minutes;
|
2006-11-06 18:07:30 +00:00
|
|
|
struct audio_recording_options rec_options;
|
2006-03-03 19:41:16 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
bool keep_playing = false;
|
2005-11-13 21:03:53 +00:00
|
|
|
bool statusbar = global_settings.statusbar;
|
2006-03-07 11:49:06 +00:00
|
|
|
int button_timeout = current_tick + (2*HZ);
|
2005-11-20 01:02:14 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
struct gui_buttonbar buttonbar;
|
|
|
|
gui_buttonbar_init(&buttonbar);
|
|
|
|
gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
|
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
/* change status to "in screen" */
|
|
|
|
in_screen = true;
|
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
/* always display status bar in radio screen for now */
|
|
|
|
global_settings.statusbar = true;
|
2006-04-02 12:23:08 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
screen_set_xmargin(&screens[i],0);
|
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars,true);
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
fh = font_get(FONT_UI)->height;
|
|
|
|
|
2003-11-06 00:47:47 +00:00
|
|
|
/* Adjust for font size, trying to center the information vertically */
|
|
|
|
if(fh < 10)
|
|
|
|
top_of_screen = 1;
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
if(!num_presets)
|
|
|
|
{
|
|
|
|
memset(presets, 0, sizeof(presets));
|
|
|
|
radio_load_presets(global_settings.fmr_file);
|
|
|
|
}
|
|
|
|
|
2004-07-02 07:43:49 +00:00
|
|
|
#ifndef SIMULATOR
|
2006-08-28 22:38:41 +00:00
|
|
|
if(radio_status == FMRADIO_OFF)
|
|
|
|
audio_stop();
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2004-06-04 12:34:29 +00:00
|
|
|
if(rec_create_directory() > 0)
|
|
|
|
have_recorded = true;
|
2005-08-13 17:35:02 +00:00
|
|
|
|
2006-04-30 23:18:21 +00:00
|
|
|
audio_init_recording(talk_get_bufsize());
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2004-07-06 12:17:14 +00:00
|
|
|
sound_settings_apply();
|
2003-11-20 00:33:43 +00:00
|
|
|
/* Yes, we use the D/A for monitoring */
|
|
|
|
peak_meter_playback(true);
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
peak_meter_enabled = true;
|
2004-03-19 22:15:53 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
rec_init_recording_options(&rec_options);
|
|
|
|
rec_options.rec_source = AUDIO_SRC_LINEIN;
|
|
|
|
rec_set_recording_options(&rec_options);
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
|
|
|
|
sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN);
|
2006-07-21 08:42:28 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
#endif /* CONFIG_CODEC != SWCODEC */
|
|
|
|
#endif /* ndef SIMULATOR */
|
2005-08-13 17:35:02 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
/* turn on radio */
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
rec_set_source(AUDIO_SRC_FMRADIO, (radio_status == FMRADIO_PAUSED) ?
|
|
|
|
SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
|
|
|
|
#else
|
|
|
|
if (radio_status == FMRADIO_OFF)
|
|
|
|
radio_start();
|
2004-07-02 07:43:49 +00:00
|
|
|
#endif
|
2004-07-12 13:28:44 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
/* I hate this thing with vehement passion (jhMikeS): */
|
2006-04-02 12:23:08 +00:00
|
|
|
if(num_presets == 0 && yesno_pop(str(LANG_FM_FIRST_AUTOSCAN)))
|
|
|
|
scan_presets();
|
2004-07-05 14:30:17 +00:00
|
|
|
|
2003-05-04 02:23:18 +00:00
|
|
|
curr_preset = find_preset(curr_freq);
|
2005-11-13 21:03:53 +00:00
|
|
|
if(curr_preset != -1)
|
|
|
|
radio_mode = RADIO_PRESET_MODE;
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2005-11-20 01:02:14 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
2006-08-28 22:38:41 +00:00
|
|
|
gui_buttonbar_set(&buttonbar, str(LANG_BUTTONBAR_MENU),
|
|
|
|
str(LANG_FM_BUTTONBAR_PRESETS), str(LANG_FM_BUTTONBAR_RECORD));
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif
|
2003-11-05 09:46:08 +00:00
|
|
|
|
2005-09-29 11:19:55 +00:00
|
|
|
cpu_idle_mode(true);
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
while(!done)
|
|
|
|
{
|
|
|
|
if(search_dir)
|
|
|
|
{
|
2006-10-05 12:40:13 +00:00
|
|
|
curr_freq += search_dir
|
|
|
|
* fm_region[global_settings.fm_region].freq_step;
|
|
|
|
if(curr_freq < fm_region[global_settings.fm_region].freq_min)
|
|
|
|
curr_freq = fm_region[global_settings.fm_region].freq_max;
|
|
|
|
if(curr_freq > fm_region[global_settings.fm_region].freq_max)
|
|
|
|
curr_freq = fm_region[global_settings.fm_region].freq_min;
|
2003-05-03 02:40:09 +00:00
|
|
|
|
|
|
|
/* Tune in and delay */
|
2004-07-05 14:30:17 +00:00
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
2003-11-05 09:46:08 +00:00
|
|
|
sleep(1);
|
2003-05-03 02:40:09 +00:00
|
|
|
|
|
|
|
/* Start IF measurement */
|
2004-07-05 14:30:17 +00:00
|
|
|
radio_set(RADIO_IF_MEASUREMENT, 1);
|
2003-11-05 09:46:08 +00:00
|
|
|
sleep(1);
|
2003-05-03 02:40:09 +00:00
|
|
|
|
|
|
|
/* Now check how close to the IF frequency we are */
|
2004-10-19 08:20:38 +00:00
|
|
|
tuned = radio_get(RADIO_TUNED);
|
2003-05-03 02:40:09 +00:00
|
|
|
|
2004-10-18 07:58:59 +00:00
|
|
|
/* Stop searching if the tuning is close */
|
2004-10-19 08:20:38 +00:00
|
|
|
if(tuned)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2003-05-03 02:40:09 +00:00
|
|
|
search_dir = 0;
|
2003-05-04 02:23:18 +00:00
|
|
|
curr_preset = find_preset(curr_freq);
|
2004-07-12 13:28:44 +00:00
|
|
|
remember_frequency();
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
2003-11-05 09:46:08 +00:00
|
|
|
|
|
|
|
update_screen = true;
|
2003-05-03 02:40:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(search_dir)
|
|
|
|
button = button_get(false);
|
|
|
|
else
|
2006-09-22 12:18:58 +00:00
|
|
|
button = get_action(CONTEXT_FM, HZ / PEAK_METER_FPS);
|
|
|
|
if (button != ACTION_NONE)
|
2006-03-07 11:49:06 +00:00
|
|
|
{
|
|
|
|
cpu_idle_mode(false);
|
|
|
|
button_timeout = current_tick + (2*HZ);
|
|
|
|
}
|
2003-05-03 02:40:09 +00:00
|
|
|
switch(button)
|
|
|
|
{
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_STOP:
|
2006-08-28 22:38:41 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() == AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-04-04 12:36:06 +00:00
|
|
|
audio_stop();
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
|
|
|
else
|
2004-07-02 07:43:49 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
|
|
|
done = true;
|
2006-04-02 12:23:08 +00:00
|
|
|
if(presets_changed)
|
|
|
|
{
|
|
|
|
if(yesno_pop(str(LANG_FM_SAVE_CHANGES)))
|
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
if(filepreset[0] == '\0')
|
2006-04-02 12:23:08 +00:00
|
|
|
save_preset_list();
|
|
|
|
else
|
|
|
|
radio_save_presets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Clear the preset list on exit. */
|
|
|
|
clear_preset_list();
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
|
|
|
update_screen = true;
|
|
|
|
break;
|
2003-05-09 00:14:59 +00:00
|
|
|
|
2004-10-10 17:12:43 +00:00
|
|
|
#ifdef FM_RECORD
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_RECORD:
|
2005-09-05 19:17:23 +00:00
|
|
|
#ifdef FM_RECORD_DBLPRE
|
2006-09-22 12:18:58 +00:00
|
|
|
if (lastbutton != ACTION_FM_RECORD_DBLPRE)
|
2005-09-05 19:17:23 +00:00
|
|
|
{
|
|
|
|
rec_lastclick = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (current_tick - rec_lastclick > HZ/2)
|
|
|
|
{
|
|
|
|
rec_lastclick = current_tick;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2004-07-02 07:43:49 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() == AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
rec_new_file();
|
2003-11-20 00:33:43 +00:00
|
|
|
update_screen = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-31 03:13:29 +00:00
|
|
|
have_recorded = true;
|
2006-08-28 22:38:41 +00:00
|
|
|
rec_record();
|
2003-11-20 00:33:43 +00:00
|
|
|
update_screen = true;
|
|
|
|
}
|
2004-07-02 07:43:49 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
last_seconds = 0;
|
2003-05-09 00:14:59 +00:00
|
|
|
break;
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif /* #ifdef FM_RECORD */
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_EXIT:
|
2006-08-28 22:38:41 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC && !defined(SIMULATOR)
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() == AUDIO_STATUS_RECORD)
|
|
|
|
audio_stop();
|
2005-03-06 18:03:01 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
keep_playing = true;
|
2005-11-13 21:03:53 +00:00
|
|
|
done = true;
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
if(presets_changed)
|
|
|
|
{
|
|
|
|
if(yesno_pop(str(LANG_FM_SAVE_CHANGES)))
|
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
if(filepreset[0] == '\0')
|
2006-04-02 12:23:08 +00:00
|
|
|
save_preset_list();
|
|
|
|
else
|
|
|
|
radio_save_presets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the preset list on exit. */
|
|
|
|
clear_preset_list();
|
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
break;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
|
|
|
case ACTION_STD_PREV:
|
2005-11-13 21:03:53 +00:00
|
|
|
if(radio_mode == RADIO_SCAN_MODE)
|
|
|
|
{
|
2006-10-05 12:40:13 +00:00
|
|
|
curr_freq
|
|
|
|
-= fm_region[global_settings.fm_region].freq_step;
|
|
|
|
if(curr_freq < fm_region[global_settings.fm_region].freq_min)
|
|
|
|
curr_freq
|
|
|
|
= fm_region[global_settings.fm_region].freq_max;
|
2005-11-13 21:03:53 +00:00
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
curr_preset = find_preset(curr_freq);
|
|
|
|
remember_frequency();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
next_preset(-1);
|
2003-05-03 02:40:09 +00:00
|
|
|
search_dir = 0;
|
2003-11-06 00:47:47 +00:00
|
|
|
update_screen = true;
|
2003-05-03 02:40:09 +00:00
|
|
|
break;
|
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_STD_NEXT:
|
2005-11-13 21:03:53 +00:00
|
|
|
if(radio_mode == RADIO_SCAN_MODE)
|
|
|
|
{
|
2006-10-05 12:40:13 +00:00
|
|
|
curr_freq
|
|
|
|
+= fm_region[global_settings.fm_region].freq_step;
|
|
|
|
if(curr_freq > fm_region[global_settings.fm_region].freq_max)
|
|
|
|
curr_freq
|
|
|
|
= fm_region[global_settings.fm_region].freq_min;
|
2005-11-13 21:03:53 +00:00
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
curr_preset = find_preset(curr_freq);
|
|
|
|
remember_frequency();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
next_preset(1);
|
2003-05-03 02:40:09 +00:00
|
|
|
search_dir = 0;
|
2003-11-06 00:47:47 +00:00
|
|
|
update_screen = true;
|
2003-05-03 02:40:09 +00:00
|
|
|
break;
|
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_STD_PREVREPEAT:
|
2005-11-13 21:03:53 +00:00
|
|
|
if(radio_mode == RADIO_SCAN_MODE)
|
|
|
|
search_dir = -1;
|
2006-04-02 12:23:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
next_preset(-1);
|
|
|
|
update_screen = true;
|
|
|
|
}
|
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
break;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
|
|
|
case ACTION_STD_NEXTREPEAT:
|
2005-11-13 21:03:53 +00:00
|
|
|
if(radio_mode == RADIO_SCAN_MODE)
|
|
|
|
search_dir = 1;
|
2006-04-02 12:23:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
next_preset(1);
|
|
|
|
update_screen = true;
|
|
|
|
}
|
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
break;
|
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
|
|
|
|
case ACTION_SETTINGS_INC:
|
|
|
|
case ACTION_SETTINGS_INCREPEAT:
|
2003-05-03 02:40:09 +00:00
|
|
|
global_settings.volume++;
|
2005-04-01 13:41:03 +00:00
|
|
|
if(global_settings.volume > sound_max(SOUND_VOLUME))
|
|
|
|
global_settings.volume = sound_max(SOUND_VOLUME);
|
2005-11-06 23:12:11 +00:00
|
|
|
sound_set_volume(global_settings.volume);
|
2003-11-05 09:46:08 +00:00
|
|
|
update_screen = true;
|
2003-05-03 02:40:09 +00:00
|
|
|
settings_save();
|
|
|
|
break;
|
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_SETTINGS_DEC:
|
|
|
|
case ACTION_SETTINGS_DECREPEAT:
|
2003-05-03 02:40:09 +00:00
|
|
|
global_settings.volume--;
|
2005-04-01 13:41:03 +00:00
|
|
|
if(global_settings.volume < sound_min(SOUND_VOLUME))
|
|
|
|
global_settings.volume = sound_min(SOUND_VOLUME);
|
2005-11-06 23:12:11 +00:00
|
|
|
sound_set_volume(global_settings.volume);
|
2003-11-05 09:46:08 +00:00
|
|
|
update_screen = true;
|
2003-05-03 02:40:09 +00:00
|
|
|
settings_save();
|
|
|
|
break;
|
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_PLAY:
|
2006-08-28 22:38:41 +00:00
|
|
|
if (radio_status == FMRADIO_PLAYING)
|
|
|
|
radio_pause();
|
2005-11-13 21:03:53 +00:00
|
|
|
else
|
2006-08-28 22:38:41 +00:00
|
|
|
radio_start();
|
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
update_screen = true;
|
|
|
|
break;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
|
|
|
case ACTION_FM_MENU:
|
2003-05-09 00:14:59 +00:00
|
|
|
radio_menu();
|
2003-05-04 02:23:18 +00:00
|
|
|
curr_preset = find_preset(curr_freq);
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i){
|
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
screen_set_xmargin(&screens[i],0);
|
|
|
|
}
|
2005-11-20 01:02:14 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
gui_buttonbar_set(&buttonbar, str(LANG_BUTTONBAR_MENU),
|
|
|
|
str(LANG_FM_BUTTONBAR_PRESETS),
|
|
|
|
str(LANG_FM_BUTTONBAR_RECORD));
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif
|
2003-11-05 09:46:08 +00:00
|
|
|
update_screen = true;
|
2003-05-04 02:23:18 +00:00
|
|
|
break;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
2004-10-10 17:12:43 +00:00
|
|
|
#ifdef FM_PRESET
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_PRESET:
|
2006-04-02 12:23:08 +00:00
|
|
|
if(num_presets < 1)
|
|
|
|
{
|
2005-11-16 23:36:35 +00:00
|
|
|
gui_syncsplash(HZ, true, str(LANG_FM_NO_PRESETS));
|
|
|
|
update_screen = true;
|
2006-04-02 12:23:08 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
screen_set_xmargin(&screens[i],0);
|
|
|
|
gui_textarea_update(&screens[i]);
|
|
|
|
}
|
|
|
|
|
2005-11-16 23:36:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2004-07-05 14:30:17 +00:00
|
|
|
handle_radio_presets();
|
2006-04-02 12:23:08 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
screen_set_xmargin(&screens[i],0);
|
2006-04-02 12:23:08 +00:00
|
|
|
gui_textarea_update(&screens[i]);
|
2005-11-13 21:03:53 +00:00
|
|
|
}
|
2005-11-20 01:02:14 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
|
|
|
gui_buttonbar_set(&buttonbar,
|
|
|
|
str(LANG_BUTTONBAR_MENU),
|
|
|
|
str(LANG_FM_BUTTONBAR_PRESETS),
|
|
|
|
str(LANG_FM_BUTTONBAR_RECORD));
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif
|
2003-11-05 09:46:08 +00:00
|
|
|
update_screen = true;
|
2003-05-04 02:23:18 +00:00
|
|
|
break;
|
2004-10-10 17:12:43 +00:00
|
|
|
#endif
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2004-10-10 17:12:43 +00:00
|
|
|
#ifdef FM_FREEZE
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_FREEZE:
|
2003-11-06 00:47:47 +00:00
|
|
|
if(!screen_freeze)
|
|
|
|
{
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_syncsplash(HZ, true, str(LANG_FM_FREEZE));
|
2003-11-06 00:47:47 +00:00
|
|
|
screen_freeze = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
update_screen = true;
|
|
|
|
screen_freeze = false;
|
|
|
|
}
|
|
|
|
break;
|
2004-09-10 13:19:41 +00:00
|
|
|
#endif
|
2003-05-04 02:23:18 +00:00
|
|
|
case SYS_USB_CONNECTED:
|
2003-11-20 00:33:43 +00:00
|
|
|
/* Only accept USB connection when not recording */
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() != AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2004-07-26 16:06:59 +00:00
|
|
|
default_event_handler(SYS_USB_CONNECTED);
|
2003-12-31 03:13:29 +00:00
|
|
|
screen_freeze = true; /* Cosmetic: makes sure the
|
|
|
|
radio screen doesn't redraw */
|
2003-11-20 00:33:43 +00:00
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
break;
|
2005-11-13 21:03:53 +00:00
|
|
|
|
|
|
|
#ifdef FM_MODE
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_MODE:
|
|
|
|
if(radio_mode == RADIO_SCAN_MODE)
|
2005-11-13 21:03:53 +00:00
|
|
|
{
|
2006-09-22 12:18:58 +00:00
|
|
|
/* Force scan mode if there are no presets. */
|
|
|
|
if(num_presets > 0)
|
|
|
|
radio_mode = RADIO_PRESET_MODE;
|
2005-11-13 21:03:53 +00:00
|
|
|
}
|
2006-09-22 12:18:58 +00:00
|
|
|
else
|
|
|
|
radio_mode = RADIO_SCAN_MODE;
|
|
|
|
update_screen = true;
|
2005-11-13 21:03:53 +00:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef FM_NEXT_PRESET
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_NEXT_PRESET:
|
2005-11-13 21:03:53 +00:00
|
|
|
next_preset(1);
|
|
|
|
search_dir = 0;
|
|
|
|
update_screen = true;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
#ifdef FM_PREV_PRESET
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_FM_PREV_PRESET:
|
2005-11-13 21:03:53 +00:00
|
|
|
next_preset(-1);
|
|
|
|
search_dir = 0;
|
|
|
|
update_screen = true;
|
|
|
|
break;
|
|
|
|
#endif
|
2004-07-26 16:06:59 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
default_event_handler(button);
|
|
|
|
break;
|
2006-03-07 11:49:06 +00:00
|
|
|
} /*switch(button)*/
|
2003-11-05 09:46:08 +00:00
|
|
|
|
2006-09-22 12:18:58 +00:00
|
|
|
if (button != ACTION_NONE)
|
2005-08-13 17:35:02 +00:00
|
|
|
lastbutton = button;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
2006-03-03 19:41:16 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2003-11-05 09:46:08 +00:00
|
|
|
peak_meter_peek();
|
2006-03-03 19:41:16 +00:00
|
|
|
#endif
|
2003-11-05 09:46:08 +00:00
|
|
|
|
2003-11-06 00:47:47 +00:00
|
|
|
if(!screen_freeze)
|
2005-11-13 21:03:53 +00:00
|
|
|
{
|
2003-12-31 03:13:29 +00:00
|
|
|
/* Only display the peak meter when not recording */
|
2005-04-04 12:36:06 +00:00
|
|
|
if(!audio_status())
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2006-03-25 13:35:31 +00:00
|
|
|
|
2006-03-03 19:41:16 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2006-03-25 13:35:31 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
peak_meter_screen(&screens[i],0,
|
|
|
|
STATUSBAR_HEIGHT + fh*(top_of_screen + 4), fh);
|
|
|
|
screens[i].update_rect(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4),
|
|
|
|
screens[i].width, fh);
|
|
|
|
}
|
2006-03-03 19:41:16 +00:00
|
|
|
#endif
|
2006-03-25 13:35:31 +00:00
|
|
|
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
2005-08-29 20:07:17 +00:00
|
|
|
|
2003-11-06 00:47:47 +00:00
|
|
|
if(TIME_AFTER(current_tick, timeout))
|
2003-11-05 09:46:08 +00:00
|
|
|
{
|
2003-11-06 00:47:47 +00:00
|
|
|
timeout = current_tick + HZ;
|
2006-08-28 22:38:41 +00:00
|
|
|
|
|
|
|
/* keep "mono" from always being displayed when paused */
|
|
|
|
if (radio_status != FMRADIO_PAUSED)
|
2003-11-06 00:47:47 +00:00
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
stereo = radio_get(RADIO_STEREO) &&
|
|
|
|
!global_settings.fm_force_mono;
|
|
|
|
if(stereo != last_stereo_status)
|
|
|
|
{
|
|
|
|
update_screen = true;
|
|
|
|
last_stereo_status = stereo;
|
|
|
|
}
|
2003-11-06 00:47:47 +00:00
|
|
|
}
|
2003-11-05 09:46:08 +00:00
|
|
|
}
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2004-07-02 07:43:49 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2005-11-12 04:00:56 +00:00
|
|
|
seconds = audio_recorded_time() / HZ;
|
2005-08-13 17:35:02 +00:00
|
|
|
#endif
|
2004-07-02 07:43:49 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
if(update_screen || seconds > last_seconds)
|
2003-11-05 09:46:08 +00:00
|
|
|
{
|
2003-11-20 00:33:43 +00:00
|
|
|
last_seconds = seconds;
|
2005-11-29 15:10:07 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].setfont(FONT_UI);
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
if (curr_preset >= 0 )
|
|
|
|
snprintf(buf, 128, "%d. %s",curr_preset + 1,
|
|
|
|
presets[curr_preset].name);
|
2003-11-06 00:47:47 +00:00
|
|
|
else
|
2005-11-13 21:03:53 +00:00
|
|
|
snprintf(buf, 128, " ");
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen, buf);
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2006-10-05 12:40:13 +00:00
|
|
|
freq = curr_freq / 10000;
|
|
|
|
snprintf(buf, 128, str(LANG_FM_STATION), freq / 100, freq % 100);
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen + 1, buf);
|
2003-11-06 00:47:47 +00:00
|
|
|
|
2005-11-13 21:03:53 +00:00
|
|
|
snprintf(buf, 128, stereo?str(LANG_CHANNEL_STEREO):
|
|
|
|
str(LANG_CHANNEL_MONO));
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen + 2, buf);
|
|
|
|
|
2005-11-29 15:10:07 +00:00
|
|
|
snprintf(buf, 128, "%s %s", str(LANG_FM_TUNE_MODE),
|
|
|
|
radio_mode ? str(LANG_RADIO_PRESET_MODE) :
|
|
|
|
str(LANG_RADIO_SCAN_MODE));
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen + 3, buf);
|
2006-03-03 19:41:16 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() == AUDIO_STATUS_RECORD)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
|
|
|
hours = seconds / 3600;
|
|
|
|
minutes = (seconds - (hours * 3600)) / 60;
|
|
|
|
snprintf(buf, 32, "%s %02d:%02d:%02d",
|
|
|
|
str(LANG_RECORDING_TIME),
|
|
|
|
hours, minutes, seconds%60);
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen + 4, buf);
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
2003-12-31 03:13:29 +00:00
|
|
|
else
|
|
|
|
{
|
2006-11-06 18:07:30 +00:00
|
|
|
if(rec_options.rec_prerecord_time)
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
|
|
|
snprintf(buf, 32, "%s %02d",
|
|
|
|
str(LANG_RECORD_PRERECORD), seconds%60);
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
screens[i].puts_scroll(0, top_of_screen + 4, buf);
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
2003-12-31 03:13:29 +00:00
|
|
|
}
|
2006-03-03 19:41:16 +00:00
|
|
|
#endif
|
2005-11-20 01:02:14 +00:00
|
|
|
|
2005-11-20 01:35:20 +00:00
|
|
|
#ifdef HAS_BUTTONBAR
|
2005-11-20 01:02:14 +00:00
|
|
|
gui_buttonbar_draw(&buttonbar);
|
|
|
|
#endif
|
2005-11-13 21:03:53 +00:00
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_textarea_update(&screens[i]);
|
2003-11-05 09:46:08 +00:00
|
|
|
}
|
2004-12-26 18:36:48 +00:00
|
|
|
/* Only force the redraw if update_screen is true */
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars,true);
|
2005-11-20 01:02:14 +00:00
|
|
|
|
2005-09-06 21:01:35 +00:00
|
|
|
update_screen = false;
|
2003-11-05 09:46:08 +00:00
|
|
|
}
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() & AUDIO_STATUS_ERROR)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
|
|
|
done = true;
|
|
|
|
}
|
2006-03-07 11:49:06 +00:00
|
|
|
if (TIME_AFTER(current_tick, button_timeout))
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
|
|
|
cpu_idle_mode(true);
|
|
|
|
}
|
2006-03-07 11:49:06 +00:00
|
|
|
} /*while(!done)*/
|
2003-05-03 15:39:40 +00:00
|
|
|
|
2004-07-02 07:43:49 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-04-04 12:36:06 +00:00
|
|
|
if(audio_status() & AUDIO_STATUS_ERROR)
|
2003-11-20 00:33:43 +00:00
|
|
|
{
|
2005-11-16 15:12:15 +00:00
|
|
|
gui_syncsplash(0, true, str(LANG_DISK_FULL));
|
2005-11-13 21:03:53 +00:00
|
|
|
gui_syncstatusbar_draw(&statusbars,true);
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
gui_textarea_update(&screens[i]);
|
2005-04-04 12:36:06 +00:00
|
|
|
audio_error_clear();
|
2003-11-20 00:33:43 +00:00
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
2006-09-22 12:18:58 +00:00
|
|
|
button = get_action(CONTEXT_FM, TIMEOUT_BLOCK);
|
2006-09-25 19:59:37 +00:00
|
|
|
if(button == ACTION_FM_STOP)
|
2003-11-20 00:33:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2005-04-04 12:36:06 +00:00
|
|
|
audio_init_playback();
|
2005-08-13 17:35:02 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
|
2004-07-06 12:17:14 +00:00
|
|
|
sound_settings_apply();
|
2006-04-02 12:23:08 +00:00
|
|
|
#endif /* SIMULATOR */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2003-11-20 00:33:43 +00:00
|
|
|
if(keep_playing)
|
|
|
|
{
|
2006-08-28 22:38:41 +00:00
|
|
|
/* Catch FMRADIO_PLAYING status for the sim. */
|
2006-04-02 12:23:08 +00:00
|
|
|
#ifndef SIMULATOR
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2003-11-20 00:33:43 +00:00
|
|
|
/* Enable the Left and right A/D Converter */
|
2005-11-12 04:00:56 +00:00
|
|
|
audio_set_recording_gain(sound_default(SOUND_LEFT_GAIN),
|
2006-08-28 22:38:41 +00:00
|
|
|
sound_default(SOUND_RIGHT_GAIN),
|
|
|
|
AUDIO_GAIN_LINEIN);
|
2003-11-20 00:33:43 +00:00
|
|
|
mas_codec_writereg(6, 0x4000);
|
2005-08-13 17:35:02 +00:00
|
|
|
#endif
|
2006-04-02 12:23:08 +00:00
|
|
|
#endif
|
2004-10-19 08:20:38 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2006-08-28 22:38:41 +00:00
|
|
|
rec_set_source(AUDIO_SRC_PLAYBACK, SRCF_PLAYBACK);
|
|
|
|
#else
|
|
|
|
radio_stop();
|
2005-08-13 17:35:02 +00:00
|
|
|
#endif
|
2003-11-20 00:33:43 +00:00
|
|
|
}
|
2005-09-29 11:19:55 +00:00
|
|
|
|
|
|
|
cpu_idle_mode(false);
|
2005-11-13 21:03:53 +00:00
|
|
|
|
|
|
|
/* restore status bar settings */
|
|
|
|
global_settings.statusbar = statusbar;
|
2006-08-28 22:38:41 +00:00
|
|
|
|
|
|
|
in_screen = false;
|
2005-09-29 11:19:55 +00:00
|
|
|
|
2003-11-20 00:33:43 +00:00
|
|
|
return have_recorded;
|
2006-08-28 22:38:41 +00:00
|
|
|
} /* radio_screen */
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static void radio_save_presets(void)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int i;
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
fd = creat(filepreset, O_WRONLY);
|
2003-05-04 02:23:18 +00:00
|
|
|
if(fd >= 0)
|
|
|
|
{
|
2004-07-05 14:30:17 +00:00
|
|
|
for(i = 0;i < num_presets;i++)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2005-02-22 12:48:36 +00:00
|
|
|
fdprintf(fd, "%d:%s\n", presets[i].frequency, presets[i].name);
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
close(fd);
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
if(!strncasecmp(FMPRESET_PATH, filepreset, strlen(FMPRESET_PATH)))
|
|
|
|
set_file(filepreset, global_settings.fmr_file, MAX_FILENAME);
|
|
|
|
presets_changed = false;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
gui_syncsplash(HZ, true, str(LANG_FM_PRESET_SAVE_FAILED));
|
|
|
|
}
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
void radio_load_presets(char *filename)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int rc;
|
|
|
|
char buf[128];
|
|
|
|
char *freq;
|
|
|
|
char *name;
|
|
|
|
bool done = false;
|
2004-07-05 14:30:17 +00:00
|
|
|
int f;
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
memset(presets, 0, sizeof(presets));
|
|
|
|
num_presets = 0;
|
|
|
|
|
|
|
|
/* No Preset in configuration. */
|
|
|
|
if(filename[0] == '\0')
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
filepreset[0] = '\0';
|
|
|
|
return;
|
2006-08-28 22:38:41 +00:00
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
/* Temporary preset, loaded until player shuts down. */
|
|
|
|
else if(filename[0] == '/')
|
|
|
|
strncpy(filepreset, filename, sizeof(filepreset));
|
|
|
|
/* Preset from default directory. */
|
|
|
|
else
|
2006-08-28 22:38:41 +00:00
|
|
|
snprintf(filepreset, sizeof(filepreset), "%s/%s.fmr",
|
2006-04-02 12:23:08 +00:00
|
|
|
FMPRESET_PATH, filename);
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
fd = open(filepreset, O_RDONLY);
|
|
|
|
if(fd >= 0)
|
|
|
|
{
|
|
|
|
while(!done && num_presets < MAX_PRESETS)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
rc = read_line(fd, buf, 128);
|
|
|
|
if(rc > 0)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
if(settings_parseline(buf, &freq, &name))
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
f = atoi(freq);
|
|
|
|
if(f) /* For backwards compatibility */
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
presets[num_presets].frequency = f;
|
2006-04-03 10:06:39 +00:00
|
|
|
strncpy(presets[num_presets].name, name, MAX_FMPRESET_LEN);
|
|
|
|
presets[num_presets].name[MAX_FMPRESET_LEN] = 0;
|
2006-04-02 12:23:08 +00:00
|
|
|
num_presets++;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
else
|
|
|
|
done = true;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
close(fd);
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
else /* invalid file name? */
|
|
|
|
filepreset[0] = '\0';
|
|
|
|
|
|
|
|
if(num_presets > 0)
|
|
|
|
presets_loaded = true;
|
|
|
|
else
|
|
|
|
presets_loaded = false;
|
|
|
|
|
|
|
|
presets_changed = false;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
static void rebuild_preset_menu(void)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
|
|
|
int i;
|
2004-07-05 14:30:17 +00:00
|
|
|
for(i = 0;i < num_presets;i++)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2004-07-05 14:30:17 +00:00
|
|
|
preset_menu_items[i].desc = presets[i].name;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool radio_add_preset(void)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-03 10:06:39 +00:00
|
|
|
char buf[MAX_FMPRESET_LEN];
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
if(num_presets < MAX_PRESETS)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-03 10:06:39 +00:00
|
|
|
memset(buf, 0, MAX_FMPRESET_LEN);
|
2003-05-04 02:23:18 +00:00
|
|
|
|
2006-04-03 10:06:39 +00:00
|
|
|
if (!kbd_input(buf, MAX_FMPRESET_LEN))
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2006-04-03 10:06:39 +00:00
|
|
|
buf[MAX_FMPRESET_LEN] = 0;
|
2004-07-05 14:30:17 +00:00
|
|
|
strcpy(presets[num_presets].name, buf);
|
|
|
|
presets[num_presets].frequency = curr_freq;
|
2005-11-19 19:23:44 +00:00
|
|
|
#ifdef FM_PRESET_ADD /* only for archos */
|
2004-07-05 14:30:17 +00:00
|
|
|
menu_insert(preset_menu, -1,
|
2004-07-23 23:01:20 +00:00
|
|
|
presets[num_presets].name, 0);
|
2004-07-05 14:30:17 +00:00
|
|
|
/* We must still rebuild the menu table, since the
|
|
|
|
item name pointers must be updated */
|
|
|
|
rebuild_preset_menu();
|
2005-11-19 19:23:44 +00:00
|
|
|
#endif
|
2004-07-05 14:30:17 +00:00
|
|
|
num_presets++;
|
2006-04-02 12:23:08 +00:00
|
|
|
presets_changed = true;
|
|
|
|
if(num_presets > 0)
|
|
|
|
presets_loaded = true;
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
gui_syncsplash(HZ, true, str(LANG_FM_NO_FREE_PRESETS));
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* button preprocessor for preset option submenu */
|
2004-07-05 14:30:17 +00:00
|
|
|
static int handle_radio_presets_menu_cb(int key, int m)
|
|
|
|
{
|
|
|
|
(void)m;
|
2004-10-19 18:00:41 +00:00
|
|
|
#ifdef FM_PRESET_ACTION
|
2004-07-05 14:30:17 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_F3:
|
|
|
|
key = ACTION_STD_CANCEL; /* Fake an exit */
|
|
|
|
action_signalscreenchange();
|
2004-10-19 09:09:27 +00:00
|
|
|
break;
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
2004-09-19 21:58:37 +00:00
|
|
|
#endif
|
2004-07-05 14:30:17 +00:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool radio_edit_preset(void)
|
|
|
|
{
|
|
|
|
int pos = menu_cursor(preset_menu);
|
2006-04-03 10:06:39 +00:00
|
|
|
char buf[MAX_FMPRESET_LEN];
|
2004-07-05 14:30:17 +00:00
|
|
|
|
2006-04-03 10:06:39 +00:00
|
|
|
strncpy(buf, menu_description(preset_menu, pos), MAX_FMPRESET_LEN);
|
2004-07-05 14:30:17 +00:00
|
|
|
|
2006-04-03 10:06:39 +00:00
|
|
|
if (!kbd_input(buf, MAX_FMPRESET_LEN))
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
2006-04-03 10:06:39 +00:00
|
|
|
buf[MAX_FMPRESET_LEN] = 0;
|
2004-07-05 14:30:17 +00:00
|
|
|
strcpy(presets[pos].name, buf);
|
2006-04-02 12:23:08 +00:00
|
|
|
presets_changed = true;
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool radio_delete_preset(void)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2004-07-05 14:30:17 +00:00
|
|
|
int pos = menu_cursor(preset_menu);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = pos;i < num_presets;i++)
|
|
|
|
presets[i] = presets[i+1];
|
|
|
|
num_presets--;
|
|
|
|
|
|
|
|
menu_delete(preset_menu, pos);
|
|
|
|
/* We must still rebuild the menu table, since the
|
|
|
|
item name pointers must be updated */
|
|
|
|
rebuild_preset_menu();
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
return true; /* Make the menu return immediately */
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool load_preset_list(void)
|
2006-04-02 12:23:08 +00:00
|
|
|
{
|
|
|
|
return !rockbox_browse(FMPRESET_PATH, SHOW_FMR);
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool save_preset_list(void)
|
2006-04-02 12:23:08 +00:00
|
|
|
{
|
|
|
|
if(num_presets != 0)
|
|
|
|
{
|
2006-04-25 00:14:21 +00:00
|
|
|
bool bad_file_name = true;
|
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
if(!opendir(FMPRESET_PATH)) /* Check if there is preset folder */
|
|
|
|
mkdir(FMPRESET_PATH, 0);
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
create_numbered_filename(filepreset, FMPRESET_PATH, "preset",
|
|
|
|
".fmr", 2 IF_CNFN_NUM_(, NULL));
|
2006-04-25 00:14:21 +00:00
|
|
|
|
|
|
|
while(bad_file_name)
|
|
|
|
{
|
|
|
|
if(!kbd_input(filepreset, sizeof(filepreset)))
|
|
|
|
{
|
|
|
|
/* check the name: max MAX_FILENAME (20) chars */
|
|
|
|
char* p2;
|
|
|
|
char* p1;
|
|
|
|
int len;
|
|
|
|
p1 = strrchr(filepreset, '/');
|
|
|
|
p2 = p1;
|
|
|
|
while((p1) && (*p2) && (*p2 != '.'))
|
|
|
|
p2++;
|
|
|
|
len = (int)(p2-p1) - 1;
|
|
|
|
if((!p1) || (len > MAX_FILENAME) || (len == 0))
|
|
|
|
{
|
|
|
|
/* no slash, too long or too short */
|
|
|
|
gui_syncsplash(HZ,true,str(LANG_INVALID_FILENAME));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* add correct extension (easier to always write)
|
|
|
|
at this point, p2 points to 0 or the extension dot */
|
|
|
|
*p2 = '\0';
|
|
|
|
strcat(filepreset,".fmr");
|
|
|
|
bad_file_name = false;
|
|
|
|
radio_save_presets();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* user aborted */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
gui_syncsplash(HZ,true,str(LANG_FM_NO_PRESETS));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool clear_preset_list(void)
|
2006-04-02 12:23:08 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* little menu on what to do with a preset entry */
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool handle_radio_presets_menu(void)
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
2004-08-03 20:52:31 +00:00
|
|
|
static const struct menu_item preset_menu_items[] = {
|
2004-07-23 23:31:58 +00:00
|
|
|
{ ID2P(LANG_FM_EDIT_PRESET), radio_edit_preset },
|
|
|
|
{ ID2P(LANG_FM_DELETE_PRESET), radio_delete_preset },
|
2004-07-05 14:30:17 +00:00
|
|
|
};
|
|
|
|
int m;
|
|
|
|
|
|
|
|
m = menu_init( preset_menu_items,
|
|
|
|
sizeof preset_menu_items / sizeof(struct menu_item),
|
|
|
|
handle_radio_presets_menu_cb,
|
|
|
|
NULL, NULL, str(LANG_FM_BUTTONBAR_EXIT));
|
|
|
|
menu_run(m);
|
|
|
|
menu_exit(m);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* button preprocessor for list of preset stations menu */
|
2006-12-25 14:01:47 +00:00
|
|
|
static int handle_radio_presets_cb(int key, int m)
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
2004-09-19 21:58:37 +00:00
|
|
|
(void)m;
|
2006-09-22 12:18:58 +00:00
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
2004-10-19 18:00:41 +00:00
|
|
|
#ifdef FM_PRESET_ADD
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_STD_MENU:
|
2004-07-05 14:30:17 +00:00
|
|
|
radio_add_preset();
|
|
|
|
menu_draw(m);
|
|
|
|
key = BUTTON_NONE;
|
|
|
|
break;
|
2005-11-13 21:03:53 +00:00
|
|
|
#endif
|
2006-07-21 08:42:28 +00:00
|
|
|
#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
|
2004-10-19 18:00:41 +00:00
|
|
|
#ifdef FM_PRESET
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_STD_QUICKSCREEN:
|
2004-07-05 14:30:17 +00:00
|
|
|
menu_draw(m);
|
2006-09-22 13:08:17 +00:00
|
|
|
key = ACTION_STD_CANCEL; /* Fake an exit */
|
2004-07-05 14:30:17 +00:00
|
|
|
break;
|
2004-10-19 18:00:41 +00:00
|
|
|
#endif
|
2005-11-13 21:03:53 +00:00
|
|
|
#endif
|
2006-09-22 12:18:58 +00:00
|
|
|
case ACTION_F3:
|
|
|
|
case ACTION_STD_CONTEXT:
|
2004-10-19 18:00:41 +00:00
|
|
|
{
|
|
|
|
bool ret;
|
2004-07-05 14:30:17 +00:00
|
|
|
ret = handle_radio_presets_menu();
|
|
|
|
menu_draw(m);
|
|
|
|
if(ret)
|
2006-09-22 12:18:58 +00:00
|
|
|
key = SYS_USB_CONNECTED;
|
2004-07-05 14:30:17 +00:00
|
|
|
else
|
2006-09-22 12:18:58 +00:00
|
|
|
key = ACTION_NONE;
|
2004-07-05 14:30:17 +00:00
|
|
|
break;
|
2004-10-19 18:00:41 +00:00
|
|
|
}
|
2004-07-05 14:30:17 +00:00
|
|
|
}
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* present a list of preset stations */
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool handle_radio_presets(void)
|
2004-07-05 14:30:17 +00:00
|
|
|
{
|
|
|
|
int result;
|
2003-05-04 02:23:18 +00:00
|
|
|
bool reload_dir = false;
|
|
|
|
|
|
|
|
if(presets_loaded)
|
|
|
|
{
|
2004-07-05 14:30:17 +00:00
|
|
|
rebuild_preset_menu();
|
|
|
|
|
2003-05-04 02:23:18 +00:00
|
|
|
/* DIY menu handling, since we want to exit after selection */
|
2004-07-05 14:30:17 +00:00
|
|
|
preset_menu = menu_init( preset_menu_items, num_presets,
|
|
|
|
handle_radio_presets_cb,
|
|
|
|
str(LANG_FM_BUTTONBAR_ADD),
|
|
|
|
str(LANG_FM_BUTTONBAR_EXIT),
|
|
|
|
str(LANG_FM_BUTTONBAR_ACTION));
|
2005-04-10 17:36:55 +00:00
|
|
|
if (curr_preset >= 0)
|
|
|
|
menu_set_cursor(preset_menu, curr_preset);
|
2004-07-05 14:30:17 +00:00
|
|
|
result = menu_show(preset_menu);
|
|
|
|
menu_exit(preset_menu);
|
2003-05-04 02:23:18 +00:00
|
|
|
if (result == MENU_SELECTED_EXIT)
|
|
|
|
return false;
|
|
|
|
else if (result == MENU_ATTACHED_USB)
|
|
|
|
reload_dir = true;
|
|
|
|
|
2004-07-05 14:30:17 +00:00
|
|
|
if (result >= 0) /* A preset was selected */
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
2005-04-10 20:26:19 +00:00
|
|
|
curr_preset = menu_cursor(preset_menu);
|
|
|
|
curr_freq = presets[curr_preset].frequency;
|
2004-07-05 14:30:17 +00:00
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
2004-07-12 13:28:44 +00:00
|
|
|
remember_frequency();
|
2003-05-04 02:23:18 +00:00
|
|
|
}
|
|
|
|
}
|
2004-07-05 14:30:17 +00:00
|
|
|
|
2003-05-04 02:23:18 +00:00
|
|
|
return reload_dir;
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static char monomode_menu_string[32];
|
2004-07-05 14:30:17 +00:00
|
|
|
|
|
|
|
static void create_monomode_menu(void)
|
|
|
|
{
|
2005-11-29 15:10:07 +00:00
|
|
|
snprintf(monomode_menu_string, sizeof monomode_menu_string,
|
|
|
|
"%s: %s", str(LANG_FM_MONO_MODE),
|
2004-07-05 14:30:17 +00:00
|
|
|
global_settings.fm_force_mono?
|
|
|
|
str(LANG_SET_BOOL_YES):str(LANG_SET_BOOL_NO));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool toggle_mono_mode(void)
|
|
|
|
{
|
|
|
|
global_settings.fm_force_mono = !global_settings.fm_force_mono;
|
|
|
|
radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono);
|
|
|
|
settings_save();
|
|
|
|
create_monomode_menu();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-25 14:01:47 +00:00
|
|
|
static char region_menu_string[32];
|
2006-10-05 12:40:13 +00:00
|
|
|
static void create_region_menu(void)
|
|
|
|
{
|
|
|
|
snprintf(region_menu_string, sizeof(region_menu_string),
|
|
|
|
"%s: %s", str(LANG_FM_REGION),
|
|
|
|
str(fm_region[global_settings.fm_region].lang));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool toggle_region_mode(void)
|
|
|
|
{
|
|
|
|
global_settings.fm_region++;
|
|
|
|
if(global_settings.fm_region >=
|
|
|
|
(int)(sizeof(fm_region) / sizeof(struct fm_region_setting)))
|
|
|
|
global_settings.fm_region = 0;
|
|
|
|
#if (CONFIG_TUNER & TEA5767)
|
|
|
|
radio_set(RADIO_SET_DEEMPHASIS,
|
|
|
|
fm_region[global_settings.fm_region].deemphasis);
|
|
|
|
radio_set(RADIO_SET_BAND, fm_region[global_settings.fm_region].band);
|
|
|
|
#endif
|
|
|
|
/* make sure the current frequency is in the region range */
|
|
|
|
curr_freq -= (curr_freq - fm_region[global_settings.fm_region].freq_min)
|
|
|
|
% fm_region[global_settings.fm_region].freq_step;
|
|
|
|
if(curr_freq < fm_region[global_settings.fm_region].freq_min)
|
|
|
|
curr_freq = fm_region[global_settings.fm_region].freq_min;
|
|
|
|
if(curr_freq > fm_region[global_settings.fm_region].freq_max)
|
|
|
|
curr_freq = fm_region[global_settings.fm_region].freq_max;
|
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
|
2006-10-12 13:59:44 +00:00
|
|
|
remember_frequency();
|
2006-10-05 12:40:13 +00:00
|
|
|
create_region_menu();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2005-11-29 15:10:07 +00:00
|
|
|
#ifndef FM_MODE
|
2006-12-25 14:01:47 +00:00
|
|
|
static char radiomode_menu_string[32];
|
2005-11-29 15:10:07 +00:00
|
|
|
|
|
|
|
static void create_radiomode_menu(void)
|
|
|
|
{
|
|
|
|
snprintf(radiomode_menu_string, 32, "%s %s", str(LANG_FM_TUNE_MODE),
|
|
|
|
radio_mode ? str(LANG_RADIO_PRESET_MODE) :
|
|
|
|
str(LANG_RADIO_SCAN_MODE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool toggle_radio_mode(void)
|
|
|
|
{
|
|
|
|
radio_mode = (radio_mode == RADIO_SCAN_MODE) ?
|
|
|
|
RADIO_PRESET_MODE : RADIO_SCAN_MODE;
|
|
|
|
create_radiomode_menu();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-16 23:36:35 +00:00
|
|
|
static bool scan_presets(void)
|
|
|
|
{
|
2006-04-02 12:23:08 +00:00
|
|
|
bool tuned = false, do_scan = true;
|
2006-04-03 10:06:39 +00:00
|
|
|
char buf[MAX_FMPRESET_LEN];
|
2005-11-16 23:36:35 +00:00
|
|
|
int freq, i;
|
2006-04-02 12:23:08 +00:00
|
|
|
|
|
|
|
if(num_presets > 0) /* Do that to avoid 2 questions. */
|
|
|
|
do_scan = yesno_pop(str(LANG_FM_CLEAR_PRESETS));
|
|
|
|
|
|
|
|
if(do_scan)
|
|
|
|
{
|
2006-10-05 12:40:13 +00:00
|
|
|
curr_freq = fm_region[global_settings.fm_region].freq_min;
|
2005-11-19 14:54:41 +00:00
|
|
|
num_presets = 0;
|
2006-04-03 10:06:39 +00:00
|
|
|
memset(presets, 0, sizeof(presets));
|
2006-10-05 12:40:13 +00:00
|
|
|
while(curr_freq <= fm_region[global_settings.fm_region].freq_max)
|
2006-04-02 12:23:08 +00:00
|
|
|
{
|
2006-12-26 22:01:27 +00:00
|
|
|
if (num_presets >= MAX_PRESETS || action_userabort(TIMEOUT_NOBLOCK))
|
2005-11-19 14:54:41 +00:00
|
|
|
break;
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2006-10-05 12:40:13 +00:00
|
|
|
freq = curr_freq / 10000;
|
2006-04-03 10:06:39 +00:00
|
|
|
snprintf(buf, MAX_FMPRESET_LEN, str(LANG_FM_SCANNING),
|
2006-10-05 12:40:13 +00:00
|
|
|
freq/100, freq % 100);
|
2005-11-19 14:54:41 +00:00
|
|
|
gui_syncsplash(0, true, buf);
|
|
|
|
|
|
|
|
/* Tune in and delay */
|
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
sleep(1);
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2005-11-19 14:54:41 +00:00
|
|
|
/* Start IF measurement */
|
|
|
|
radio_set(RADIO_IF_MEASUREMENT, 1);
|
|
|
|
sleep(1);
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2005-11-19 14:54:41 +00:00
|
|
|
/* Now check how close to the IF frequency we are */
|
|
|
|
tuned = radio_get(RADIO_TUNED);
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2005-11-19 14:54:41 +00:00
|
|
|
/* add preset */
|
|
|
|
if(tuned){
|
2006-04-03 10:06:39 +00:00
|
|
|
snprintf(buf, MAX_FMPRESET_LEN,
|
2006-10-05 12:40:13 +00:00
|
|
|
str(LANG_FM_DEFAULT_PRESET_NAME),freq/100, freq % 100);
|
2005-11-19 19:23:44 +00:00
|
|
|
strcpy(presets[num_presets].name,buf);
|
2005-11-19 14:54:41 +00:00
|
|
|
presets[num_presets].frequency = curr_freq;
|
|
|
|
num_presets++;
|
|
|
|
}
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2006-10-05 12:40:13 +00:00
|
|
|
curr_freq += fm_region[global_settings.fm_region].freq_step;
|
2005-11-19 14:54:41 +00:00
|
|
|
|
|
|
|
}
|
2005-11-16 23:36:35 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
presets_changed = true;
|
|
|
|
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
gui_textarea_clear(&screens[i]);
|
|
|
|
screen_set_xmargin(&screens[i],0);
|
|
|
|
gui_textarea_update(&screens[i]);
|
|
|
|
}
|
2005-11-19 14:54:41 +00:00
|
|
|
|
2006-04-02 12:23:08 +00:00
|
|
|
if(num_presets > 0 )
|
|
|
|
{
|
2005-11-19 14:54:41 +00:00
|
|
|
curr_freq = presets[0].frequency;
|
|
|
|
radio_set(RADIO_FREQUENCY, curr_freq);
|
|
|
|
remember_frequency();
|
2005-11-19 19:23:44 +00:00
|
|
|
radio_mode = RADIO_PRESET_MODE;
|
2006-04-02 12:23:08 +00:00
|
|
|
presets_loaded = true;
|
2005-11-16 23:36:35 +00:00
|
|
|
}
|
2006-04-02 12:23:08 +00:00
|
|
|
else
|
|
|
|
presets_loaded = false;
|
2005-11-16 23:36:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* button preprocessor for the main menu */
|
2006-12-25 14:01:47 +00:00
|
|
|
static int radio_menu_cb(int key, int m)
|
2004-10-19 22:50:34 +00:00
|
|
|
{
|
|
|
|
(void)m;
|
2006-08-15 12:27:07 +00:00
|
|
|
#if 0 /* this screen needs fixing! */
|
2004-10-19 22:50:34 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
2006-07-21 08:42:28 +00:00
|
|
|
#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
|
2004-10-19 22:50:34 +00:00
|
|
|
#ifdef MENU_ENTER2
|
|
|
|
case MENU_ENTER2:
|
2005-11-13 21:03:53 +00:00
|
|
|
#endif
|
2004-10-19 22:50:34 +00:00
|
|
|
#endif
|
|
|
|
case MENU_ENTER:
|
|
|
|
key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */
|
|
|
|
break;
|
|
|
|
|
2006-07-21 08:42:28 +00:00
|
|
|
#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) && (CONFIG_KEYPAD != IAUDIO_X5_PAD)
|
2004-10-19 22:50:34 +00:00
|
|
|
#ifdef MENU_ENTER2
|
|
|
|
case MENU_ENTER2 | BUTTON_REL:
|
2005-11-13 21:03:53 +00:00
|
|
|
#endif
|
2004-10-19 22:50:34 +00:00
|
|
|
#endif
|
|
|
|
case MENU_ENTER | BUTTON_REL:
|
|
|
|
key = MENU_ENTER; /* fake downpress, next menu doesn't like release */
|
|
|
|
break;
|
|
|
|
}
|
2006-08-15 12:27:07 +00:00
|
|
|
#endif
|
2004-10-19 22:50:34 +00:00
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
#ifndef SIMULATOR
|
2006-10-10 13:42:22 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
|
|
|
|
#if defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC
|
|
|
|
#define FM_RECORDING_SCREEN
|
2006-08-28 22:38:41 +00:00
|
|
|
static bool fm_recording_screen(void)
|
|
|
|
{
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
/* switch recording source to FMRADIO for the duration */
|
|
|
|
int rec_source = global_settings.rec_source;
|
|
|
|
global_settings.rec_source = AUDIO_SRC_FMRADIO;
|
|
|
|
|
|
|
|
/* clearing queue seems to cure a spontaneous abort during record */
|
|
|
|
while (button_get(false) != BUTTON_NONE);
|
|
|
|
|
|
|
|
ret = recording_screen(true);
|
|
|
|
|
|
|
|
/* safe to reset as changing sources is prohibited here */
|
|
|
|
global_settings.rec_source = rec_source;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2006-10-10 13:42:22 +00:00
|
|
|
#endif /* defined(HAVE_FMRADIO_IN) && CONFIG_CODEC == SWCODEC */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
2006-10-10 13:42:22 +00:00
|
|
|
#if defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC
|
|
|
|
#define FM_RECORDING_SETTINGS
|
2006-08-28 22:38:41 +00:00
|
|
|
static bool fm_recording_settings(void)
|
|
|
|
{
|
|
|
|
bool ret = recording_menu(true);
|
|
|
|
|
2006-09-17 18:52:31 +00:00
|
|
|
#if CONFIG_CODEC != SWCODEC
|
2006-08-28 22:38:41 +00:00
|
|
|
if (!ret)
|
|
|
|
{
|
2006-11-06 18:07:30 +00:00
|
|
|
struct audio_recording_options rec_options;
|
|
|
|
rec_init_recording_options(&rec_options);
|
|
|
|
rec_options.rec_source = AUDIO_SRC_LINEIN;
|
|
|
|
rec_set_recording_options(&rec_options);
|
2006-08-28 22:38:41 +00:00
|
|
|
}
|
2006-09-17 18:52:31 +00:00
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2006-10-10 13:42:22 +00:00
|
|
|
#endif /* defined(HAVE_FMRADIO_IN) || CONFIG_CODEC != SWCODEC */
|
|
|
|
#endif /* HAVE_RECORDING */
|
2006-08-28 22:38:41 +00:00
|
|
|
#endif /* SIMULATOR */
|
|
|
|
|
|
|
|
|
2004-10-19 22:50:34 +00:00
|
|
|
/* main menu of the radio screen */
|
2006-12-25 14:01:47 +00:00
|
|
|
static bool radio_menu(void)
|
2003-05-04 02:23:18 +00:00
|
|
|
{
|
|
|
|
int m;
|
|
|
|
bool result;
|
2005-08-27 11:03:41 +00:00
|
|
|
|
|
|
|
static const struct menu_item items[] = {
|
2005-09-22 18:36:02 +00:00
|
|
|
/* Add functions not accessible via buttons */
|
|
|
|
#ifndef FM_PRESET
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_FM_BUTTONBAR_PRESETS), handle_radio_presets },
|
2005-09-22 18:36:02 +00:00
|
|
|
#endif
|
|
|
|
#ifndef FM_PRESET_ADD
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_FM_ADD_PRESET) , radio_add_preset },
|
2005-08-13 17:35:02 +00:00
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_FM_PRESET_LOAD) , load_preset_list },
|
|
|
|
{ ID2P(LANG_FM_PRESET_SAVE) , save_preset_list },
|
|
|
|
{ ID2P(LANG_FM_PRESET_CLEAR) , clear_preset_list },
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2006-08-28 22:38:41 +00:00
|
|
|
{ monomode_menu_string , toggle_mono_mode },
|
2005-11-29 15:10:07 +00:00
|
|
|
#ifndef FM_MODE
|
2006-08-28 22:38:41 +00:00
|
|
|
{ radiomode_menu_string , toggle_radio_mode },
|
|
|
|
#endif
|
2006-10-05 12:40:13 +00:00
|
|
|
{ region_menu_string , toggle_region_mode },
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_SOUND_SETTINGS) , sound_menu },
|
2006-10-10 13:42:22 +00:00
|
|
|
#ifdef FM_RECORDING_SCREEN
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_RECORDING_MENU) , fm_recording_screen },
|
2005-11-29 15:10:07 +00:00
|
|
|
#endif
|
2006-10-10 13:42:22 +00:00
|
|
|
#ifdef FM_RECORDING_SETTINGS
|
|
|
|
{ ID2P(LANG_RECORDING_SETTINGS) , fm_recording_settings },
|
2004-07-05 14:30:17 +00:00
|
|
|
#endif
|
2006-08-28 22:38:41 +00:00
|
|
|
{ ID2P(LANG_FM_SCAN_PRESETS) , scan_presets },
|
2005-08-27 11:03:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
create_monomode_menu();
|
2006-10-05 12:40:13 +00:00
|
|
|
create_region_menu();
|
2005-11-29 15:10:07 +00:00
|
|
|
#ifndef FM_MODE
|
|
|
|
create_radiomode_menu();
|
|
|
|
#endif
|
2005-08-27 11:03:41 +00:00
|
|
|
m = menu_init(items, sizeof(items) / sizeof(*items),
|
|
|
|
radio_menu_cb, NULL, NULL, NULL);
|
2003-05-04 02:23:18 +00:00
|
|
|
result = menu_run(m);
|
|
|
|
menu_exit(m);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2003-05-03 02:40:09 +00:00
|
|
|
#endif
|