diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/recorder/radio.c | 115 |
1 files changed, 79 insertions, 36 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 3e45b712b5..9688a3a727 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "screens.h" | 42 | #include "screens.h" |
43 | #include "peakmeter.h" | 43 | #include "peakmeter.h" |
44 | #include "lang.h" | 44 | #include "lang.h" |
45 | #include "font.h" | ||
45 | 46 | ||
46 | #ifdef HAVE_FMRADIO | 47 | #ifdef HAVE_FMRADIO |
47 | 48 | ||
@@ -107,20 +108,27 @@ bool radio_screen(void) | |||
107 | int val; | 108 | int val; |
108 | int freq; | 109 | int freq; |
109 | int i_freq; | 110 | int i_freq; |
110 | bool lock; | 111 | bool stereo = false; |
111 | bool stereo; | ||
112 | int search_dir = 0; | 112 | int search_dir = 0; |
113 | int fw, fh; | 113 | int fw, fh; |
114 | 114 | int last_stereo_status = false; | |
115 | int top_of_screen = 0; | ||
115 | bool update_screen = true; | 116 | bool update_screen = true; |
116 | int timeout = current_tick + HZ/10; | 117 | int timeout = current_tick + HZ/10; |
118 | bool screen_freeze = false; | ||
117 | 119 | ||
118 | lcd_clear_display(); | 120 | lcd_clear_display(); |
119 | lcd_setmargins(0, 8); | 121 | lcd_setmargins(0, 8); |
120 | status_draw(true); | 122 | status_draw(true); |
121 | fmradio_set_status(FMRADIO_PLAYING); | 123 | fmradio_set_status(FMRADIO_PLAYING); |
122 | lcd_getstringsize("A", &fw, &fh); | ||
123 | 124 | ||
125 | font_get(FONT_UI); | ||
126 | lcd_getstringsize("M", &fw, &fh); | ||
127 | |||
128 | /* Adjust for font size, trying to center the information vertically */ | ||
129 | if(fh < 10) | ||
130 | top_of_screen = 1; | ||
131 | |||
124 | radio_load_presets(); | 132 | radio_load_presets(); |
125 | 133 | ||
126 | mpeg_stop(); | 134 | mpeg_stop(); |
@@ -133,8 +141,10 @@ bool radio_screen(void) | |||
133 | fmradio_set(2, 0x140884); /* 5kHz, 7.2MHz crystal */ | 141 | fmradio_set(2, 0x140884); /* 5kHz, 7.2MHz crystal */ |
134 | radio_set_frequency(curr_freq); | 142 | radio_set_frequency(curr_freq); |
135 | curr_preset = find_preset(curr_freq); | 143 | curr_preset = find_preset(curr_freq); |
136 | 144 | ||
137 | peak_meter_playback(true); | 145 | /* We use the A/D pseudo peak */ |
146 | peak_meter_playback(false); | ||
147 | peak_meter_enabled = true; | ||
138 | 148 | ||
139 | buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), | 149 | buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), |
140 | NULL); | 150 | NULL); |
@@ -198,6 +208,7 @@ bool radio_screen(void) | |||
198 | radio_set_frequency(curr_freq); | 208 | radio_set_frequency(curr_freq); |
199 | curr_preset = find_preset(curr_freq); | 209 | curr_preset = find_preset(curr_freq); |
200 | search_dir = 0; | 210 | search_dir = 0; |
211 | update_screen = true; | ||
201 | break; | 212 | break; |
202 | 213 | ||
203 | case BUTTON_RIGHT: | 214 | case BUTTON_RIGHT: |
@@ -208,6 +219,7 @@ bool radio_screen(void) | |||
208 | radio_set_frequency(curr_freq); | 219 | radio_set_frequency(curr_freq); |
209 | curr_preset = find_preset(curr_freq); | 220 | curr_preset = find_preset(curr_freq); |
210 | search_dir = 0; | 221 | search_dir = 0; |
222 | update_screen = true; | ||
211 | break; | 223 | break; |
212 | 224 | ||
213 | case BUTTON_LEFT | BUTTON_REPEAT: | 225 | case BUTTON_LEFT | BUTTON_REPEAT: |
@@ -260,6 +272,20 @@ bool radio_screen(void) | |||
260 | update_screen = true; | 272 | update_screen = true; |
261 | break; | 273 | break; |
262 | 274 | ||
275 | case BUTTON_F3: | ||
276 | if(!screen_freeze) | ||
277 | { | ||
278 | splash(0, 0, true, "Screen frozen"); | ||
279 | lcd_update(); | ||
280 | screen_freeze = true; | ||
281 | } | ||
282 | else | ||
283 | { | ||
284 | update_screen = true; | ||
285 | screen_freeze = false; | ||
286 | } | ||
287 | break; | ||
288 | |||
263 | case SYS_USB_CONNECTED: | 289 | case SYS_USB_CONNECTED: |
264 | usb_screen(); | 290 | usb_screen(); |
265 | fmradio_set_status(0); | 291 | fmradio_set_status(0); |
@@ -268,41 +294,58 @@ bool radio_screen(void) | |||
268 | 294 | ||
269 | peak_meter_peek(); | 295 | peak_meter_peek(); |
270 | 296 | ||
271 | lcd_clearrect(0, 8 + fh*4, LCD_WIDTH, fh); | 297 | if(!screen_freeze) |
272 | peak_meter_draw(0, 8 + fh*4, LCD_WIDTH, fh); | ||
273 | lcd_update_rect(0, 8 + fh*4, LCD_WIDTH, fh); | ||
274 | |||
275 | if(update_screen || TIME_AFTER(current_tick, timeout)) | ||
276 | { | 298 | { |
277 | update_screen = false; | 299 | lcd_setmargins(0, 8); |
278 | 300 | lcd_clearrect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); | |
279 | timeout = current_tick + HZ/2; | 301 | peak_meter_draw(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); |
280 | 302 | lcd_update_rect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); | |
281 | freq = curr_freq / 100000; | 303 | |
282 | snprintf(buf, 128, str(LANG_FM_STATION), freq / 10, freq % 10); | 304 | if(TIME_AFTER(current_tick, timeout)) |
283 | lcd_puts(0, 2, buf); | ||
284 | |||
285 | val = fmradio_read(3); | ||
286 | stereo = (val & 0x100000)?true:false; | ||
287 | lock = (val & 0x80000)?true:false; | ||
288 | snprintf(buf, 128, | ||
289 | stereo?str(LANG_CHANNEL_STEREO):str(LANG_CHANNEL_MONO)); | ||
290 | lcd_puts(0, 3, buf); | ||
291 | |||
292 | if(curr_preset >= 0) | ||
293 | { | 305 | { |
294 | lcd_puts_scroll(0, 1, presets[curr_preset].name); | 306 | timeout = current_tick + HZ; |
307 | |||
308 | val = fmradio_read(3); | ||
309 | stereo = (val & 0x100000)?true:false; | ||
310 | if(stereo != last_stereo_status) | ||
311 | { | ||
312 | update_screen = true; | ||
313 | last_stereo_status = stereo; | ||
314 | } | ||
295 | } | 315 | } |
296 | else | 316 | |
317 | if(update_screen) | ||
297 | { | 318 | { |
298 | lcd_clearrect(0, 8+fh*1, LCD_WIDTH, fh); | 319 | lcd_setfont(FONT_UI); |
320 | |||
321 | if(curr_preset >= 0) | ||
322 | { | ||
323 | lcd_puts_scroll(0, top_of_screen, | ||
324 | presets[curr_preset].name); | ||
325 | } | ||
326 | else | ||
327 | { | ||
328 | lcd_clearrect(0, 8 + top_of_screen*fh, LCD_WIDTH, fh); | ||
329 | } | ||
330 | |||
331 | freq = curr_freq / 100000; | ||
332 | snprintf(buf, 128, str(LANG_FM_STATION), freq / 10, freq % 10); | ||
333 | lcd_puts(0, top_of_screen + 1, buf); | ||
334 | |||
335 | snprintf(buf, 128, | ||
336 | stereo?str(LANG_CHANNEL_STEREO): | ||
337 | str(LANG_CHANNEL_MONO)); | ||
338 | lcd_puts(0, top_of_screen + 2, buf); | ||
339 | |||
340 | /* Only force the redraw if update_screen is true */ | ||
341 | status_draw(update_screen); | ||
342 | |||
343 | buttonbar_draw(); | ||
344 | |||
345 | lcd_update(); | ||
346 | |||
347 | update_screen = false; | ||
299 | } | 348 | } |
300 | |||
301 | status_draw(true); | ||
302 | |||
303 | buttonbar_draw(); | ||
304 | |||
305 | lcd_update(); | ||
306 | } | 349 | } |
307 | } | 350 | } |
308 | 351 | ||