summaryrefslogtreecommitdiffstats
path: root/apps/talk.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-12-17 22:27:55 -0600
committerWilliam Wilgus <me.theuser@yahoo.com>2018-12-22 12:27:21 -0600
commita06d9c85f7475d650cc451fb0f537623c0206f5a (patch)
tree952a0e7265e836328873a5e2f6eb0ca8ec3cc06a /apps/talk.c
parentb3356e3aff34a4ab94778e7f6a8db43f9135296c (diff)
downloadrockbox-a06d9c85f7475d650cc451fb0f537623c0206f5a.tar.gz
rockbox-a06d9c85f7475d650cc451fb0f537623c0206f5a.tar.bz2
rockbox-a06d9c85f7475d650cc451fb0f537623c0206f5a.zip
Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
Unifies time formatting in settings_list.c allows time format to display as HH:MM:SS.MSS or any consecutive combination thereof (hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss) works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING' Time is auto-ranged dependent on value Adds talk_time_intervals to allow time values to be spoken similar to display format: x Hours, x Minutes, x Seconds, x Milliseconds Table lookups merged or removed from recording, clip meter and lcd timeout -String_Choice replaced with TABLE_SETTING or INT_SETTING for these functions as well, cleaned-up cfg_vals that get saved to cfgfile RTL Languages ARE supported Negative values ARE supported Backlight on/off are now Always and Never to share formatter with LCD Timeout Added flag to allow ranged units to be locked to a minimum index Added flag to allow leading zero to be supressed from the largest unit merged talk_time_unit() and talk_time_intervals() optimized time_split() optimized format_time_auto() Backlight time-out list same as original Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
Diffstat (limited to 'apps/talk.c')
-rw-r--r--apps/talk.c71
1 files changed, 55 insertions, 16 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 8a2a809c37..de564c0ff0 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -47,6 +47,7 @@
#include "plugin.h" /* plugin_get_buffer() */
#include "debug.h"
#include "panic.h"
+#include "misc.h" /* time_split_units() */
/* Memory layout varies between targets because the
Archos (MASCODEC) devices cannot mix voice and audio playback
@@ -1307,22 +1308,7 @@ static int talk_year(long year, bool enqueue)
say hours,minutes,seconds. */
static int talk_time_unit(long secs, 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;
- talk_value(mins, UNIT_MIN, true);
- }
- if((secs) || (!hours && !mins))
- talk_value(secs, UNIT_SEC, true);
- else if(!hours && secs)
- talk_number(secs, true);
- return 0;
+ return talk_time_intervals(secs, UNIT_SEC, enqueue);
}
void talk_fractional(char *tbuf, int value, int unit)
@@ -1443,6 +1429,59 @@ int talk_value_decimal(long n, int unit, int decimals, bool enqueue)
return 0;
}
+/* Say time duration/interval. Input is time unit specifies base unit,
+ say hours,minutes,seconds, milliseconds. or any combination thereof */
+int talk_time_intervals(long time, int unit_idx, bool enqueue)
+{
+ unsigned long units_in[UNIT_IDX_TIME_COUNT];
+
+ if (talk_temp_disable_count > 0)
+ return -1; /* talking has been disabled */
+ if (!check_audio_status())
+ return -1;
+
+ if (talk_handle <= 0 || index_handle <= 0) /* reload needed? */
+ {
+ int fd = open_voicefile();
+ if (fd < 0 || !load_voicefile_index(fd))
+ return -1;
+ load_voicefile_data(fd);
+ close(fd);
+ }
+
+ if (!enqueue)
+ talk_shutup(); /* cut off all the pending stuff */
+
+ time_split_units(unit_idx, labs(time), &units_in);
+
+ if (time < 0)
+ talk_id(VOICE_MINUS, true);
+
+ if (time == 0)
+ talk_value(0, unit_idx, true);
+ else
+ {
+ if (units_in[UNIT_IDX_HR] != 0)
+ {
+ talk_value(units_in[UNIT_IDX_HR], UNIT_HOUR, true);
+ }
+ if (units_in[UNIT_IDX_MIN] != 0)
+ {
+ talk_value(units_in[UNIT_IDX_MIN], UNIT_MIN, true);
+ }
+ if (units_in[UNIT_IDX_SEC] != 0)
+ {
+ talk_value(units_in[UNIT_IDX_SEC], UNIT_SEC, true);
+ }
+ if (units_in[UNIT_IDX_MS] != 0)
+ {
+ talk_value(units_in[UNIT_IDX_MS], UNIT_MS, true);
+ }
+ }
+
+ return -1;
+}
+
/* spell a string */
int talk_spell(const char* spell, bool enqueue)
{