summaryrefslogtreecommitdiff
path: root/apps/main_menu.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-01-31 00:39:20 +0000
committerJens Arnold <amiconn@rockbox.org>2005-01-31 00:39:20 +0000
commit2116bba296f12bd94024ec7c39ae03fbfcc5bdef (patch)
tree29c49672b2dcf2012bb6bb69f8130f024f52bdb9 /apps/main_menu.c
parent19afad88f8bb973726af0c6a7850dbd992996a9f (diff)
downloadrockbox-2116bba296f12bd94024ec7c39ae03fbfcc5bdef.tar.gz
rockbox-2116bba296f12bd94024ec7c39ae03fbfcc5bdef.zip
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
Diffstat (limited to 'apps/main_menu.c')
-rw-r--r--apps/main_menu.c29
1 files changed, 14 insertions, 15 deletions
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);
137#endif 137#endif
138bool show_info(void) 138bool show_info(void)
139{ 139{
140 char s[32]; 140 char s[32], s2[32];
141 /* avoid overflow for 8MB mod :) was: ((mp3end - mp3buf) * 1000) / 0x100000; */ 141 /* avoid overflow for 8MB mod :) was: ((mp3end - mp3buf) * 1000) / 0x100000; */
142 int buflen = ((mp3end - mp3buf) * 100) / 0x19999; 142 int buflen = ((mp3end - mp3buf) * 100) / 0x19999;
143 int integer, decimal; 143 int integer, decimal;
@@ -146,9 +146,13 @@ bool show_info(void)
146 int state = 1; 146 int state = 1;
147 unsigned long size, free; 147 unsigned long size, free;
148 148
149 const unsigned char *kbyte_units[] = {
150 ID2P(LANG_KILOBYTE),
151 ID2P(LANG_MEGABYTE),
152 ID2P(LANG_GIGABYTE)
153 };
154
149 fat_size( IF_MV2(0,) &size, &free ); 155 fat_size( IF_MV2(0,) &size, &free );
150 size /= 1024;
151 free /= 1024;
152 156
153 if (global_settings.talk_menu) 157 if (global_settings.talk_menu)
154 { /* say whatever is reasonable, no real connection to the screen */ 158 { /* say whatever is reasonable, no real connection to the screen */
@@ -160,11 +164,8 @@ bool show_info(void)
160 talk_value(battery_level(), UNIT_PERCENT, true); 164 talk_value(battery_level(), UNIT_PERCENT, true);
161 } 165 }
162 166
163 talk_id(LANG_DISK_FREE_STAT, enqueue); 167 talk_id(LANG_DISK_FREE_INFO, enqueue);
164 talk_number(free / 1024, true); 168 output_dyn_value(NULL, 0, free, kbyte_units, true); /* NULL == talk */
165 decimal = free % 1024 / 100;
166 talk_id(VOICE_POINT, true);
167 talk_value(decimal, UNIT_GB, true);
168 169
169#ifdef HAVE_RTC 170#ifdef HAVE_RTC
170 { 171 {
@@ -220,14 +221,12 @@ bool show_info(void)
220 } 221 }
221 222
222 if (state & 2) { 223 if (state & 2) {
223 integer = size / 1024; 224 output_dyn_value(s2, sizeof s2, size, kbyte_units, true);
224 decimal = size % 1024 / 100; 225 snprintf(s, sizeof s, "%s %s", str(LANG_DISK_SIZE_INFO), s2);
225 snprintf(s, sizeof s, str(LANG_DISK_STAT), integer, decimal);
226 lcd_puts(0, y++, s); 226 lcd_puts(0, y++, s);
227 227
228 integer = free / 1024; 228 output_dyn_value(s2, sizeof s2, free, kbyte_units, true);
229 decimal = free % 1024 / 100; 229 snprintf(s, sizeof s, "%s %s", str(LANG_DISK_FREE_INFO), s2);
230 snprintf(s, sizeof s, str(LANG_DISK_FREE_STAT), integer, decimal);
231 lcd_puts(0, y++, s); 230 lcd_puts(0, y++, s);
232 } 231 }
233 lcd_update(); 232 lcd_update();