Overlooked to "voice" the set_int() function, this is why many numerical setting remained silent.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4416 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jörg Hohensohn 2004-03-20 16:49:58 +00:00
parent 78f06b9a2c
commit beec2e97e6
7 changed files with 106 additions and 37 deletions

View file

@ -11,6 +11,8 @@
# If you re-order things or remove entries, you must bump the binary language # If you re-order things or remove entries, you must bump the binary language
# file version number in both the 'binlang' tool and the language loader code. # file version number in both the 'binlang' tool and the language loader code.
# #
# The "voice' entry contains how we want the speech UI to pronounce this.
#
id: LANG_SOUND_SETTINGS id: LANG_SOUND_SETTINGS
desc: in the main menu desc: in the main menu
eng: "Sound Settings" eng: "Sound Settings"
@ -2345,5 +2347,29 @@ eng: ""
voice: "gigabyte" voice: "gigabyte"
new: new:
id: VOICE_MILLIAMPHOURS
desc: spoken only
eng: ""
voice: "milliamp hours"
new:
id: VOICE_PIXEL
desc: spoken only
eng: ""
voice: "pixel"
new:
id: VOICE_PER_SEC
desc: spoken only
eng: ""
voice: "per second"
new:
id: VOICE_HERTZ
desc: spoken only
eng: ""
voice: "hertz"
new:
#carry on adding normal LANG_ strings below #carry on adding normal LANG_ strings below

View file

