summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-02-07 04:24:21 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-02-07 04:24:21 +0000
commiteed62f1657f4f2b08571f0bd2b1827f3a71dac87 (patch)
tree1023d721c59e29150f445bbba25a0e11bed4c1ae
parentff3bb3aa18e71860d644a50632088ec282968de4 (diff)
downloadrockbox-eed62f1657f4f2b08571f0bd2b1827f3a71dac87.tar.gz
rockbox-eed62f1657f4f2b08571f0bd2b1827f3a71dac87.zip
Change the radio screen and recording screen to use the global_status structure for state. I guess global_status had been added already and I missed it. :D
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12222 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/filetree.c2
-rw-r--r--apps/gui/statusbar.c5
-rw-r--r--apps/recorder/radio.c51
-rw-r--r--apps/recorder/radio.h1
-rw-r--r--apps/recorder/recording.c11
-rw-r--r--apps/recorder/recording.h1
-rw-r--r--apps/settings.c15
-rw-r--r--apps/settings.h9
-rw-r--r--apps/status.c6
-rw-r--r--firmware/export/fmradio.h5
10 files changed, 53 insertions, 53 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 10174dbb31..4a68d00f8b 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -445,7 +445,7 @@ int ft_enter(struct tree_context* c)
445 { 445 {
446 set_file(buf, global_settings.fmr_file, MAX_FILENAME); 446 set_file(buf, global_settings.fmr_file, MAX_FILENAME);
447 radio_load_presets(global_settings.fmr_file); 447 radio_load_presets(global_settings.fmr_file);
448 if(!in_radio_screen()) 448 if(!global_status.in_radio_screen)
449 radio_screen(); 449 radio_screen();
450 } 450 }
451 /* 451 /*
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index d3f4813e37..f1943f3356 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -258,8 +258,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
258#endif 258#endif
259#ifdef HAVE_RECORDING 259#ifdef HAVE_RECORDING
260 /* turn off volume display in recording screen */ 260 /* turn off volume display in recording screen */
261 bool recscreen_on = in_recording_screen(); 261 if (!global_status.in_recording_screen)
262 if (!recscreen_on)
263#endif 262#endif
264 bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume); 263 bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume);
265 gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play); 264 gui_statusbar_icon_play_state(display, current_playmode() + Icon_Play);
@@ -267,7 +266,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
267#ifdef HAVE_RECORDING 266#ifdef HAVE_RECORDING
268 /* If in recording screen, replace repeat mode, volume 267 /* If in recording screen, replace repeat mode, volume
269 and shuffle icons with recording info */ 268 and shuffle icons with recording info */
270 if (recscreen_on) 269 if (global_status.in_recording_screen)
271 gui_statusbar_icon_recording_info(display); 270 gui_statusbar_icon_recording_info(display);
272 else 271 else
273#endif 272#endif
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index dc533cf017..97d6266a02 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -114,9 +114,6 @@ static int curr_preset = -1;
114static int curr_freq; 114static int curr_freq;
115static int radio_mode = RADIO_SCAN_MODE; 115static int radio_mode = RADIO_SCAN_MODE;
116 116
117static int radio_status = FMRADIO_OFF;
118static bool in_screen = false;
119
120#define MAX_PRESETS 64 117#define MAX_PRESETS 64
121static bool presets_loaded = false, presets_changed = false; 118static bool presets_loaded = false, presets_changed = false;
122static struct fmstation presets[MAX_PRESETS]; 119static struct fmstation presets[MAX_PRESETS];
@@ -185,14 +182,11 @@ void radio_init(void)
185 radio_stop(); 182 radio_stop();
186} 183}
187 184
185/* For powermgmt.c to check status for shutdown since it can't access
186 the global_status structure directly. */
188int get_radio_status(void) 187int get_radio_status(void)
189{ 188{
190 return radio_status; 189 return global_status.radio_status;
191}
192
193bool in_radio_screen(void)
194{
195 return in_screen;
196} 190}
197 191
198/* secret flag for starting paused - prevents unmute */ 192/* secret flag for starting paused - prevents unmute */
@@ -202,14 +196,14 @@ void radio_start(void)
202 bool start_paused; 196 bool start_paused;
203 int mute_timeout; 197 int mute_timeout;
204 198
205 if(radio_status == FMRADIO_PLAYING) 199 if(global_status.radio_status == FMRADIO_PLAYING)
206 return; 200 return;
207 201
208 start_paused = radio_status & FMRADIO_START_PAUSED; 202 start_paused = global_status.radio_status & FMRADIO_START_PAUSED;
209 /* clear flag before any yielding */ 203 /* clear flag before any yielding */
210 radio_status &= ~FMRADIO_START_PAUSED; 204 global_status.radio_status &= ~FMRADIO_START_PAUSED;
211 205
212 if(radio_status == FMRADIO_OFF) 206 if(global_status.radio_status == FMRADIO_OFF)
213 radio_power(true); 207 radio_power(true);
214 208
215 curr_freq = global_status.last_frequency 209 curr_freq = global_status.last_frequency
@@ -219,7 +213,7 @@ void radio_start(void)
219 radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ 213 radio_set(RADIO_SLEEP, 0); /* wake up the tuner */
220 radio_set(RADIO_FREQUENCY, curr_freq); 214 radio_set(RADIO_FREQUENCY, curr_freq);
221 215
222 if(radio_status == FMRADIO_OFF) 216 if(global_status.radio_status == FMRADIO_OFF)
223 { 217 {
224 radio_set(RADIO_IF_MEASUREMENT, 0); 218 radio_set(RADIO_IF_MEASUREMENT, 0);
225 radio_set(RADIO_SENSITIVITY, 0); 219 radio_set(RADIO_SENSITIVITY, 0);
@@ -248,34 +242,34 @@ void radio_start(void)
248 if(!start_paused) 242 if(!start_paused)
249 radio_set(RADIO_MUTE, 0); 243 radio_set(RADIO_MUTE, 0);
250 244
251 radio_status = FMRADIO_PLAYING; 245 global_status.radio_status = FMRADIO_PLAYING;
252} /* radio_start */ 246} /* radio_start */
253 247
254void radio_pause(void) 248void radio_pause(void)
255{ 249{
256 if(radio_status == FMRADIO_PAUSED) 250 if(global_status.radio_status == FMRADIO_PAUSED)
257 return; 251 return;
258 252
259 if(radio_status == FMRADIO_OFF) 253 if(global_status.radio_status == FMRADIO_OFF)
260 { 254 {
261 radio_status |= FMRADIO_START_PAUSED; 255 global_status.radio_status |= FMRADIO_START_PAUSED;
262 radio_start(); 256 radio_start();
263 } 257 }
264 258
265 radio_set(RADIO_MUTE, 1); 259 radio_set(RADIO_MUTE, 1);
266 radio_set(RADIO_SLEEP, 1); 260 radio_set(RADIO_SLEEP, 1);
267 261
268 radio_status = FMRADIO_PAUSED; 262 global_status.radio_status = FMRADIO_PAUSED;
269} /* radio_pause */ 263} /* radio_pause */
270 264
271void radio_stop(void) 265void radio_stop(void)
272{ 266{
273 if(radio_status == FMRADIO_OFF) 267 if(global_status.radio_status == FMRADIO_OFF)
274 return; 268 return;
275 269
276 radio_set(RADIO_MUTE, 1); 270 radio_set(RADIO_MUTE, 1);
277 radio_set(RADIO_SLEEP, 1); /* low power mode, if available */ 271 radio_set(RADIO_SLEEP, 1); /* low power mode, if available */
278 radio_status = FMRADIO_OFF; 272 global_status.radio_status = FMRADIO_OFF;
279 radio_power(false); /* status update, power off if avail. */ 273 radio_power(false); /* status update, power off if avail. */
280} /* radio_stop */ 274} /* radio_stop */
281 275
@@ -397,7 +391,7 @@ bool radio_screen(void)
397 gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) ); 391 gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
398#endif 392#endif
399 /* change status to "in screen" */ 393 /* change status to "in screen" */
400 in_screen = true; 394 global_status.in_radio_screen = true;
401 395
402 /* always display status bar in radio screen for now */ 396 /* always display status bar in radio screen for now */
403 global_settings.statusbar = true; 397 global_settings.statusbar = true;
@@ -422,7 +416,7 @@ bool radio_screen(void)
422 } 416 }
423 417
424#ifndef SIMULATOR 418#ifndef SIMULATOR
425 if(radio_status == FMRADIO_OFF) 419 if(global_status.radio_status == FMRADIO_OFF)
426 audio_stop(); 420 audio_stop();
427 421
428#if CONFIG_CODEC != SWCODEC 422#if CONFIG_CODEC != SWCODEC
@@ -449,10 +443,11 @@ bool radio_screen(void)
449 443
450 /* turn on radio */ 444 /* turn on radio */
451#if CONFIG_CODEC == SWCODEC 445#if CONFIG_CODEC == SWCODEC
452 rec_set_source(AUDIO_SRC_FMRADIO, (radio_status == FMRADIO_PAUSED) ? 446 rec_set_source(AUDIO_SRC_FMRADIO,
447 (global_status.radio_status == FMRADIO_PAUSED) ?
453 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING); 448 SRCF_FMRADIO_PAUSED : SRCF_FMRADIO_PLAYING);
454#else 449#else
455 if (radio_status == FMRADIO_OFF) 450 if (global_status.radio_status == FMRADIO_OFF)
456 radio_start(); 451 radio_start();
457#endif 452#endif
458 453
@@ -676,7 +671,7 @@ bool radio_screen(void)
676 break; 671 break;
677 672
678 case ACTION_FM_PLAY: 673 case ACTION_FM_PLAY:
679 if (radio_status == FMRADIO_PLAYING) 674 if (global_status.radio_status == FMRADIO_PLAYING)
680 radio_pause(); 675 radio_pause();
681 else 676 else
682 radio_start(); 677 radio_start();
@@ -819,7 +814,7 @@ bool radio_screen(void)
819 timeout = current_tick + HZ; 814 timeout = current_tick + HZ;
820 815
821 /* keep "mono" from always being displayed when paused */ 816 /* keep "mono" from always being displayed when paused */
822 if (radio_status != FMRADIO_PAUSED) 817 if (global_status.radio_status != FMRADIO_PAUSED)
823 { 818 {
824 stereo = radio_get(RADIO_STEREO) && 819 stereo = radio_get(RADIO_STEREO) &&
825 !global_settings.fm_force_mono; 820 !global_settings.fm_force_mono;
@@ -962,7 +957,7 @@ bool radio_screen(void)
962 /* restore status bar settings */ 957 /* restore status bar settings */
963 global_settings.statusbar = statusbar; 958 global_settings.statusbar = statusbar;
964 959
965 in_screen = false; 960 global_status.in_radio_screen = false;
966 961
967 return have_recorded; 962 return have_recorded;
968} /* radio_screen */ 963} /* radio_screen */
diff --git a/apps/recorder/radio.h b/apps/recorder/radio.h
index a4f9f1a978..0bfda3bccf 100644
--- a/apps/recorder/radio.h
+++ b/apps/recorder/radio.h
@@ -31,7 +31,6 @@ void radio_start(void);
31void radio_pause(void); 31void 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);
35 34
36#define MAX_FMPRESET_LEN 27 35#define MAX_FMPRESET_LEN 27
37 36
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index cb934877a9..a0a929f3a6 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -70,13 +70,6 @@
70#include "radio.h" 70#include "radio.h"
71#ifdef HAVE_RECORDING 71#ifdef HAVE_RECORDING
72 72
73static bool in_screen = false;
74
75bool in_recording_screen(void)
76{
77 return in_screen;
78}
79
80#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) 73#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
81 74
82#if CONFIG_KEYPAD == RECORDER_PAD 75#if CONFIG_KEYPAD == RECORDER_PAD
@@ -801,7 +794,7 @@ bool recording_screen(bool no_source)
801 794
802 struct audio_recording_options rec_options; 795 struct audio_recording_options rec_options;
803 796
804 in_screen = true; 797 global_status.in_recording_screen = true;
805 cursor = 0; 798 cursor = 0;
806#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 799#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
807 ata_set_led_enabled(false); 800 ata_set_led_enabled(false);
@@ -1771,7 +1764,7 @@ bool recording_screen(bool no_source)
1771 peak_meter_trigger(false); 1764 peak_meter_trigger(false);
1772 peak_meter_set_trigger_listener(NULL); 1765 peak_meter_set_trigger_listener(NULL);
1773 1766
1774 in_screen = false; 1767 global_status.in_recording_screen = false;
1775 sound_settings_apply(); 1768 sound_settings_apply();
1776 1769
1777 FOR_NB_SCREENS(i) 1770 FOR_NB_SCREENS(i)
diff --git a/apps/recorder/recording.h b/apps/recorder/recording.h
index 1b313ecab5..a67337b9b6 100644
--- a/apps/recorder/recording.h
+++ b/apps/recorder/recording.h
@@ -19,7 +19,6 @@
19#ifndef RECORDING_H 19#ifndef RECORDING_H
20#define RECORDING_H 20#define RECORDING_H
21 21
22bool in_recording_screen(void);
23bool recording_screen(bool no_source); 22bool recording_screen(bool no_source);
24char *rec_create_filename(char *buf); 23char *rec_create_filename(char *buf);
25int rec_create_directory(void); 24int rec_create_directory(void);
diff --git a/apps/settings.c b/apps/settings.c
index f0833a65c2..4d06f9b09c 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -73,7 +73,20 @@
73void dac_line_in(bool enable); 73void dac_line_in(bool enable);
74#endif 74#endif
75struct user_settings global_settings; 75struct user_settings global_settings;
76struct system_status global_status; 76
77/* Initial values for globally needed state data that shouldn't be saved
78 or reset should be defined here and not in settings_list */
79struct system_status global_status =
80{
81#ifdef CONFIG_TUNER
82 .in_radio_screen = false,
83 .radio_status = FMRADIO_OFF,
84#endif
85#ifdef HAVE_RECORDING
86 .in_recording_screen = false,
87#endif
88};
89
77#ifdef HAVE_RECORDING 90#ifdef HAVE_RECORDING
78const char rec_base_directory[] = REC_BASE_DIR; 91const char rec_base_directory[] = REC_BASE_DIR;
79#endif 92#endif
diff --git a/apps/settings.h b/apps/settings.h
index 7321d39cf5..379084b885 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -263,8 +263,17 @@ struct system_status
263#ifdef CONFIG_TUNER 263#ifdef CONFIG_TUNER
264 int last_frequency; /* Last frequency for resuming, in FREQ_STEP units, 264 int last_frequency; /* Last frequency for resuming, in FREQ_STEP units,
265 relative to MIN_FREQ */ 265 relative to MIN_FREQ */
266 bool in_radio_screen; /* Currently in radio screen?
267 Set by radio_screen. */
268 int radio_status; /* Current radio status (off, playing, paused)
269 Set by radio control functions. */
270#endif
271#ifdef HAVE_RECORDING
272 bool in_recording_screen; /* Currently in recording screen?
273 Set by recording_screen. */
266#endif 274#endif
267}; 275};
276
268struct user_settings 277struct user_settings
269{ 278{
270 /* audio settings */ 279 /* audio settings */
diff --git a/apps/status.c b/apps/status.c
index 75219d604c..d03cb98157 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -97,12 +97,10 @@ int current_playmode(void)
97#endif 97#endif
98 98
99#ifdef CONFIG_TUNER 99#ifdef CONFIG_TUNER
100 audio_stat = get_radio_status(); 100 if(global_status.radio_status & FMRADIO_PLAYING)
101
102 if(audio_stat & FMRADIO_PLAYING)
103 return STATUS_RADIO; 101 return STATUS_RADIO;
104 102
105 if(audio_stat & FMRADIO_PAUSED) 103 if(global_status.radio_status & FMRADIO_PAUSED)
106 return STATUS_RADIO_PAUSE; 104 return STATUS_RADIO_PAUSE;
107#endif 105#endif
108 106
diff --git a/firmware/export/fmradio.h b/firmware/export/fmradio.h
index 73113237c0..87fcfd191c 100644
--- a/firmware/export/fmradio.h
+++ b/firmware/export/fmradio.h
@@ -29,11 +29,6 @@
29#define FMRADIO_PLAYING 0x1 29#define FMRADIO_PLAYING 0x1
30#define FMRADIO_PAUSED 0x2 30#define FMRADIO_PAUSED 0x2
31 31
32/* returns the IN flag */
33#define FMRADIO_IN_SCREEN(s) ((s) & FMRADIO_IN_FLAG)
34#define FMRADIO_STATUS_PLAYING(s) ((s) & FMRADIO_PLAYING_OUT)
35#define FMRADIO_STATUS_PAUSED(s) ((s) & FMRADIO_PAUSED_OUT)
36
37extern int get_radio_status(void); 32extern int get_radio_status(void);
38 33
39extern int fmradio_read(int addr); 34extern int fmradio_read(int addr);