summaryrefslogtreecommitdiffstats
path: root/apps/misc.h
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/misc.h
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/misc.h')
-rw-r--r--apps/misc.h46
1 files changed, 45 insertions, 1 deletions
diff --git a/apps/misc.h b/apps/misc.h
index 6821c6debf..25e9d17b9c 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -28,7 +28,7 @@
extern const unsigned char * const byte_units[];
extern const unsigned char * const * const kibyte_units;
-
+extern const unsigned char * const unit_strings_core[];
/* Format a large-range value for output, using the appropriate unit so that
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
* units) if possible, and 3 significant digits are shown. If a buffer is
@@ -41,6 +41,50 @@ char *output_dyn_value(char *buf,
unsigned int unit_count,
bool binary_scale);
+
+/* format_time_auto */
+enum e_fmt_time_auto_idx
+{
+ UNIT_IDX_HR = 0,
+ UNIT_IDX_MIN,
+ UNIT_IDX_SEC,
+ UNIT_IDX_MS,
+ UNIT_IDX_TIME_COUNT,
+};
+#define UNIT_IDX_MASK 0x01FFU /*Return only Unit_IDX*/
+#define UNIT_TRIM_ZERO 0x0200U /*Don't show leading zero on max_idx*/
+#define UNIT_LOCK_HR 0x0400U /*Don't Auto Range below this field*/
+#define UNIT_LOCK_MIN 0x0800U /*Don't Auto Range below this field*/
+#define UNIT_LOCK_SEC 0x1000U /*Don't Auto Range below this field*/
+
+/* time_split_units()
+ split time values depending on base unit
+ unit_idx: UNIT_HOUR, UNIT_MIN, UNIT_SEC, UNIT_MS
+ abs_value: absolute time value
+ units_in: array of unsigned ints with IDX_TIME_COUNT fields
+*/
+unsigned int time_split_units(int unit_idx, unsigned long abs_val,
+ unsigned long (*units_in)[UNIT_IDX_TIME_COUNT]);
+
+/* format_time_auto - return an auto ranged time string;
+ buffer: needs to be at least 25 characters for full range
+
+ unit_idx: specifies lowest or base index of the value
+ add | UNIT_LOCK_ to keep place holder of units that would normally be
+ discarded.. For instance, UNIT_LOCK_HR would keep the hours place, ex: string
+ 00:10:10 (0 HRS 10 MINS 10 SECONDS) normally it would return as 10:10
+ add | UNIT_TRIM_ZERO to supress leading zero on the largest unit
+
+ value: should be passed in the same form as unit_idx
+
+ supress_unit: may be set to true and in this case the
+ hr, min, sec, ms identifiers will be left off the resulting string but
+ since right to left languages are handled it is advisable to leave units
+ as an indication of the text direction
+*/
+const char *format_time_auto(char *buffer, int buf_len, long value,
+ int unit_idx, bool supress_unit);
+
/* Format time into buf.
*
* buf - buffer to format to.