Voice the recording trigger settings screen.

From FS#6325, with a slight coding improvement.
Also take out a duplicated snprintf in there.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15059 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Stéphane Doyon 2007-10-10 01:41:48 +00:00
parent 6799ac8051
commit 0279c71a92
4 changed files with 93 additions and 35 deletions

View file

@ -6310,7 +6310,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "Once"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -6326,7 +6326,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "Trigtype" recording: "Trigger type"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -6375,7 +6375,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "Start Above"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -6392,7 +6392,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "for at least"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -6409,7 +6409,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "Stop Below"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -6426,7 +6426,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "Presplit Gap"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>
@ -8354,7 +8354,7 @@
</dest> </dest>
<voice> <voice>
*: none *: none
recording: "" recording: "minus infinity"
</voice> </voice>
</phrase> </phrase>
<phrase> <phrase>

View file

@ -381,17 +381,23 @@ enum trigger_menu_option
TRIG_OPTION_COUNT, TRIG_OPTION_COUNT,
}; };
static char* create_thres_str(int threshold) static char* create_thres_str(int threshold, long *voice_id)
{ {
static char retval[6]; static char retval[6];
if (threshold < 0) { if (threshold < 0) {
if (threshold < -88) { if (threshold < -88) {
snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF)); snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF));
if(voice_id)
*voice_id = LANG_DB_INF;
} else { } else {
snprintf (retval, sizeof retval, "%ddb", threshold + 1); snprintf (retval, sizeof retval, "%ddb", threshold + 1);
if(voice_id)
*voice_id = TALK_ID(threshold + 1, UNIT_DB);
} }
} else { } else {
snprintf (retval, sizeof retval, "%d%%", threshold); snprintf (retval, sizeof retval, "%d%%", threshold);
if(voice_id)
*voice_id = TALK_ID(threshold, UNIT_PERCENT);
} }
return retval; return retval;
} }
@ -442,11 +448,13 @@ bool rectrigger(void)
}; };
#define PRERECORD_TIMES_COUNT 31 #define PRERECORD_TIMES_COUNT 31
static const unsigned char *prerecord_times[] = { static const struct opt_items prerecord_times[] = {
ID2P(LANG_OFF),"1s","2s", "3s", "4s", "5s", "6s", "7s", "8s", "9s", { STR(LANG_OFF) },
"10s", "11s", "12s", "13s", "14s", "15s", "16s", "17s", "18s", "19s", #define T(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
"20s", "21s", "22s", "23s", "24s", "25s", "26s", "27s", "28s", "29s", T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(9), T(10),
"30s" T(11), T(12), T(13), T(14), T(15), T(16), T(17), T(18), T(19), T(20),
T(21), T(22), T(23), T(24), T(25), T(26), T(27), T(28), T(29), T(30),
#undef T
}; };
#define TRIGGER_TYPE_COUNT 3 #define TRIGGER_TYPE_COUNT 3
@ -486,6 +494,8 @@ bool rectrigger(void)
int trig_ypos[NB_SCREENS]; int trig_ypos[NB_SCREENS];
int trig_width[NB_SCREENS]; int trig_width[NB_SCREENS];
bool say_field = true, say_value = true;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
offset[i] = 0; offset[i] = 0;
@ -535,23 +545,17 @@ bool rectrigger(void)
"%s", "%s",
P2STR(trigger_types[global_settings.rec_trigger_type])); P2STR(trigger_types[global_settings.rec_trigger_type]));
snprintf(
option_value[TRIGGER_TYPE],
sizeof option_value[TRIGGER_TYPE],
"%s",
P2STR(trigger_types[global_settings.rec_trigger_type]));
snprintf ( snprintf (
option_value[PRERECORD_TIME], option_value[PRERECORD_TIME],
sizeof option_value[PRERECORD_TIME], sizeof option_value[PRERECORD_TIME],
"%s", "%s",
P2STR(prerecord_times[global_settings.rec_prerecord_time])); prerecord_times[global_settings.rec_prerecord_time].string);
/* due to value range shift (peak_meter_define_trigger) -1 is 0db */ /* due to value range shift (peak_meter_define_trigger) -1 is 0db */
if (global_settings.rec_start_thres == -1) { if (global_settings.rec_start_thres == -1) {
str = str(LANG_OFF); str = str(LANG_OFF);
} else { } else {
str = create_thres_str(global_settings.rec_start_thres); str = create_thres_str(global_settings.rec_start_thres, NULL);
} }
snprintf( snprintf(
option_value[START_THRESHOLD], option_value[START_THRESHOLD],
@ -563,13 +567,12 @@ bool rectrigger(void)
option_value[START_DURATION], option_value[START_DURATION],
sizeof option_value[START_DURATION], sizeof option_value[START_DURATION],
"%s", "%s",
trig_durations[global_settings.rec_start_duration]); trig_durations[global_settings.rec_start_duration].string);
if (global_settings.rec_stop_thres <= INF_DB) { if (global_settings.rec_stop_thres <= INF_DB) {
str = str(LANG_OFF); str = str(LANG_OFF);
} else { } else {
str = create_thres_str(global_settings.rec_stop_thres); str = create_thres_str(global_settings.rec_stop_thres, NULL);
} }
snprintf( snprintf(
option_value[STOP_THRESHOLD], option_value[STOP_THRESHOLD],
@ -581,13 +584,13 @@ bool rectrigger(void)
option_value[STOP_POSTREC], option_value[STOP_POSTREC],
sizeof option_value[STOP_POSTREC], sizeof option_value[STOP_POSTREC],
"%s", "%s",
trig_durations[global_settings.rec_stop_postrec]); trig_durations[global_settings.rec_stop_postrec].string);
snprintf( snprintf(
option_value[STOP_GAP], option_value[STOP_GAP],
sizeof option_value[STOP_GAP], sizeof option_value[STOP_GAP],
"%s", "%s",
trig_durations[global_settings.rec_stop_gap]); trig_durations[global_settings.rec_stop_gap].string);
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
{ {
@ -629,6 +632,52 @@ bool rectrigger(void)
VERTICAL); VERTICAL);
} }
bool enqueue = false;
if(say_field) {
talk_id(P2ID(option_name[selected]), enqueue);
enqueue = true;
}
if(say_value) {
long id;
switch(selected) {
case TRIGGER_MODE:
id = P2ID(trigger_modes[global_settings.rec_trigger_mode]);
break;
case TRIGGER_TYPE:
id = P2ID(trigger_types[global_settings.rec_trigger_type]);
break;
case PRERECORD_TIME:
id = prerecord_times[global_settings.rec_prerecord_time]
.voice_id;
break;
case START_THRESHOLD:
if (global_settings.rec_start_thres == -1)
id = LANG_OFF;
else create_thres_str(global_settings.rec_start_thres, &id);
break;
case START_DURATION:
id = trig_durations[global_settings.rec_start_duration]
.voice_id;
break;
case STOP_THRESHOLD:
if (global_settings.rec_stop_thres <= INF_DB)
id = LANG_OFF;
else create_thres_str(global_settings.rec_stop_thres, &id);
break;
case STOP_POSTREC:
id = trig_durations[global_settings.rec_stop_postrec].voice_id;
break;
case STOP_GAP:
id = trig_durations[global_settings.rec_stop_gap].voice_id;
break;
case TRIG_OPTION_COUNT:
// avoid compiler warnings
break;
};
talk_id(id, enqueue);
}
say_field = say_value = false;
peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS); peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS);
button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS); button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS);
@ -661,6 +710,7 @@ bool rectrigger(void)
offset[i] = MIN(offset[i], (int)selected); offset[i] = MIN(offset[i], (int)selected);
offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1);
} }
say_field = say_value = true;
break; break;
case ACTION_STD_NEXT: case ACTION_STD_NEXT:
@ -671,6 +721,7 @@ bool rectrigger(void)
offset[i] = MIN(offset[i], (int)selected); offset[i] = MIN(offset[i], (int)selected);
offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1);
} }
say_field = say_value = true;
break; break;
case ACTION_SETTINGS_INC: case ACTION_SETTINGS_INC:
@ -719,6 +770,7 @@ bool rectrigger(void)
} }
peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
settings_apply_trigger(); settings_apply_trigger();
say_value = true;
break; break;
case ACTION_SETTINGS_DEC: case ACTION_SETTINGS_DEC:
@ -770,6 +822,7 @@ bool rectrigger(void)
} }
peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF);
settings_apply_trigger(); settings_apply_trigger();
say_value = true;
break; break;
case ACTION_REC_F2: case ACTION_REC_F2:

