1
0
Fork 0
forked from len0rd/rockbox

The FM radio screen now remembers the last used frequency

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4865 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Linus Nielsen Feltzing 2004-07-12 13:28:44 +00:00
parent 7c0cdf1918
commit 3e92dbecc8
3 changed files with 17 additions and 2 deletions

View file

@ -68,7 +68,7 @@ static int fm_in1 = DEFAULT_IN1;
static int fm_in2 = DEFAULT_IN2; static int fm_in2 = DEFAULT_IN2;
static int curr_preset = -1; static int curr_preset = -1;
static int curr_freq = 99400000; static int curr_freq;
static int pll_cnt; static int pll_cnt;
#define MAX_PRESETS 32 #define MAX_PRESETS 32
@ -159,6 +159,12 @@ static int find_preset(int freq)
return -1; return -1;
} }
static void remember_frequency(void)
{
global_settings.last_frequency = (curr_freq - MIN_FREQ) / FREQ_STEP;
settings_save();
}
bool radio_screen(void) bool radio_screen(void)
{ {
char buf[MAX_PATH]; char buf[MAX_PATH];
@ -225,6 +231,8 @@ bool radio_screen(void)
mpeg_sound_default(SOUND_RIGHT_GAIN), false); mpeg_sound_default(SOUND_RIGHT_GAIN), false);
#endif #endif
curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ;
fmradio_set(1, DEFAULT_IN1); fmradio_set(1, DEFAULT_IN1);
fmradio_set(2, DEFAULT_IN2); fmradio_set(2, DEFAULT_IN2);
@ -266,6 +274,7 @@ bool radio_screen(void)
{ {
search_dir = 0; search_dir = 0;
curr_preset = find_preset(curr_freq); curr_preset = find_preset(curr_freq);
remember_frequency();
} }
update_screen = true; update_screen = true;
@ -322,6 +331,7 @@ bool radio_screen(void)
radio_set(RADIO_FREQUENCY, curr_freq); radio_set(RADIO_FREQUENCY, curr_freq);
curr_preset = find_preset(curr_freq); curr_preset = find_preset(curr_freq);
remember_frequency();
search_dir = 0; search_dir = 0;
update_screen = true; update_screen = true;
break; break;
@ -333,6 +343,7 @@ bool radio_screen(void)
radio_set(RADIO_FREQUENCY, curr_freq); radio_set(RADIO_FREQUENCY, curr_freq);
curr_preset = find_preset(curr_freq); curr_preset = find_preset(curr_freq);
remember_frequency();
search_dir = 0; search_dir = 0;
update_screen = true; update_screen = true;
break; break;
@ -765,6 +776,7 @@ bool handle_radio_presets(void)
i = menu_cursor(preset_menu); i = menu_cursor(preset_menu);
curr_freq = presets[i].frequency; curr_freq = presets[i].frequency;
radio_set(RADIO_FREQUENCY, curr_freq); radio_set(RADIO_FREQUENCY, curr_freq);
remember_frequency();
} }
} }

View file

@ -222,9 +222,10 @@ static struct bit_entry rtc_bits[] =
/* If values are just added to the end, no need to bump the version. */ /* If values are just added to the end, no need to bump the version. */
#ifdef HAVE_FMRADIO #ifdef HAVE_FMRADIO
{1, S_O(fm_force_mono), false, "force fm mono", off_on }, {1, S_O(fm_force_mono), false, "force fm mono", off_on },
{8, S_O(last_frequency), 994, NULL, NULL },
#endif #endif
/* Current sum of bits: 271 (worst case) */ /* Current sum of bits: 286 (worst case) */
/* Sum of all bit sizes must not grow beyond 288! */ /* Sum of all bit sizes must not grow beyond 288! */
}; };

View file

@ -195,6 +195,8 @@ struct user_settings
bool fm_force_mono; /* Forces Mono mode if true */ bool fm_force_mono; /* Forces Mono mode if true */
bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else
only 88MHz-108MHz */ only 88MHz-108MHz */
int last_frequency; /* Last frequency for resuming, in FREQ_STEP units,
relative to MIN_FREQ */
#endif #endif
int max_files_in_dir; /* Max entries in directory (file browser) */ int max_files_in_dir; /* Max entries in directory (file browser) */