summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Doyon <s.doyon@videotron.ca>2007-11-03 03:43:12 +0000
committerStéphane Doyon <s.doyon@videotron.ca>2007-11-03 03:43:12 +0000
commit8b8785b541d0630c65cb399ad66be2d2b072b277 (patch)
treefc2bfdacfb5c75e7968ad6bfc1220fd4d8d6de94
parentf6b404bd73818bdf9fd58b1edb61141a6d11af87 (diff)
Accept FS#7798: Voice unit for time
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15416 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/talk.c28
-rw-r--r--apps/talk.h2
2 files changed, 30 insertions, 0 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 0c8fafbe59..a7baf4927a 100644
--- a/apps/talk.c
+++ b/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
diff --git a/apps/talk.h b/apps/talk.h
index 0dea8d6b18..bb05bd8321 100644
--- a/apps/talk.h
+++ b/apps/talk.h
@@ -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 */
};