View file

@ -123,11 +123,15 @@ static unsigned long rec_sizesplit_bytes(void)
* Time strings used for the trigger durations. * Time strings used for the trigger durations.
* Keep synchronous to trigger_times in settings_apply_trigger * Keep synchronous to trigger_times in settings_apply_trigger
*/ */
const char * const trig_durations[TRIG_DURATION_COUNT] = const struct opt_items trig_durations[TRIG_DURATION_COUNT] =
{ {
"0s", "1s", "2s", "5s", #define TS(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) }
"10s", "15s", "20s", "25s", "30s", #define TM(x) { (unsigned char *)(#x "min"), TALK_ID(x, UNIT_MIN) }
"1min", "2min", "5min", "10min" TS(0), TS(1), TS(2), TS(5),
TS(10), TS(15), TS(20), TS(25), TS(30),
TM(1), TM(2), TM(5), TM(10)
#undef TS
#undef TM
}; };
void settings_apply_trigger(void) void settings_apply_trigger(void)

View file

@ -39,6 +39,11 @@
#include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */ #include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */
#endif #endif
struct opt_items {
unsigned const char* string;
long voice_id;
};
/** Setting values defines **/ /** Setting values defines **/
/* name of directory where configuration, fonts and other data /* name of directory where configuration, fonts and other data
@ -103,7 +108,7 @@
#define TRIG_MODE_REARM 2 #define TRIG_MODE_REARM 2
#define TRIG_DURATION_COUNT 13 #define TRIG_DURATION_COUNT 13
extern const char * const trig_durations[TRIG_DURATION_COUNT]; extern const struct opt_items trig_durations[TRIG_DURATION_COUNT];
#define CROSSFADE_ENABLE_SHUFFLE 1 #define CROSSFADE_ENABLE_SHUFFLE 1
#define CROSSFADE_ENABLE_TRACKSKIP 2 #define CROSSFADE_ENABLE_TRACKSKIP 2
@ -255,10 +260,6 @@ void settings_display(void);
enum optiontype { INT, BOOL }; enum optiontype { INT, BOOL };
struct opt_items {
unsigned const char* string;
long voice_id;
};
const struct settings_list* find_setting(void* variable, int *id); const struct settings_list* find_setting(void* variable, int *id);
bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len); bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len);
void talk_setting(void *global_settings_variable); void talk_setting(void *global_settings_variable);