From cf986e8d440015ca4d242e8e748576f779255d4a Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 4 Apr 2005 20:16:01 +0000 Subject: 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 --- apps/recorder/peakmeter.c | 28 +++++++++------------- apps/recorder/recording.c | 4 ++-- apps/settings.c | 2 ++ apps/sound_menu.c | 61 +++++++++++++++++++++++++++-------------------- 4 files changed, 50 insertions(+), 45 deletions(-) (limited to 'apps') diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index 0481e25acd..8bb771e9b3 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c @@ -68,6 +68,7 @@ static unsigned short db_min = 0; static unsigned short db_max = 9000; static unsigned short db_range = 9000; +#ifdef HAVE_RECORDING static unsigned short trig_strt_threshold; static long trig_strt_duration; static long trig_strt_dropout; @@ -81,10 +82,11 @@ static long trig_hightime; /* point in time when the volume fell below the threshold*/ static long trig_lowtime; -/* The output value of the trigger. See TRIG_XXX constants vor valid values */ +/* The output value of the trigger. See TRIG_XXX constants for valid values */ static int trig_status = TRIG_OFF; static void (*trigger_listener)(int) = NULL; +#endif #if CONFIG_HWCODEC == MASNONE #define MAS_REG_DQPEAK_L 0 @@ -176,21 +178,6 @@ static const int db_scale_src_values[DB_SCALE_SRC_VALUES_SIZE] = { }; #endif -const char* peak_meter_dbnames[DB_SCALE_SRC_VALUES_SIZE] = { - "0 db", - "-3 db", - "-6 db", - "-9 db", - "-12 db", - "-18 db", - "-24 db", - "-30 db", - "-40 db", - "-50 db", - "-60 db", - "-inf", -}; - static int db_scale_count = DB_SCALE_SRC_VALUES_SIZE; /* if db_scale_valid is false the content of @@ -540,6 +527,7 @@ void peak_meter_playback(bool playback) #endif } +#ifdef HAVE_RECORDING static void set_trig_status(int new_state) { if (trig_status != new_state) { trig_status = new_state; @@ -548,6 +536,7 @@ static void set_trig_status(int new_state) { } } } +#endif /** * Reads peak values from the MAS, and detects clips. The @@ -591,6 +580,7 @@ inline void peak_meter_peek(void) current_tick + clip_time_out[peak_meter_clip_hold]; } +#ifdef HAVE_RECORDING switch (trig_status) { case TRIG_READY: /* no more changes, if trigger was activated as release trigger */ @@ -705,6 +695,7 @@ inline void peak_meter_peek(void) } break; } +#endif /* peaks are searched -> we have to find the maximum. When many calls of peak_meter_peek the maximum value will be @@ -971,6 +962,7 @@ void peak_meter_draw(int x, int y, int width, int height) { lcd_invertpixel(db_scale_lcd_coord[i], y + height / 2 - 1); } +#ifdef HAVE_RECORDING if (trig_status != TRIG_OFF) { int start_trigx, stop_trigx, ycenter; @@ -984,8 +976,8 @@ void peak_meter_draw(int x, int y, int width, int height) { stop_trigx = x + peak_meter_scale_value(trig_stp_threshold,meterwidth); lcd_drawline(stop_trigx, ycenter - 2, stop_trigx, ycenter); if (stop_trigx > 0) lcd_drawpixel(stop_trigx - 1, ycenter - 1); - } +#endif #ifdef PM_DEBUG /* display a bar to show how many calls to peak_meter_peek @@ -1011,6 +1003,7 @@ void peak_meter_draw(int x, int y, int width, int height) { last_right = right; } +#ifdef HAVE_RECORDING /** * Defines the parameters of the trigger. After these parameters are defined * the trigger can be started either by peak_meter_attack_trigger or by @@ -1142,6 +1135,7 @@ void peak_meter_draw_trig(int xpos, int ypos) { } } +#endif int peak_meter_draw_get_btn(int x, int y, int width, int height) { diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 9ef6d4a521..68859632fa 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -318,7 +318,7 @@ bool recording_screen(void) }; cursor = 0; -#ifndef SIMULATOR +#if defined(HAVE_LED) && !defined(SIMULATOR) ata_set_led_enabled(false); #endif mpeg_init_recording(); @@ -859,7 +859,7 @@ bool recording_screen(void) if (have_recorded) reload_directory(); -#ifndef SIMULATOR +#if defined(HAVE_LED) && !defined(SIMULATOR) ata_set_led_enabled(true); #endif return been_in_usb_mode; diff --git a/apps/settings.c b/apps/settings.c index 39bb9b4d26..56dcd0af09 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -154,10 +154,12 @@ static const char off_on_ask[] = "off,on,ask"; static const char graphic_numeric[] = "graphic,numeric"; static const char off_number_spell_hover[] = "off,number,spell,hover"; +#ifdef HAVE_RECORDING /* keep synchronous to trig_durations and trigger_times in settings_apply_trigger */ static const char trig_durations_conf [] = "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min"; +#endif /* the part of the settings which ends up in the RTC RAM, where available (those we either need early, save frequently, or without spinup) */ 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) } return retval; } -#endif -#if !defined(SIMULATOR) && CONFIG_HWCODEC == MAS3587F #define INF_DB (-89) static void change_threshold(int *threshold, int change) { @@ -499,6 +497,17 @@ static void change_threshold(int *threshold, int change) } } +/* Variable button definitions */ +#if CONFIG_KEYPAD == RECORDER_PAD +#define TRIG_CANCEL BUTTON_OFF +#define TRIG_ACCEPT BUTTON_PLAY +#define TRIG_RESET_SIM BUTTON_F2 + +#elif CONFIG_KEYPAD == ONDIO_PAD +#define TRIG_CANCEL BUTTON_OFF +#define TRIG_ACCEPT BUTTON_MENU +#endif + /** * Displays a menu for editing the trigger settings. */ @@ -510,22 +519,29 @@ bool rectrigger(void) int old_x_margin, old_y_margin; #define TRIGGER_MODE_COUNT 3 - char *trigger_modes[] = - { - str(LANG_OFF), - str(LANG_RECORD_TRIG_NOREARM), - str(LANG_RECORD_TRIG_REARM) + static const unsigned char *trigger_modes[] = { + ID2P(LANG_OFF), + ID2P(LANG_RECORD_TRIG_NOREARM), + ID2P(LANG_RECORD_TRIG_REARM) }; #define PRERECORD_TIMES_COUNT 31 - char *prerecord_times[] = { - str(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", + static const unsigned char *prerecord_times[] = { + ID2P(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", "10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s", "20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s", "30s" }; - char *option_name[TRIG_OPTION_COUNT]; + static const unsigned char *option_name[] = { + [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER_MODE), + [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME), + [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD), + [START_DURATION] = ID2P(LANG_RECORD_MIN_DURATION), + [STOP_THRESHOLD] = ID2P(LANG_RECORD_STOP_THRESHOLD), + [STOP_POSTREC] = ID2P(LANG_RECORD_STOP_POSTREC), + [STOP_GAP] = ID2P(LANG_RECORD_STOP_GAP) + }; int old_start_thres = global_settings.rec_start_thres; int old_start_duration = global_settings.rec_start_duration; @@ -539,15 +555,6 @@ bool rectrigger(void) int option_lines; int w, h; - option_name[TRIGGER_MODE] = str(LANG_RECORD_TRIGGER_MODE); - option_name[PRERECORD_TIME] = str(LANG_RECORD_PRERECORD_TIME); - option_name[START_THRESHOLD] = str(LANG_RECORD_START_THRESHOLD); - option_name[START_DURATION] = str(LANG_RECORD_MIN_DURATION); - option_name[STOP_THRESHOLD] = str(LANG_RECORD_STOP_THRESHOLD); - option_name[STOP_POSTREC] = str(LANG_RECORD_STOP_POSTREC); - option_name[STOP_GAP] = str(LANG_RECORD_STOP_GAP); - - /* restart trigger with new values */ settings_apply_trigger(); peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); @@ -569,20 +576,20 @@ bool rectrigger(void) while (!exit_request) { int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; int button, i; - char *str; + const char *str; char option_value[TRIG_OPTION_COUNT][7]; snprintf( option_value[TRIGGER_MODE], sizeof option_value[TRIGGER_MODE], "%s", - trigger_modes[global_settings.rec_trigger_mode]); + P2STR(trigger_modes[global_settings.rec_trigger_mode])); snprintf ( option_value[PRERECORD_TIME], sizeof option_value[PRERECORD_TIME], "%s", - prerecord_times[global_settings.rec_prerecord_time]); + P2STR(prerecord_times[global_settings.rec_prerecord_time])); /* due to value range shift (peak_meter_define_trigger) -1 is 0db */ if (global_settings.rec_start_thres == -1) { @@ -635,7 +642,7 @@ bool rectrigger(void) for (i = 0; i < option_lines; i++) { int x, y; - str = option_name[i + offset]; + str = P2STR(option_name[i + offset]); lcd_putsxy(5, stat_height + i * h, str); str = option_value[i + offset]; @@ -659,7 +666,7 @@ bool rectrigger(void) lcd_update(); switch (button) { - case BUTTON_OFF: + case TRIG_CANCEL: splash(50, true, str(LANG_RESET_DONE_CANCEL)); global_settings.rec_start_thres = old_start_thres; global_settings.rec_start_duration = old_start_duration; @@ -671,7 +678,7 @@ bool rectrigger(void) exit_request = true; break; - case BUTTON_PLAY: + case TRIG_ACCEPT: exit_request = true; break; @@ -785,9 +792,11 @@ bool rectrigger(void) } break; - case BUTTON_F2: +#ifdef TRIG_RESET_SIM + case TRIG_RESET_SIM: peak_meter_trigger(true); break; +#endif case SYS_USB_CONNECTED: if(default_event_handler(button) == SYS_USB_CONNECTED) { -- cgit v1.2.3