@ -1682,6 +1682,7 @@ bool set_bool_options(char* string, bool* variable,
bool set_int(char* string, bool set_int(char* string,
char* unit, char* unit,
int voice_unit,
int* variable, int* variable,
void (*function)(int), void (*function)(int),
int step, int step,
@ -1691,6 +1692,7 @@ bool set_int(char* string,
bool done = false; bool done = false;
int button; int button;
int org_value=*variable; int org_value=*variable;
int last_value = 0x7FFFFFFF; /* out of range init */
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar) if(global_settings.statusbar)
@ -1711,6 +1713,20 @@ bool set_int(char* string,
#endif #endif
lcd_update(); lcd_update();
if (*variable != last_value)
{
if (voice_unit < UNIT_LAST)
{ /* use the available unit definition */
talk_value(*variable, voice_unit, false);
}
else
{ /* say the number, followed by an arbitrary voice ID */
talk_number(*variable, false);
talk_id(voice_unit, true);
}
last_value = *variable;
}
button = button_get_w_tmo(HZ/2); button = button_get_w_tmo(HZ/2);
switch(button) { switch(button) {
#ifdef HAVE_RECORDER_KEYPAD #ifdef HAVE_RECORDER_KEYPAD

View file

@ -230,7 +230,7 @@ bool set_bool_options(char* string, bool* variable,
bool set_bool(char* string, bool* variable ); bool set_bool(char* string, bool* variable );
bool set_option(char* string, void* variable, enum optiontype type, bool set_option(char* string, void* variable, enum optiontype type,
struct opt_items* options, int numoptions, void (*function)(int)); struct opt_items* options, int numoptions, void (*function)(int));
bool set_int(char* string, char* unit, int* variable, bool set_int(char* string, char* unit, int voice_unit, int* variable,
void (*function)(int), int step, int min, int max ); void (*function)(int), int step, int min, int max );
bool set_time(char* string, int timedate[]); bool set_time(char* string, int timedate[]);
int read_line(int fd, char* buffer, int buffer_size); int read_line(int fd, char* buffer, int buffer_size);

View file

@ -63,7 +63,8 @@ static bool car_adapter_mode(void)
static bool contrast(void) static bool contrast(void)
{ {
return set_int( str(LANG_CONTRAST), "", &global_settings.contrast, return set_int( str(LANG_CONTRAST), "", UNIT_INT,
&global_settings.contrast,
lcd_set_contrast, 1, MIN_CONTRAST_SETTING, lcd_set_contrast, 1, MIN_CONTRAST_SETTING,
MAX_CONTRAST_SETTING ); MAX_CONTRAST_SETTING );
} }
@ -154,7 +155,7 @@ static bool volume_type(void)
#ifdef PM_DEBUG #ifdef PM_DEBUG
static bool peak_meter_fps_menu(void) { static bool peak_meter_fps_menu(void) {
bool retval = false; bool retval = false;
retval = set_int( "Refresh rate", "/s", retval = set_int( "Refresh rate", "/s", UNIT_PER_SEC,
&peak_meter_fps, &peak_meter_fps,
NULL, 1, 5, 40); NULL, 1, 5, 40);
return retval; return retval;
@ -251,7 +252,7 @@ static bool peak_meter_release(void) {
fits into a 7 bit number. The 8th bit is used for storing fits into a 7 bit number. The 8th bit is used for storing
something else in the rtc ram. something else in the rtc ram.
Also, the max value is 0x7e, since the RTC value 0xff is reserved */ Also, the max value is 0x7e, since the RTC value 0xff is reserved */
retval = set_int( str(LANG_PM_RELEASE), str(LANG_PM_UNITS_PER_READ), retval = set_int( str(LANG_PM_RELEASE), STR(LANG_PM_UNITS_PER_READ),
&global_settings.peak_meter_release, &global_settings.peak_meter_release,
NULL, 1, 1, 0x7e); NULL, 1, 1, 0x7e);
@ -320,7 +321,7 @@ static bool peak_meter_min(void) {
int range_max = -global_settings.peak_meter_max; int range_max = -global_settings.peak_meter_max;
int min = -global_settings.peak_meter_min; int min = -global_settings.peak_meter_min;
retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS), retval = set_int(str(LANG_PM_MIN), str(LANG_PM_DBFS), UNIT_DB,
&min, NULL, 1, -89, range_max); &min, NULL, 1, -89, range_max);
global_settings.peak_meter_min = - min; global_settings.peak_meter_min = - min;
@ -330,7 +331,7 @@ static bool peak_meter_min(void) {
else { else {
int min = global_settings.peak_meter_min; int min = global_settings.peak_meter_min;
retval = set_int(str(LANG_PM_MIN), "%", retval = set_int(str(LANG_PM_MIN), "%", UNIT_PERCENT,
&min, NULL, &min, NULL,
1, 0, global_settings.peak_meter_max - 1); 1, 0, global_settings.peak_meter_max - 1);
@ -354,7 +355,7 @@ static bool peak_meter_max(void) {
int range_min = -global_settings.peak_meter_min; int range_min = -global_settings.peak_meter_min;
int max = -global_settings.peak_meter_max;; int max = -global_settings.peak_meter_max;;
retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS), retval = set_int(str(LANG_PM_MAX), str(LANG_PM_DBFS), UNIT_DB,
&max, NULL, 1, range_min, 0); &max, NULL, 1, range_min, 0);
global_settings.peak_meter_max = - max; global_settings.peak_meter_max = - max;
@ -365,7 +366,7 @@ static bool peak_meter_max(void) {
else { else {
int max = global_settings.peak_meter_max; int max = global_settings.peak_meter_max;
retval = set_int(str(LANG_PM_MAX), "%", retval = set_int(str(LANG_PM_MAX), "%", UNIT_PERCENT,
&max, NULL, &max, NULL,
1, global_settings.peak_meter_min + 1, 100); 1, global_settings.peak_meter_min + 1, 100);
@ -579,7 +580,8 @@ static bool poweroff_idle_timer(void)
static bool scroll_speed(void) static bool scroll_speed(void)
{ {
return set_int(str(LANG_SCROLL), "Hz", &global_settings.scroll_speed, return set_int(str(LANG_SCROLL), "Hz", UNIT_HERTZ,
&global_settings.scroll_speed,
&lcd_scroll_speed, 1, 1, 10 ); &lcd_scroll_speed, 1, 1, 10 );
} }
@ -587,7 +589,8 @@ static bool scroll_speed(void)
static bool scroll_delay(void) static bool scroll_delay(void)
{ {
int dummy = global_settings.scroll_delay * (HZ/10); int dummy = global_settings.scroll_delay * (HZ/10);
int rc = set_int(str(LANG_SCROLL_DELAY), "ms", &dummy, int rc = set_int(str(LANG_SCROLL_DELAY), "ms", UNIT_MS,
&dummy,
&lcd_scroll_delay, 100, 0, 2500 ); &lcd_scroll_delay, 100, 0, 2500 );
global_settings.scroll_delay = dummy / (HZ/10); global_settings.scroll_delay = dummy / (HZ/10);
return rc; return rc;
@ -596,7 +599,7 @@ static bool scroll_delay(void)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
static bool scroll_step(void) static bool scroll_step(void)
{ {
return set_int(str(LANG_SCROLL_STEP_EXAMPLE), "pixels", return set_int(str(LANG_SCROLL_STEP_EXAMPLE), "pixels", UNIT_PIXEL,
&global_settings.scroll_step, &global_settings.scroll_step,
&lcd_scroll_step, 1, 1, LCD_WIDTH ); &lcd_scroll_step, 1, 1, LCD_WIDTH );
} }
@ -604,7 +607,8 @@ static bool scroll_step(void)
static bool bidir_limit(void) static bool bidir_limit(void)
{ {
return set_int(str(LANG_BIDIR_SCROLL), "%", &global_settings.bidir_limit, return set_int(str(LANG_BIDIR_SCROLL), "%", UNIT_PERCENT,
&global_settings.bidir_limit,
&lcd_bidir_scroll, 25, 0, 200 ); &lcd_bidir_scroll, 25, 0, 200 );
} }
@ -627,7 +631,8 @@ static bool jump_scroll(void)
static bool jump_scroll_delay(void) static bool jump_scroll_delay(void)
{ {
int dummy = global_settings.jump_scroll_delay * (HZ/10); int dummy = global_settings.jump_scroll_delay * (HZ/10);
int rc = set_int(str(LANG_JUMP_SCROLL_DELAY), "ms", &dummy, int rc = set_int(str(LANG_JUMP_SCROLL_DELAY), "ms", UNIT_MS,
&dummy,
&lcd_jump_scroll_delay, 100, 0, 2500 ); &lcd_jump_scroll_delay, 100, 0, 2500 );
global_settings.jump_scroll_delay = dummy / (HZ/10); global_settings.jump_scroll_delay = dummy / (HZ/10);
return rc; return rc;
@ -640,7 +645,8 @@ static bool jump_scroll_delay(void)
*/ */
static bool battery_capacity(void) static bool battery_capacity(void)
{ {
return set_int(str(LANG_BATTERY_CAPACITY), "mAh", &global_settings.battery_capacity, return set_int(str(LANG_BATTERY_CAPACITY), "mAh", UNIT_MAH,
&global_settings.battery_capacity,
&set_battery_capacity, 50, 1500, BATTERY_CAPACITY_MAX ); &set_battery_capacity, 50, 1500, BATTERY_CAPACITY_MAX );
} }
#endif #endif
@ -754,7 +760,8 @@ static bool timeformat_set(void)
static bool spindown(void) static bool spindown(void)
{ {
return set_int(str(LANG_SPINDOWN), "s", &global_settings.disk_spindown, return set_int(str(LANG_SPINDOWN), "s", UNIT_SEC,
&global_settings.disk_spindown,
ata_spindown, 1, 3, 254 ); ata_spindown, 1, 3, 254 );
} }
@ -778,21 +785,21 @@ static bool poweroff(void)
static bool max_files_in_dir(void) static bool max_files_in_dir(void)
{ {
return set_int(str(LANG_MAX_FILES_IN_DIR), "", return set_int(str(LANG_MAX_FILES_IN_DIR), "", UNIT_INT,
&global_settings.max_files_in_dir, &global_settings.max_files_in_dir,
NULL, 50, 50, 10000 ); NULL, 50, 50, 10000 );
} }
static bool max_files_in_playlist(void) static bool max_files_in_playlist(void)
{ {
return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "", return set_int(str(LANG_MAX_FILES_IN_PLAYLIST), "", UNIT_INT,
&global_settings.max_files_in_playlist, &global_settings.max_files_in_playlist,
NULL, 1000, 1000, 20000 ); NULL, 1000, 1000, 20000 );
} }
static bool buffer_margin(void) static bool buffer_margin(void)
{ {
return set_int(str(LANG_MP3BUFFER_MARGIN), "s", return set_int(str(LANG_MP3BUFFER_MARGIN), "s", UNIT_SEC,
&global_settings.buffer_margin, &global_settings.buffer_margin,
mpeg_set_buffer_margin, 1, 0, 7 ); mpeg_set_buffer_margin, 1, 0, 7 );
} }

View file

@ -238,7 +238,7 @@ static bool recchannels(void)
static bool recquality(void) static bool recquality(void)
{ {
return set_int(str(LANG_RECORDING_QUALITY), "", return set_int(str(LANG_RECORDING_QUALITY), "", UNIT_INT,
&global_settings.rec_quality, &global_settings.rec_quality,
NULL, 1, 0, 7 ); NULL, 1, 0, 7 );
} }

View file

@ -35,8 +35,8 @@ extern void bitswap(unsigned char *data, int length); /* no header for this */
/***************** Constants *****************/ /***************** Constants *****************/
#define VOICEFONT_FILENAME "/.rockbox/langs/english.voice" #define QUEUE_SIZE 20
#define QUEUE_SIZE 32 const char* voicefont_file = "/.rockbox/langs/english.voice";
/***************** Data types *****************/ /***************** Data types *****************/
@ -87,7 +87,7 @@ static int load_voicefont(void)
p_voicefont = NULL; /* indicate no voicefont if we fail below */ p_voicefont = NULL; /* indicate no voicefont if we fail below */
fd = open(VOICEFONT_FILENAME, O_RDONLY); fd = open(voicefont_file, O_RDONLY);
if (fd < 0) /* failed to open */ if (fd < 0) /* failed to open */
{ {
p_voicefont = NULL; /* indicate no voicefont */ p_voicefont = NULL; /* indicate no voicefont */
@ -203,8 +203,20 @@ static int queue_clip(unsigned char* buf, int size, bool enqueue)
void talk_init(void) void talk_init(void)
{ {
has_voicefont = true; /* unless we fail later, assume we have one */ int fd;
talk_buffer_steal();
fd = open(voicefont_file, O_RDONLY);
if (fd >= 0) /* success */
{
close(fd);
has_voicefont = true;
}
else
{
has_voicefont = false; /* no voice file available */
}
talk_buffer_steal(); /* abuse this for most of our inits */
queue_write = queue_read = 0; queue_write = queue_read = 0;
} }
@ -294,18 +306,18 @@ int talk_file(char* filename, bool enqueue)
} }
/* say a numeric value, this works for english, /* say a numeric value, this word ordering works for english,
but not necessarily for other languages */ but not necessarily for other languages (e.g. german) */
int talk_number(int n, bool enqueue) int talk_number(int n, bool enqueue)
{ {
int level = 0; // mille count int level = 0; /* mille count */
int mil = 1000000000; // highest possible "-illion" int mil = 1000000000; /* highest possible "-illion" */
if (!enqueue) if (!enqueue)
shutup(); /* cut off all the pending stuff */ shutup(); /* cut off all the pending stuff */
if (n==0) if (n==0)
{ // special case { /* special case */
talk_id(VOICE_ZERO, true); talk_id(VOICE_ZERO, true);
return 0; return 0;
} }
@ -318,9 +330,9 @@ int talk_number(int n, bool enqueue)
while (n) while (n)
{ {
int segment = n / mil; // extract in groups of 3 digits int segment = n / mil; /* extract in groups of 3 digits */
n -= segment * mil; // remove the used digits from number n -= segment * mil; /* remove the used digits from number */
mil /= 1000; // digit place for next round mil /= 1000; /* digit place for next round */
if (segment) if (segment)
{ {
@ -333,7 +345,7 @@ int talk_number(int n, bool enqueue)
talk_id(VOICE_HUNDRED, true); talk_id(VOICE_HUNDRED, true);
} }
// combination indexing /* combination indexing */
if (ones > 20) if (ones > 20)
{ {
int tens = ones/10 + 18; int tens = ones/10 + 18;
@ -341,11 +353,11 @@ int talk_number(int n, bool enqueue)
ones %= 10; ones %= 10;
} }
// direct indexing /* direct indexing */
if (ones) if (ones)
talk_id(VOICE_ZERO + ones, true); talk_id(VOICE_ZERO + ones, true);
// add billion, million, thousand /* add billion, million, thousand */
if (mil) if (mil)
talk_id(VOICE_BILLION + level, true); talk_id(VOICE_BILLION + level, true);
} }
@ -369,7 +381,11 @@ int talk_value(int n, int unit, bool enqueue)
VOICE_DB, VOICE_DB,
VOICE_PERCENT, VOICE_PERCENT,
VOICE_MEGABYTE, VOICE_MEGABYTE,
VOICE_GIGABYTE VOICE_GIGABYTE,
VOICE_MILLIAMPHOURS,
VOICE_PIXEL,
VOICE_PER_SEC,
VOICE_HERTZ,
}; };
if (unit < 0 || unit >= UNIT_LAST) if (unit < 0 || unit >= UNIT_LAST)
@ -377,7 +393,7 @@ int talk_value(int n, int unit, bool enqueue)
else else
unit_id = unit_voiced[unit]; unit_id = unit_voiced[unit];
if ((n==1 || n==-1) // singular? if ((n==1 || n==-1) /* singular? */
&& unit_id >= VOICE_SECONDS && unit_id <= VOICE_HOURS) && unit_id >= VOICE_SECONDS && unit_id <= VOICE_HOURS)
{ {
unit_id--; /* use the singular for those units which have */ unit_id--; /* use the singular for those units which have */

View file

@ -38,6 +38,10 @@ enum {
UNIT_PERCENT, /* % */ UNIT_PERCENT, /* % */
UNIT_MB, /* megabyte */ UNIT_MB, /* megabyte */
UNIT_GB, /* gigabyte */ UNIT_GB, /* gigabyte */
UNIT_MAH, /* milliAmp hours */
UNIT_PIXEL, /* pixels */
UNIT_PER_SEC, /* per second */
UNIT_HERTZ, /* hertz */
UNIT_LAST /* END MARKER */ UNIT_LAST /* END MARKER */
}; };