diff options
author | Anton Oleynikov <len0x@rockbox.org> | 2005-11-13 21:03:53 +0000 |
---|---|---|
committer | Anton Oleynikov <len0x@rockbox.org> | 2005-11-13 21:03:53 +0000 |
commit | 697e832bef16f564d74611bab68690470e8cedde (patch) | |
tree | df3704a7e21f7d14a320e0ae335f373f555d21bc /apps/recorder | |
parent | 061f38096a6990f1b3de2fd2dc4f06ecb29e363f (diff) | |
download | rockbox-697e832bef16f564d74611bab68690470e8cedde.tar.gz rockbox-697e832bef16f564d74611bab68690470e8cedde.zip |
fm radio: new preset mode, new button assignment and remote support for iRiver,
misc clean up and improvements
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7849 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder')
-rw-r--r-- | apps/recorder/radio.c | 386 |
1 files changed, 312 insertions, 74 deletions
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 4563c6fe15..fa0f091156 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c | |||
@@ -21,7 +21,6 @@ | |||
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | #include "sprintf.h" | 23 | #include "sprintf.h" |
24 | #include "lcd.h" | ||
25 | #include "mas.h" | 24 | #include "mas.h" |
26 | #include "settings.h" | 25 | #include "settings.h" |
27 | #include "button.h" | 26 | #include "button.h" |
@@ -52,6 +51,10 @@ | |||
52 | #include "hwcompat.h" | 51 | #include "hwcompat.h" |
53 | #include "power.h" | 52 | #include "power.h" |
54 | #include "sound.h" | 53 | #include "sound.h" |
54 | #include "screen_access.h" | ||
55 | #include "statusbar.h" | ||
56 | #include "textarea.h" | ||
57 | #include "splash.h" | ||
55 | 58 | ||
56 | #ifdef CONFIG_TUNER | 59 | #ifdef CONFIG_TUNER |
57 | 60 | ||
@@ -66,15 +69,39 @@ | |||
66 | #define FM_RECORD BUTTON_F3 | 69 | #define FM_RECORD BUTTON_F3 |
67 | #define FM_FREEZE BUTTON_PLAY | 70 | #define FM_FREEZE BUTTON_PLAY |
68 | #define FM_STOP BUTTON_OFF | 71 | #define FM_STOP BUTTON_OFF |
72 | #define FM_MODE (BUTTON_ON | BUTTON_REPEAT) | ||
73 | #define FM_EXIT_PRE BUTTON_ON | ||
69 | #define FM_EXIT (BUTTON_ON | BUTTON_REL) | 74 | #define FM_EXIT (BUTTON_ON | BUTTON_REL) |
70 | #define FM_PRESET_ADD BUTTON_F1 | 75 | #define FM_PRESET_ADD BUTTON_F1 |
71 | #define FM_PRESET_ACTION BUTTON_F3 | 76 | #define FM_PRESET_ACTION BUTTON_F3 |
72 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD | 77 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD |
73 | #define FM_MENU BUTTON_MODE | 78 | /* pause/play - short PLAY */ |
74 | #define FM_PRESET BUTTON_ON | 79 | #define FM_PLAY_PRE BUTTON_ON |
80 | #define FM_RC_PLAY_PRE BUTTON_RC_ON | ||
81 | #define FM_PLAY (BUTTON_ON | BUTTON_REL) | ||
82 | #define FM_RC_PLAY (BUTTON_RC_ON | BUTTON_REL) | ||
83 | /* preset/scan mode - long PLAY */ | ||
84 | #define FM_MODE (BUTTON_ON | BUTTON_REPEAT) | ||
85 | #define FM_RC_MODE (BUTTON_RC_ON | BUTTON_REPEAT) | ||
86 | /* preset menu - short SELECT */ | ||
87 | #define FM_PRESET_PRE BUTTON_SELECT | ||
88 | #define FM_RC_PRESET_PRE BUTTON_RC_MENU | ||
89 | #define FM_PRESET (BUTTON_SELECT | BUTTON_REL) | ||
90 | #define FM_RC_PRESET (BUTTON_RC_MENU | BUTTON_REL) | ||
91 | /* fm menu - long SELECT */ | ||
92 | #define FM_MENU (BUTTON_SELECT | BUTTON_REPEAT) | ||
93 | #define FM_RC_MENU (BUTTON_RC_MENU | BUTTON_REPEAT) | ||
94 | /* main menu(exit radio while playing) - A-B */ | ||
95 | #define FM_EXIT_PRE BUTTON_MODE | ||
96 | #define FM_EXIT (BUTTON_MODE | BUTTON_REL) | ||
97 | #define FM_RC_EXIT_PRE BUTTON_RC_MODE | ||
98 | #define FM_RC_EXIT (BUTTON_RC_MODE | BUTTON_REL) | ||
99 | /* prev/next preset on the remote - BITRATE/SOURCE */ | ||
100 | #define FM_NEXT_PRESET (BUTTON_RC_BITRATE | BUTTON_REL) | ||
101 | #define FM_PREV_PRESET (BUTTON_RC_SOURCE | BUTTON_REL) | ||
102 | /* stop and exit radio - STOP */ | ||
75 | #define FM_STOP BUTTON_OFF | 103 | #define FM_STOP BUTTON_OFF |
76 | #define FM_EXIT_PRE BUTTON_SELECT | 104 | #define FM_RC_STOP BUTTON_RC_STOP |
77 | #define FM_EXIT (BUTTON_SELECT | BUTTON_REL) | ||
78 | #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted keypad */ | 105 | #elif CONFIG_KEYPAD == ONDIO_PAD /* restricted keypad */ |
79 | #define FM_MENU (BUTTON_MENU | BUTTON_REPEAT) | 106 | #define FM_MENU (BUTTON_MENU | BUTTON_REPEAT) |
80 | #define FM_RECORD_DBLPRE BUTTON_MENU | 107 | #define FM_RECORD_DBLPRE BUTTON_MENU |
@@ -87,10 +114,14 @@ | |||
87 | #define MIN_FREQ (87500000) | 114 | #define MIN_FREQ (87500000) |
88 | #define FREQ_STEP 100000 | 115 | #define FREQ_STEP 100000 |
89 | 116 | ||
117 | #define RADIO_SCAN_MODE 0 | ||
118 | #define RADIO_PRESET_MODE 1 | ||
119 | |||
90 | static int curr_preset = -1; | 120 | static int curr_preset = -1; |
91 | static int curr_freq; | 121 | static int curr_freq; |
122 | static int radio_mode = RADIO_SCAN_MODE; | ||
92 | 123 | ||
93 | #define MAX_PRESETS 32 | 124 | #define MAX_PRESETS 64 |
94 | static bool presets_loaded = false; | 125 | static bool presets_loaded = false; |
95 | static struct fmstation presets[MAX_PRESETS]; | 126 | static struct fmstation presets[MAX_PRESETS]; |
96 | 127 | ||
@@ -173,12 +204,67 @@ static int find_preset(int freq) | |||
173 | return -1; | 204 | return -1; |
174 | } | 205 | } |
175 | 206 | ||
207 | static int find_closest_preset(int freq) | ||
208 | { | ||
209 | int i; | ||
210 | int diff; | ||
211 | int min_diff = MAX_FREQ; | ||
212 | int preset = -1; | ||
213 | |||
214 | for(i = 0;i < MAX_PRESETS;i++) | ||
215 | { | ||
216 | diff = freq - presets[i].frequency; | ||
217 | if(diff==0) | ||
218 | return i; | ||
219 | if(diff < 0) | ||
220 | diff = -diff; | ||
221 | if(diff < min_diff) | ||
222 | { | ||
223 | preset = i; | ||
224 | min_diff = diff; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | return preset; | ||
229 | } | ||
230 | |||
231 | |||
232 | |||
176 | static void remember_frequency(void) | 233 | static void remember_frequency(void) |
177 | { | 234 | { |
178 | global_settings.last_frequency = (curr_freq - MIN_FREQ) / FREQ_STEP; | 235 | global_settings.last_frequency = (curr_freq - MIN_FREQ) / FREQ_STEP; |
179 | settings_save(); | 236 | settings_save(); |
180 | } | 237 | } |
181 | 238 | ||
239 | void next_preset(int direction) | ||
240 | { | ||
241 | if (num_presets < 1) | ||
242 | return; | ||
243 | curr_preset = find_preset(curr_freq); | ||
244 | if(curr_preset == -1) | ||
245 | curr_preset = find_closest_preset(curr_freq); | ||
246 | else if ((curr_preset < (num_presets-1) && direction > 0) || | ||
247 | ((curr_preset > 0) && direction < 0)) | ||
248 | { | ||
249 | if (direction > 0) | ||
250 | curr_preset++; | ||
251 | else | ||
252 | curr_preset--; | ||
253 | } | ||
254 | else if (num_presets > 1) | ||
255 | { | ||
256 | if (direction > 0) | ||
257 | curr_preset = 0; | ||
258 | else | ||
259 | curr_preset = num_presets - 1; | ||
260 | } | ||
261 | else | ||
262 | return; | ||
263 | curr_freq = presets[curr_preset].frequency; | ||
264 | radio_set(RADIO_FREQUENCY, curr_freq); | ||
265 | remember_frequency(); | ||
266 | } | ||
267 | |||
182 | bool radio_screen(void) | 268 | bool radio_screen(void) |
183 | { | 269 | { |
184 | char buf[MAX_PATH]; | 270 | char buf[MAX_PATH]; |
@@ -187,11 +273,11 @@ bool radio_screen(void) | |||
187 | #ifdef FM_RECORD_DBLPRE | 273 | #ifdef FM_RECORD_DBLPRE |
188 | unsigned long rec_lastclick = 0; | 274 | unsigned long rec_lastclick = 0; |
189 | #endif | 275 | #endif |
190 | int freq; | 276 | int freq, i; |
191 | bool tuned; | 277 | bool tuned; |
192 | bool stereo = false; | 278 | bool stereo = false; |
193 | int search_dir = 0; | 279 | int search_dir = 0; |
194 | int fw, fh; | 280 | int fh; |
195 | bool last_stereo_status = false; | 281 | bool last_stereo_status = false; |
196 | int top_of_screen = 0; | 282 | int top_of_screen = 0; |
197 | bool update_screen = true; | 283 | bool update_screen = true; |
@@ -202,15 +288,19 @@ bool radio_screen(void) | |||
202 | unsigned int last_seconds = 0; | 288 | unsigned int last_seconds = 0; |
203 | int hours, minutes; | 289 | int hours, minutes; |
204 | bool keep_playing = false; | 290 | bool keep_playing = false; |
291 | bool statusbar = global_settings.statusbar; | ||
292 | /* always display status bar in radio screen for now */ | ||
293 | global_settings.statusbar = true; | ||
205 | 294 | ||
206 | lcd_clear_display(); | 295 | FOR_NB_SCREENS(i){ |
207 | lcd_setmargins(0, 8); | 296 | gui_textarea_clear(&screens[i]); |
208 | status_draw(true); | 297 | screen_set_xmargin(&screens[i],0); |
209 | radio_set_status(FMRADIO_PLAYING); | 298 | } |
210 | 299 | ||
211 | font_get(FONT_UI); | 300 | gui_syncstatusbar_draw(&statusbars,true); |
212 | lcd_getstringsize("M", &fw, &fh); | ||
213 | 301 | ||
302 | fh = font_get(FONT_UI)->height; | ||
303 | |||
214 | /* Adjust for font size, trying to center the information vertically */ | 304 | /* Adjust for font size, trying to center the information vertically */ |
215 | if(fh < 10) | 305 | if(fh < 10) |
216 | top_of_screen = 1; | 306 | top_of_screen = 1; |
@@ -250,7 +340,8 @@ bool radio_screen(void) | |||
250 | sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); | 340 | sound_default(SOUND_RIGHT_GAIN), AUDIO_GAIN_LINEIN); |
251 | #else | 341 | #else |
252 | uda1380_enable_recording(false); | 342 | uda1380_enable_recording(false); |
253 | uda1380_set_recvol(10, 10, AUDIO_GAIN_LINEIN); | 343 | uda1380_set_recvol(10, 10, AUDIO_GAIN_ADC); |
344 | uda1380_set_recvol(0, 0, AUDIO_GAIN_LINEIN); | ||
254 | uda1380_set_monitor(true); | 345 | uda1380_set_monitor(true); |
255 | 346 | ||
256 | /* Set the input multiplexer to FM */ | 347 | /* Set the input multiplexer to FM */ |
@@ -260,14 +351,21 @@ bool radio_screen(void) | |||
260 | 351 | ||
261 | curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; | 352 | curr_freq = global_settings.last_frequency * FREQ_STEP + MIN_FREQ; |
262 | 353 | ||
263 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ | 354 | if(radio_get_status() == FMRADIO_OFF){ |
264 | radio_set(RADIO_FREQUENCY, curr_freq); | 355 | radio_set(RADIO_SLEEP, 0); /* wake up the tuner */ |
265 | radio_set(RADIO_IF_MEASUREMENT, 0); | 356 | radio_set(RADIO_FREQUENCY, curr_freq); |
266 | radio_set(RADIO_SENSITIVITY, 0); | 357 | radio_set(RADIO_IF_MEASUREMENT, 0); |
267 | radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono); | 358 | radio_set(RADIO_SENSITIVITY, 0); |
268 | radio_set(RADIO_MUTE, 0); | 359 | radio_set(RADIO_FORCE_MONO, global_settings.fm_force_mono); |
360 | radio_set(RADIO_MUTE, 0); | ||
361 | } | ||
362 | radio_set_status(FMRADIO_PLAYING); | ||
269 | 363 | ||
270 | curr_preset = find_preset(curr_freq); | 364 | curr_preset = find_preset(curr_freq); |
365 | #ifdef FM_MODE | ||
366 | if(curr_preset != -1) | ||
367 | radio_mode = RADIO_PRESET_MODE; | ||
368 | #endif | ||
271 | 369 | ||
272 | #if CONFIG_KEYPAD == RECORDER_PAD | 370 | #if CONFIG_KEYPAD == RECORDER_PAD |
273 | buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), | 371 | buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), |
@@ -314,6 +412,9 @@ bool radio_screen(void) | |||
314 | button = button_get_w_tmo(HZ / PEAK_METER_FPS); | 412 | button = button_get_w_tmo(HZ / PEAK_METER_FPS); |
315 | switch(button) | 413 | switch(button) |
316 | { | 414 | { |
415 | #ifdef FM_RC_STOP | ||
416 | case FM_RC_STOP: | ||
417 | #endif | ||
317 | case FM_STOP: | 418 | case FM_STOP: |
318 | #ifndef SIMULATOR | 419 | #ifndef SIMULATOR |
319 | if(audio_status() == AUDIO_STATUS_RECORD) | 420 | if(audio_status() == AUDIO_STATUS_RECORD) |
@@ -360,51 +461,84 @@ bool radio_screen(void) | |||
360 | break; | 461 | break; |
361 | #endif /* #ifdef FM_RECORD */ | 462 | #endif /* #ifdef FM_RECORD */ |
362 | 463 | ||
464 | #ifdef FM_RC_EXIT | ||
465 | case FM_RC_EXIT: | ||
466 | #endif | ||
363 | case FM_EXIT: | 467 | case FM_EXIT: |
364 | #ifdef FM_EXIT_PRE | 468 | #ifdef FM_EXIT_PRE |
365 | if(lastbutton != FM_EXIT_PRE) | 469 | if(lastbutton != FM_EXIT_PRE |
470 | #ifdef FM_RC_EXIT_PRE | ||
471 | && lastbutton != FM_RC_EXIT_PRE | ||
472 | #endif | ||
473 | ) | ||
366 | break; | 474 | break; |
367 | #endif | 475 | #endif |
368 | #ifndef SIMULATOR | 476 | #ifndef SIMULATOR |
369 | if(audio_status() == AUDIO_STATUS_RECORD) | 477 | if(audio_status() == AUDIO_STATUS_RECORD) |
370 | audio_stop(); | 478 | audio_stop(); |
371 | #endif | 479 | #endif |
372 | done = true; | ||
373 | keep_playing = true; | 480 | keep_playing = true; |
481 | done = true; | ||
374 | break; | 482 | break; |
375 | 483 | ||
484 | #ifdef BUTTON_RC_REW | ||
485 | case BUTTON_RC_REW: | ||
486 | #endif | ||
376 | case BUTTON_LEFT: | 487 | case BUTTON_LEFT: |
377 | curr_freq -= FREQ_STEP; | 488 | if(radio_mode == RADIO_SCAN_MODE) |
378 | if(curr_freq < MIN_FREQ) | 489 | { |
379 | curr_freq = MAX_FREQ; | 490 | curr_freq -= FREQ_STEP; |
380 | 491 | if(curr_freq < MIN_FREQ) | |
381 | radio_set(RADIO_FREQUENCY, curr_freq); | 492 | curr_freq = MAX_FREQ; |
382 | curr_preset = find_preset(curr_freq); | 493 | radio_set(RADIO_FREQUENCY, curr_freq); |
383 | remember_frequency(); | 494 | curr_preset = find_preset(curr_freq); |
495 | remember_frequency(); | ||
496 | } | ||
497 | else | ||
498 | next_preset(-1); | ||
384 | search_dir = 0; | 499 | search_dir = 0; |
385 | update_screen = true; | 500 | update_screen = true; |
386 | break; | 501 | break; |
387 | 502 | ||
503 | #ifdef BUTTON_RC_FF | ||
504 | case BUTTON_RC_FF: | ||
505 | #endif | ||
388 | case BUTTON_RIGHT: | 506 | case BUTTON_RIGHT: |
389 | curr_freq += FREQ_STEP; | 507 | if(radio_mode == RADIO_SCAN_MODE) |
390 | if(curr_freq > MAX_FREQ) | 508 | { |
391 | curr_freq = MIN_FREQ; | 509 | curr_freq += FREQ_STEP; |
392 | 510 | if(curr_freq > MAX_FREQ) | |
393 | radio_set(RADIO_FREQUENCY, curr_freq); | 511 | curr_freq = MIN_FREQ; |
394 | curr_preset = find_preset(curr_freq); | 512 | radio_set(RADIO_FREQUENCY, curr_freq); |
395 | remember_frequency(); | 513 | curr_preset = find_preset(curr_freq); |
514 | remember_frequency(); | ||
515 | } | ||
516 | else | ||
517 | next_preset(1); | ||
396 | search_dir = 0; | 518 | search_dir = 0; |
397 | update_screen = true; | 519 | update_screen = true; |
398 | break; | 520 | break; |
399 | 521 | ||
522 | #ifdef BUTTON_RC_REW | ||
523 | case BUTTON_RC_REW | BUTTON_REPEAT: | ||
524 | #endif | ||
400 | case BUTTON_LEFT | BUTTON_REPEAT: | 525 | case BUTTON_LEFT | BUTTON_REPEAT: |
401 | search_dir = -1; | 526 | if(radio_mode == RADIO_SCAN_MODE) |
527 | search_dir = -1; | ||
402 | break; | 528 | break; |
403 | 529 | ||
530 | #ifdef BUTTON_RC_FF | ||
531 | case BUTTON_RC_FF | BUTTON_REPEAT: | ||
532 | #endif | ||
404 | case BUTTON_RIGHT | BUTTON_REPEAT: | 533 | case BUTTON_RIGHT | BUTTON_REPEAT: |
405 | search_dir = 1; | 534 | if(radio_mode == RADIO_SCAN_MODE) |
535 | search_dir = 1; | ||
406 | break; | 536 | break; |
407 | 537 | ||
538 | #ifdef BUTTON_RC_VOL_UP | ||
539 | case BUTTON_RC_VOL_UP: | ||
540 | case BUTTON_RC_VOL_UP | BUTTON_REPEAT: | ||
541 | #endif | ||
408 | case BUTTON_UP: | 542 | case BUTTON_UP: |
409 | case BUTTON_UP | BUTTON_REPEAT: | 543 | case BUTTON_UP | BUTTON_REPEAT: |
410 | global_settings.volume++; | 544 | global_settings.volume++; |
@@ -415,6 +549,10 @@ bool radio_screen(void) | |||
415 | settings_save(); | 549 | settings_save(); |
416 | break; | 550 | break; |
417 | 551 | ||
552 | #ifdef BUTTON_RC_VOL_DOWN | ||
553 | case BUTTON_RC_VOL_DOWN: | ||
554 | case BUTTON_RC_VOL_DOWN | BUTTON_REPEAT: | ||
555 | #endif | ||
418 | case BUTTON_DOWN: | 556 | case BUTTON_DOWN: |
419 | case BUTTON_DOWN | BUTTON_REPEAT: | 557 | case BUTTON_DOWN | BUTTON_REPEAT: |
420 | global_settings.volume--; | 558 | global_settings.volume--; |
@@ -425,12 +563,46 @@ bool radio_screen(void) | |||
425 | settings_save(); | 563 | settings_save(); |
426 | break; | 564 | break; |
427 | 565 | ||
566 | #ifdef FM_PLAY | ||
567 | #ifdef FM_RC_PLAY | ||
568 | case FM_RC_PLAY: | ||
569 | #endif | ||
570 | case FM_PLAY: | ||
571 | #ifdef FM_PLAY_PRE | ||
572 | if(lastbutton != FM_PLAY_PRE | ||
573 | #ifdef FM_RC_PLAY_PRE | ||
574 | && lastbutton != FM_RC_PLAY_PRE | ||
575 | #endif | ||
576 | ) | ||
577 | break; | ||
578 | #endif | ||
579 | if(radio_get_status() != FMRADIO_PLAYING) | ||
580 | { | ||
581 | radio_set(RADIO_SLEEP, 0); | ||
582 | radio_set(RADIO_FREQUENCY, curr_freq); | ||
583 | radio_set(RADIO_MUTE, 0); | ||
584 | radio_set_status(FMRADIO_PLAYING); | ||
585 | } | ||
586 | else | ||
587 | { | ||
588 | radio_set(RADIO_MUTE, 1); | ||
589 | radio_set(RADIO_SLEEP, 1); | ||
590 | radio_set_status(FMRADIO_POWERED); | ||
591 | } | ||
592 | update_screen = true; | ||
593 | break; | ||
594 | #endif | ||
428 | #ifdef FM_MENU | 595 | #ifdef FM_MENU |
596 | #ifdef FM_RC_MENU | ||
597 | case FM_RC_MENU: | ||
598 | #endif | ||
429 | case FM_MENU: | 599 | case FM_MENU: |
430 | radio_menu(); | 600 | radio_menu(); |
431 | curr_preset = find_preset(curr_freq); | 601 | curr_preset = find_preset(curr_freq); |
432 | lcd_clear_display(); | 602 | FOR_NB_SCREENS(i){ |
433 | lcd_setmargins(0, 8); | 603 | gui_textarea_clear(&screens[i]); |
604 | screen_set_xmargin(&screens[i],0); | ||
605 | } | ||
434 | #if CONFIG_KEYPAD == RECORDER_PAD | 606 | #if CONFIG_KEYPAD == RECORDER_PAD |
435 | buttonbar_set(str(LANG_BUTTONBAR_MENU), | 607 | buttonbar_set(str(LANG_BUTTONBAR_MENU), |
436 | str(LANG_FM_BUTTONBAR_PRESETS), | 608 | str(LANG_FM_BUTTONBAR_PRESETS), |
@@ -439,13 +611,26 @@ bool radio_screen(void) | |||
439 | update_screen = true; | 611 | update_screen = true; |
440 | break; | 612 | break; |
441 | #endif | 613 | #endif |
442 | 614 | ||
615 | #ifdef FM_RC_PRESET | ||
616 | case FM_RC_PRESET: | ||
617 | #endif | ||
443 | #ifdef FM_PRESET | 618 | #ifdef FM_PRESET |
444 | case FM_PRESET: | 619 | case FM_PRESET: |
620 | #ifdef FM_PRESET_PRE | ||
621 | if(lastbutton != FM_PRESET_PRE | ||
622 | #ifdef FM_RC_PRESET_PRE | ||
623 | && lastbutton != FM_RC_PRESET_PRE | ||
624 | #endif | ||
625 | ) | ||
626 | break; | ||
627 | #endif | ||
445 | handle_radio_presets(); | 628 | handle_radio_presets(); |
446 | curr_preset = find_preset(curr_freq); | 629 | curr_preset = find_preset(curr_freq); |
447 | lcd_clear_display(); | 630 | FOR_NB_SCREENS(i){ |
448 | lcd_setmargins(0, 8); | 631 | gui_textarea_clear(&screens[i]); |
632 | screen_set_xmargin(&screens[i],0); | ||
633 | } | ||
449 | #if CONFIG_KEYPAD == RECORDER_PAD | 634 | #if CONFIG_KEYPAD == RECORDER_PAD |
450 | buttonbar_set(str(LANG_BUTTONBAR_MENU), | 635 | buttonbar_set(str(LANG_BUTTONBAR_MENU), |
451 | str(LANG_FM_BUTTONBAR_PRESETS), | 636 | str(LANG_FM_BUTTONBAR_PRESETS), |
@@ -459,8 +644,7 @@ bool radio_screen(void) | |||
459 | case FM_FREEZE: | 644 | case FM_FREEZE: |
460 | if(!screen_freeze) | 645 | if(!screen_freeze) |
461 | { | 646 | { |
462 | splash(0, true, "Screen frozen"); | 647 | gui_syncsplash(HZ, true, str(LANG_FM_FREEZE)); |
463 | lcd_update(); | ||
464 | screen_freeze = true; | 648 | screen_freeze = true; |
465 | } | 649 | } |
466 | else | 650 | else |
@@ -480,6 +664,40 @@ bool radio_screen(void) | |||
480 | done = true; | 664 | done = true; |
481 | } | 665 | } |
482 | break; | 666 | break; |
667 | |||
668 | #ifdef FM_RC_MODE | ||
669 | case FM_RC_MODE: | ||
670 | #endif | ||
671 | #ifdef FM_MODE | ||
672 | case FM_MODE: | ||
673 | if(lastbutton != FM_MODE | ||
674 | #ifdef FM_RC_MODE | ||
675 | && lastbutton != FM_RC_MODE | ||
676 | #endif | ||
677 | ) | ||
678 | { | ||
679 | if(radio_mode == RADIO_SCAN_MODE) | ||
680 | radio_mode = RADIO_PRESET_MODE; | ||
681 | else | ||
682 | radio_mode = RADIO_SCAN_MODE; | ||
683 | update_screen = true; | ||
684 | } | ||
685 | break; | ||
686 | #endif | ||
687 | #ifdef FM_NEXT_PRESET | ||
688 | case FM_NEXT_PRESET: | ||
689 | next_preset(1); | ||
690 | search_dir = 0; | ||
691 | update_screen = true; | ||
692 | break; | ||
693 | #endif | ||
694 | #ifdef FM_PREV_PRESET | ||
695 | case FM_PREV_PRESET: | ||
696 | next_preset(-1); | ||
697 | search_dir = 0; | ||
698 | update_screen = true; | ||
699 | break; | ||
700 | #endif | ||
483 | 701 | ||
484 | default: | 702 | default: |
485 | default_event_handler(button); | 703 | default_event_handler(button); |
@@ -492,14 +710,13 @@ bool radio_screen(void) | |||
492 | peak_meter_peek(); | 710 | peak_meter_peek(); |
493 | 711 | ||
494 | if(!screen_freeze) | 712 | if(!screen_freeze) |
495 | { | 713 | { |
496 | lcd_setmargins(0, 8); | ||
497 | |||
498 | /* Only display the peak meter when not recording */ | 714 | /* Only display the peak meter when not recording */ |
499 | if(!audio_status()) | 715 | if(!audio_status()) |
500 | { | 716 | { |
501 | peak_meter_draw(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); | 717 | /* just main screen for the time being */ |
502 | lcd_update_rect(0, 8 + fh*(top_of_screen + 3), LCD_WIDTH, fh); | 718 | peak_meter_draw(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4), LCD_WIDTH, fh); |
719 | screens[SCREEN_MAIN].update_rect(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4), screens[SCREEN_MAIN].width, fh); | ||
503 | } | 720 | } |
504 | 721 | ||
505 | if(TIME_AFTER(current_tick, timeout)) | 722 | if(TIME_AFTER(current_tick, timeout)) |
@@ -524,28 +741,36 @@ bool radio_screen(void) | |||
524 | { | 741 | { |
525 | last_seconds = seconds; | 742 | last_seconds = seconds; |
526 | 743 | ||
527 | lcd_setfont(FONT_UI); | 744 | FOR_NB_SCREENS(i) |
745 | screens[i].setfont(FONT_UI); | ||
528 | 746 | ||
529 | if(curr_preset >= 0) | 747 | if (curr_preset >= 0 ) |
530 | { | 748 | snprintf(buf, 128, "%d. %s",curr_preset + 1, |
531 | lcd_puts_scroll(0, top_of_screen, | 749 | presets[curr_preset].name); |
532 | presets[curr_preset].name); | ||
533 | } | ||
534 | else | 750 | else |
535 | { | 751 | snprintf(buf, 128, " "); |
536 | lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 752 | FOR_NB_SCREENS(i) |
537 | lcd_fillrect(0, 8 + top_of_screen*fh, LCD_WIDTH, fh); | 753 | screens[i].puts_scroll(0, top_of_screen, buf); |
538 | lcd_set_drawmode(DRMODE_SOLID); | ||
539 | } | ||
540 | 754 | ||
541 | freq = curr_freq / 100000; | 755 | freq = curr_freq / 100000; |
542 | snprintf(buf, 128, str(LANG_FM_STATION), freq / 10, freq % 10); | 756 | snprintf(buf, 128, str(LANG_FM_STATION), freq / 10, freq % 10); |
543 | lcd_puts(0, top_of_screen + 1, buf); | 757 | FOR_NB_SCREENS(i) |
758 | screens[i].puts_scroll(0, top_of_screen + 1, buf); | ||
544 | 759 | ||
545 | snprintf(buf, 128, | 760 | strcat(buf, stereo?str(LANG_CHANNEL_STEREO): |
546 | stereo?str(LANG_CHANNEL_STEREO): | 761 | str(LANG_CHANNEL_MONO)); |
547 | str(LANG_CHANNEL_MONO)); | 762 | |
548 | lcd_puts(0, top_of_screen + 2, buf); | 763 | snprintf(buf, 128, stereo?str(LANG_CHANNEL_STEREO): |
764 | str(LANG_CHANNEL_MONO)); | ||
765 | FOR_NB_SCREENS(i) | ||
766 | screens[i].puts_scroll(0, top_of_screen + 2, buf); | ||
767 | |||
768 | #ifdef FM_MODE | ||
769 | snprintf(buf, 128, radio_mode?str(LANG_RADIO_PRESET_MODE): | ||
770 | str(LANG_RADIO_SCAN_MODE)); | ||
771 | FOR_NB_SCREENS(i) | ||
772 | screens[i].puts_scroll(0, top_of_screen + 3, buf); | ||
773 | #endif | ||
549 | 774 | ||
550 | if(audio_status() == AUDIO_STATUS_RECORD) | 775 | if(audio_status() == AUDIO_STATUS_RECORD) |
551 | { | 776 | { |
@@ -554,7 +779,8 @@ bool radio_screen(void) | |||
554 | snprintf(buf, 32, "%s %02d:%02d:%02d", | 779 | snprintf(buf, 32, "%s %02d:%02d:%02d", |
555 | str(LANG_RECORDING_TIME), | 780 | str(LANG_RECORDING_TIME), |
556 | hours, minutes, seconds%60); | 781 | hours, minutes, seconds%60); |
557 | lcd_puts(0, top_of_screen + 3, buf); | 782 | FOR_NB_SCREENS(i) |
783 | screens[i].puts_scroll(0, top_of_screen + 4, buf); | ||
558 | } | 784 | } |
559 | else | 785 | else |
560 | { | 786 | { |
@@ -562,17 +788,19 @@ bool radio_screen(void) | |||
562 | { | 788 | { |
563 | snprintf(buf, 32, "%s %02d", | 789 | snprintf(buf, 32, "%s %02d", |
564 | str(LANG_RECORD_PRERECORD), seconds%60); | 790 | str(LANG_RECORD_PRERECORD), seconds%60); |
565 | lcd_puts(0, top_of_screen + 3, buf); | 791 | FOR_NB_SCREENS(i) |
792 | screens[i].puts_scroll(0, top_of_screen + 4, buf); | ||
566 | } | 793 | } |
567 | } | 794 | } |
568 | 795 | ||
569 | #if CONFIG_KEYPAD == RECORDER_PAD | 796 | #if CONFIG_KEYPAD == RECORDER_PAD |
570 | buttonbar_draw(); | 797 | buttonbar_draw(); |
571 | #endif | 798 | #endif |
572 | lcd_update(); | 799 | FOR_NB_SCREENS(i) |
800 | gui_textarea_update(&screens[i]); | ||
573 | } | 801 | } |
574 | /* Only force the redraw if update_screen is true */ | 802 | /* Only force the redraw if update_screen is true */ |
575 | status_draw(update_screen); | 803 | gui_syncstatusbar_draw(&statusbars,true); |
576 | 804 | ||
577 | update_screen = false; | 805 | update_screen = false; |
578 | } | 806 | } |
@@ -587,8 +815,9 @@ bool radio_screen(void) | |||
587 | if(audio_status() & AUDIO_STATUS_ERROR) | 815 | if(audio_status() & AUDIO_STATUS_ERROR) |
588 | { | 816 | { |
589 | splash(0, true, str(LANG_DISK_FULL)); | 817 | splash(0, true, str(LANG_DISK_FULL)); |
590 | status_draw(true); | 818 | gui_syncstatusbar_draw(&statusbars,true); |
591 | lcd_update(); | 819 | FOR_NB_SCREENS(i) |
820 | gui_textarea_update(&screens[i]); | ||
592 | audio_error_clear(); | 821 | audio_error_clear(); |
593 | 822 | ||
594 | while(1) | 823 | while(1) |
@@ -626,6 +855,9 @@ bool radio_screen(void) | |||
626 | #endif | 855 | #endif |
627 | 856 | ||
628 | cpu_idle_mode(false); | 857 | cpu_idle_mode(false); |
858 | |||
859 | /* restore status bar settings */ | ||
860 | global_settings.statusbar = statusbar; | ||
629 | 861 | ||
630 | return have_recorded; | 862 | return have_recorded; |
631 | } | 863 | } |
@@ -816,13 +1048,15 @@ int handle_radio_presets_cb(int key, int m) | |||
816 | menu_draw(m); | 1048 | menu_draw(m); |
817 | key = BUTTON_NONE; | 1049 | key = BUTTON_NONE; |
818 | break; | 1050 | break; |
819 | #endif | 1051 | #endif |
1052 | #if CONFIG_KEYPAD != IRIVER_H100_PAD | ||
820 | #ifdef FM_PRESET | 1053 | #ifdef FM_PRESET |
821 | case FM_PRESET: | 1054 | case FM_PRESET: |
822 | menu_draw(m); | 1055 | menu_draw(m); |
823 | key = MENU_EXIT; /* Fake an exit */ | 1056 | key = MENU_EXIT; /* Fake an exit */ |
824 | break; | 1057 | break; |
825 | #endif | 1058 | #endif |
1059 | #endif | ||
826 | #ifdef FM_PRESET_ACTION | 1060 | #ifdef FM_PRESET_ACTION |
827 | case FM_PRESET_ACTION: | 1061 | case FM_PRESET_ACTION: |
828 | #endif | 1062 | #endif |
@@ -950,16 +1184,20 @@ int radio_menu_cb(int key, int m) | |||
950 | (void)m; | 1184 | (void)m; |
951 | switch(key) | 1185 | switch(key) |
952 | { | 1186 | { |
1187 | #if CONFIG_KEYPAD != IRIVER_H100_PAD | ||
953 | #ifdef MENU_ENTER2 | 1188 | #ifdef MENU_ENTER2 |
954 | case MENU_ENTER2: | 1189 | case MENU_ENTER2: |
955 | #endif | 1190 | #endif |
1191 | #endif | ||
956 | case MENU_ENTER: | 1192 | case MENU_ENTER: |
957 | key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */ | 1193 | key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */ |
958 | break; | 1194 | break; |
959 | 1195 | ||
1196 | #if CONFIG_KEYPAD != IRIVER_H100_PAD | ||
960 | #ifdef MENU_ENTER2 | 1197 | #ifdef MENU_ENTER2 |
961 | case MENU_ENTER2 | BUTTON_REL: | 1198 | case MENU_ENTER2 | BUTTON_REL: |
962 | #endif | 1199 | #endif |
1200 | #endif | ||
963 | case MENU_ENTER | BUTTON_REL: | 1201 | case MENU_ENTER | BUTTON_REL: |
964 | key = MENU_ENTER; /* fake downpress, next menu doesn't like release */ | 1202 | key = MENU_ENTER; /* fake downpress, next menu doesn't like release */ |
965 | break; | 1203 | break; |