summaryrefslogtreecommitdiff
path: root/apps/sound_menu.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-04-04 20:16:01 +0000
committerJens Arnold <amiconn@rockbox.org>2005-04-04 20:16:01 +0000
commitcf986e8d440015ca4d242e8e748576f779255d4a (patch)
treee26045b8adbd3d7dac09efa3073f04944b40f48a /apps/sound_menu.c
parente1f70587ce13100e8b1703c55fa497e55ee7a3d3 (diff)
downloadrockbox-cf986e8d440015ca4d242e8e748576f779255d4a.tar.gz
rockbox-cf986e8d440015ca4d242e8e748576f779255d4a.zip
Triggered recording fixes: (1) Made it compile for Ondio FM recorder (no led, button assigment). (2) Disabled trigger settings and peakmeter trigger handling for devices without recording. Saves > 2 KB of code on Ondio SP. (3) Const policed, saves some more code size. (4) Some code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6248 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/sound_menu.c')
-rw-r--r--apps/sound_menu.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index 48cee349bd..fe3b9202b2 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -469,9 +469,7 @@ static char* create_thres_str(int threshold)
469 } 469 }
470 return retval; 470 return retval;
471} 471}
472#endif
473 472
474#if !defined(SIMULATOR) && CONFIG_HWCODEC == MAS3587F
475#define INF_DB (-89) 473#define INF_DB (-89)
476static void change_threshold(int *threshold, int change) 474static void change_threshold(int *threshold, int change)
477{ 475{
@@ -499,6 +497,17 @@ static void change_threshold(int *threshold, int change)
499 } 497 }
500} 498}
501 499
500/* Variable button definitions */
501#if CONFIG_KEYPAD == RECORDER_PAD
502#define TRIG_CANCEL BUTTON_OFF
503#define TRIG_ACCEPT BUTTON_PLAY
504#define TRIG_RESET_SIM BUTTON_F2
505
506#elif CONFIG_KEYPAD == ONDIO_PAD
507#define TRIG_CANCEL BUTTON_OFF
508#define TRIG_ACCEPT BUTTON_MENU
509#endif
510
502/** 511/**
503 * Displays a menu for editing the trigger settings. 512 * Displays a menu for editing the trigger settings.
504 */ 513 */
@@ -510,22 +519,29 @@ bool rectrigger(void)
510 int old_x_margin, old_y_margin; 519 int old_x_margin, old_y_margin;
511 520
512#define TRIGGER_MODE_COUNT 3 521#define TRIGGER_MODE_COUNT 3
513 char *trigger_modes[] = 522 static const unsigned char *trigger_modes[] = {
514 { 523 ID2P(LANG_OFF),
515 str(LANG_OFF), 524 ID2P(LANG_RECORD_TRIG_NOREARM),
516 str(LANG_RECORD_TRIG_NOREARM), 525 ID2P(LANG_RECORD_TRIG_REARM)
517 str(LANG_RECORD_TRIG_REARM)
518 }; 526 };
519 527
520#define PRERECORD_TIMES_COUNT 31 528#define PRERECORD_TIMES_COUNT 31
521 char *prerecord_times[] = { 529 static const unsigned char *prerecord_times[] = {
522 str(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", 530 ID2P(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s",
523 "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s", 531 "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s",
524 "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s", 532 "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s",
525 "30s" 533 "30s"
526 }; 534 };
527 535
528 char *option_name[TRIG_OPTION_COUNT]; 536 static const unsigned char *option_name[] = {
537 [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER_MODE),
538 [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME),
539 [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD),
540 [START_DURATION] = ID2P(LANG_RECORD_MIN_DURATION),
541 [STOP_THRESHOLD] = ID2P(LANG_RECORD_STOP_THRESHOLD),
542 [STOP_POSTREC] = ID2P(LANG_RECORD_STOP_POSTREC),
543 [STOP_GAP] = ID2P(LANG_RECORD_STOP_GAP)
544 };
529 545
530 int old_start_thres = global_settings.rec_start_thres; 546 int old_start_thres = global_settings.rec_start_thres;
531 int old_start_duration = global_settings.rec_start_duration; 547 int old_start_duration = global_settings.rec_start_duration;
@@ -539,15 +555,6 @@ bool rectrigger(void)
539 int option_lines; 555 int option_lines;
540 int w, h; 556 int w, h;
541 557
542 option_name[TRIGGER_MODE] = str(LANG_RECORD_TRIGGER_MODE);
543 option_name[PRERECORD_TIME] = str(LANG_RECORD_PRERECORD_TIME);
544 option_name[START_THRESHOLD] = str(LANG_RECORD_START_THRESHOLD);
545 option_name[START_DURATION] = str(LANG_RECORD_MIN_DURATION);
546 option_name[STOP_THRESHOLD] = str(LANG_RECORD_STOP_THRESHOLD);
547 option_name[STOP_POSTREC] = str(LANG_RECORD_STOP_POSTREC);
548 option_name[STOP_GAP] = str(LANG_RECORD_STOP_GAP);
549
550
551 /* restart trigger with new values */ 558 /* restart trigger with new values */
552 settings_apply_trigger(); 559 settings_apply_trigger();
553 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); 560 peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF);
@@ -569,20 +576,20 @@ bool rectrigger(void)
569 while (!exit_request) { 576 while (!exit_request) {
570 int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; 577 int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
571 int button, i; 578 int button, i;
572 char *str; 579 const char *str;
573 char option_value[TRIG_OPTION_COUNT][7]; 580 char option_value[TRIG_OPTION_COUNT][7];
574 581
575 snprintf( 582 snprintf(
576 option_value[TRIGGER_MODE], 583 option_value[TRIGGER_MODE],
577 sizeof option_value[TRIGGER_MODE], 584 sizeof option_value[TRIGGER_MODE],
578 "%s", 585 "%s",
579 trigger_modes[global_settings.rec_trigger_mode]); 586 P2STR(trigger_modes[global_settings.rec_trigger_mode]));
580 587
581 snprintf ( 588 snprintf (
582 option_value[PRERECORD_TIME], 589 option_value[PRERECORD_TIME],
583 sizeof option_value[PRERECORD_TIME], 590 sizeof option_value[PRERECORD_TIME],
584 "%s", 591 "%s",
585 prerecord_times[global_settings.rec_prerecord_time]); 592 P2STR(prerecord_times[global_settings.rec_prerecord_time]));
586 593
587 /* due to value range shift (peak_meter_define_trigger) -1 is 0db */ 594 /* due to value range shift (peak_meter_define_trigger) -1 is 0db */
588 if (global_settings.rec_start_thres == -1) { 595 if (global_settings.rec_start_thres == -1) {
@@ -635,7 +642,7 @@ bool rectrigger(void)
635 for (i = 0; i < option_lines; i++) { 642 for (i = 0; i < option_lines; i++) {
636 int x, y; 643 int x, y;
637 644
638 str = option_name[i + offset]; 645 str = P2STR(option_name[i + offset]);
639 lcd_putsxy(5, stat_height + i * h, str); 646 lcd_putsxy(5, stat_height + i * h, str);
640 647
641 str = option_value[i + offset]; 648 str = option_value[i + offset];
@@ -659,7 +666,7 @@ bool rectrigger(void)
659 lcd_update(); 666 lcd_update();
660 667
661 switch (button) { 668 switch (button) {
662 case BUTTON_OFF: 669 case TRIG_CANCEL:
663 splash(50, true, str(LANG_RESET_DONE_CANCEL)); 670 splash(50, true, str(LANG_RESET_DONE_CANCEL));
664 global_settings.rec_start_thres = old_start_thres; 671 global_settings.rec_start_thres = old_start_thres;
665 global_settings.rec_start_duration = old_start_duration; 672 global_settings.rec_start_duration = old_start_duration;
@@ -671,7 +678,7 @@ bool rectrigger(void)
671 exit_request = true; 678 exit_request = true;
672 break; 679 break;
673 680
674 case BUTTON_PLAY: 681 case TRIG_ACCEPT:
675 exit_request = true; 682 exit_request = true;
676 break; 683 break;
677 684
@@ -785,9 +792,11 @@ bool rectrigger(void)
785 } 792 }
786 break; 793 break;
787 794
788 case BUTTON_F2: 795#ifdef TRIG_RESET_SIM
796 case TRIG_RESET_SIM:
789 peak_meter_trigger(true); 797 peak_meter_trigger(true);
790 break; 798 break;
799#endif
791 800
792 case SYS_USB_CONNECTED: 801 case SYS_USB_CONNECTED:
793 if(default_event_handler(button) == SYS_USB_CONNECTED) { 802 if(default_event_handler(button) == SYS_USB_CONNECTED) {