Accept FS#7798: Voice unit for time
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15416 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f6b404bd73
commit
8b8785b541
2 changed files with 30 additions and 0 deletions
28
apps/talk.c
28
apps/talk.c
|
@ -734,6 +734,30 @@ int talk_number(long n, bool enqueue)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Say time duration/interval. Input is time in seconds,
|
||||
say hours,minutes,seconds. */
|
||||
static int talk_time_unit(long secs, bool exact, bool enqueue)
|
||||
{
|
||||
int hours, mins;
|
||||
if (!enqueue)
|
||||
talk_shutup();
|
||||
if((hours = secs/3600)) {
|
||||
secs %= 3600;
|
||||
talk_value(hours, UNIT_HOUR, true);
|
||||
}
|
||||
if((mins = secs/60)) {
|
||||
secs %= 60;
|
||||
if(exact || !hours)
|
||||
talk_value(mins, UNIT_MIN, true);
|
||||
else talk_number(mins, true); /* don't say "minutes" */
|
||||
}
|
||||
if((exact && secs) || (!hours && !mins))
|
||||
talk_value(secs, UNIT_SEC, true);
|
||||
else if(!hours && secs)
|
||||
talk_number(secs, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* singular/plural aware saying of a value */
|
||||
int talk_value(long n, int unit, bool enqueue)
|
||||
{
|
||||
|
@ -778,6 +802,10 @@ int talk_value(long n, int unit, bool enqueue)
|
|||
return -1;
|
||||
#endif
|
||||
|
||||
/* special case for time duration */
|
||||
if (unit == UNIT_TIME || unit == UNIT_TIME_EXACT)
|
||||
return talk_time_unit(n, unit == UNIT_TIME_EXACT, enqueue);
|
||||
|
||||
if (unit < 0 || unit >= UNIT_LAST)
|
||||
unit_id = -1;
|
||||
else
|
||||
|
|
|
@ -45,6 +45,8 @@ enum {
|
|||
UNIT_MB, /* Megabytes */
|
||||
UNIT_KBIT, /* kilobits per sec */
|
||||
UNIT_PM_TICK, /* peak meter units per tick */
|
||||
UNIT_TIME_EXACT,/* time duration/interval in seconds, says hours,mins,secs*/
|
||||
UNIT_TIME, /* as above but less verbose */
|
||||
UNIT_LAST /* END MARKER */
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue