From 2116bba296f12bd94024ec7c39ae03fbfcc5bdef Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 31 Jan 2005 00:39:20 +0000 Subject: New function for formatting large-range values for output, both printed and voiced. This replaces num2max5(). It is currently used for the total/free space display in the info menu, for the recorded number of bytes (recorders) and the MMC debug info (Ondios). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5721 a1c6a512-1295-4272-9138-f99709370657 --- apps/main_menu.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'apps/main_menu.c') diff --git a/apps/main_menu.c b/apps/main_menu.c index 7ae57f1c7b..21e8c091b6 100644 --- a/apps/main_menu.c +++ b/apps/main_menu.c @@ -137,7 +137,7 @@ extern bool simulate_usb(void); #endif bool show_info(void) { - char s[32]; + char s[32], s2[32]; /* avoid overflow for 8MB mod :) was: ((mp3end - mp3buf) * 1000) / 0x100000; */ int buflen = ((mp3end - mp3buf) * 100) / 0x19999; int integer, decimal; @@ -146,9 +146,13 @@ bool show_info(void) int state = 1; unsigned long size, free; + const unsigned char *kbyte_units[] = { + ID2P(LANG_KILOBYTE), + ID2P(LANG_MEGABYTE), + ID2P(LANG_GIGABYTE) + }; + fat_size( IF_MV2(0,) &size, &free ); - size /= 1024; - free /= 1024; if (global_settings.talk_menu) { /* say whatever is reasonable, no real connection to the screen */ @@ -160,11 +164,8 @@ bool show_info(void) talk_value(battery_level(), UNIT_PERCENT, true); } - talk_id(LANG_DISK_FREE_STAT, enqueue); - talk_number(free / 1024, true); - decimal = free % 1024 / 100; - talk_id(VOICE_POINT, true); - talk_value(decimal, UNIT_GB, true); + talk_id(LANG_DISK_FREE_INFO, enqueue); + output_dyn_value(NULL, 0, free, kbyte_units, true); /* NULL == talk */ #ifdef HAVE_RTC { @@ -220,14 +221,12 @@ bool show_info(void) } if (state & 2) { - integer = size / 1024; - decimal = size % 1024 / 100; - snprintf(s, sizeof s, str(LANG_DISK_STAT), integer, decimal); + output_dyn_value(s2, sizeof s2, size, kbyte_units, true); + snprintf(s, sizeof s, "%s %s", str(LANG_DISK_SIZE_INFO), s2); lcd_puts(0, y++, s); - - integer = free / 1024; - decimal = free % 1024 / 100; - snprintf(s, sizeof s, str(LANG_DISK_FREE_STAT), integer, decimal); + + output_dyn_value(s2, sizeof s2, free, kbyte_units, true); + snprintf(s, sizeof s, "%s %s", str(LANG_DISK_FREE_INFO), s2); lcd_puts(0, y++, s); } lcd_update(); -- cgit v1.2.3