diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-01-31 00:39:20 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-01-31 00:39:20 +0000 |
commit | 2116bba296f12bd94024ec7c39ae03fbfcc5bdef (patch) | |
tree | 29c49672b2dcf2012bb6bb69f8130f024f52bdb9 /apps | |
parent | 19afad88f8bb973726af0c6a7850dbd992996a9f (diff) | |
download | rockbox-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')
-rw-r--r-- | apps/debug_menu.c | 43 | ||||
-rw-r--r-- | apps/lang/deutsch.lang | 69 | ||||
-rw-r--r-- | apps/lang/english.lang | 65 | ||||
-rw-r--r-- | apps/main_menu.c | 29 | ||||
-rw-r--r-- | apps/misc.c | 75 | ||||
-rw-r--r-- | apps/misc.h | 12 | ||||
-rw-r--r-- | apps/recorder/recording.c | 16 |
7 files changed, 209 insertions, 100 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 1c633200c2..5f1b5af241 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -1268,32 +1268,19 @@ static bool view_runtime(void) | |||
1268 | } | 1268 | } |
1269 | 1269 | ||
1270 | #ifdef HAVE_MMC | 1270 | #ifdef HAVE_MMC |
1271 | /* value is 10 * real value */ | ||
1272 | static unsigned char prep_value_unit(unsigned long *value, | ||
1273 | const unsigned char *units) | ||
1274 | { | ||
1275 | int unit_no = 0; | ||
1276 | |||
1277 | while (*value >= 10000) | ||
1278 | { | ||
1279 | *value /= 1000; | ||
1280 | unit_no++; | ||
1281 | } | ||
1282 | return units[unit_no]; | ||
1283 | } | ||
1284 | |||
1285 | bool dbg_mmc_info(void) | 1271 | bool dbg_mmc_info(void) |
1286 | { | 1272 | { |
1287 | bool done = false; | 1273 | bool done = false; |
1288 | int currval = 0; | 1274 | int currval = 0; |
1289 | unsigned long value; | 1275 | unsigned long value; |
1290 | tCardInfo *card; | 1276 | tCardInfo *card; |
1291 | unsigned char pbuf[32]; | 1277 | unsigned char pbuf[32], pbuf2[32]; |
1292 | unsigned char card_name[7]; | 1278 | unsigned char card_name[7]; |
1293 | unsigned char unit; | 1279 | |
1294 | |||
1295 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; | 1280 | static const unsigned char i_vmin[] = { 0, 1, 5, 10, 25, 35, 60, 100 }; |
1296 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; | 1281 | static const unsigned char i_vmax[] = { 1, 5, 10, 25, 35, 45, 80, 200 }; |
1282 | static const unsigned char *kbit_units[] = { "kBit/s", "MBit/s", "GBit/s" }; | ||
1283 | static const unsigned char *nsec_units[] = { "ns", "µs", "ms" }; | ||
1297 | 1284 | ||
1298 | card_name[6] = '\0'; | 1285 | card_name[6] = '\0'; |
1299 | 1286 | ||
@@ -1337,24 +1324,14 @@ bool dbg_mmc_info(void) | |||
1337 | } | 1324 | } |
1338 | else /* Technical details */ | 1325 | else /* Technical details */ |
1339 | { | 1326 | { |
1340 | value = card->speed / 100; | 1327 | output_dyn_value(pbuf2, sizeof pbuf2, card->speed / 1000, |
1341 | unit = prep_value_unit(&value, "kMG"); | 1328 | kbit_units, false); |
1342 | if (value < 100) | 1329 | snprintf(pbuf, sizeof pbuf, "Speed: %s", pbuf2); |
1343 | snprintf(pbuf, sizeof(pbuf), "Speed: %d.%01d %cBit/s", | ||
1344 | (int)(value / 10), (int)(value % 10), unit); | ||
1345 | else | ||
1346 | snprintf(pbuf, sizeof(pbuf), "Speed: %d %cBit/s", | ||
1347 | (int)(value / 10), unit); | ||
1348 | lcd_puts(0, 1, pbuf); | 1330 | lcd_puts(0, 1, pbuf); |
1349 | 1331 | ||
1350 | value = card->tsac; | 1332 | output_dyn_value(pbuf2, sizeof pbuf2, card->tsac, |
1351 | unit = prep_value_unit(&value, "nµm"); | 1333 | nsec_units, false); |
1352 | if (value < 100) | 1334 | snprintf(pbuf, sizeof pbuf, "Tsac: %s", pbuf2); |
1353 | snprintf(pbuf, sizeof(pbuf), "Tsac: %d.%01d %cs", | ||
1354 | (int)(value / 10), (int)(value % 10), unit); | ||
1355 | else | ||
1356 | snprintf(pbuf, sizeof(pbuf), "Tsac: %d %cs", | ||
1357 | (int)(value / 10), unit); | ||
1358 | lcd_puts(0, 2, pbuf); | 1335 | lcd_puts(0, 2, pbuf); |
1359 | 1336 | ||
1360 | snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); | 1337 | snprintf(pbuf, sizeof(pbuf), "Nsac: %d clk", card->nsac); |
diff --git a/apps/lang/deutsch.lang b/apps/lang/deutsch.lang index c5f8d9dd64..7fd32914a2 100644 --- a/apps/lang/deutsch.lang +++ b/apps/lang/deutsch.lang | |||
@@ -985,16 +985,16 @@ voice: "Aufnahmeeinstellungen" | |||
985 | new: "Aufnahmeeinstellungen" | 985 | new: "Aufnahmeeinstellungen" |
986 | 986 | ||
987 | id: LANG_DISK_STAT | 987 | id: LANG_DISK_STAT |
988 | desc: disk size info | 988 | desc: DEPRECATED |
989 | eng: "Disk: %d.%dGB" | 989 | eng: "" |
990 | voice: "" | 990 | voice: "" |
991 | new: "HDD: %d,%dGB" | 991 | new: |
992 | 992 | ||
993 | id: LANG_DISK_FREE_STAT | 993 | id: LANG_DISK_FREE_STAT |
994 | desc: disk size info | 994 | desc: DEPRECATED |
995 | eng: "Free: %d.%dGB" | 995 | eng: "" |
996 | voice: "Freier Plattenplatz:" | 996 | voice: "" |
997 | new: "Frei: %d,%dGB" | 997 | new: |
998 | 998 | ||
999 | id: LANG_POWEROFF | 999 | id: LANG_POWEROFF |
1000 | desc: disk poweroff flag | 1000 | desc: disk poweroff flag |
@@ -2256,9 +2256,9 @@ voice: "Plus" | |||
2256 | new: | 2256 | new: |
2257 | 2257 | ||
2258 | id: VOICE_POINT | 2258 | id: VOICE_POINT |
2259 | desc: spoken only, decimal separator for composing numbers | 2259 | desc: DEPRECATED |
2260 | eng: "" | 2260 | eng: "" |
2261 | voice: "Komma" | 2261 | voice: "" |
2262 | new: | 2262 | new: |
2263 | 2263 | ||
2264 | id: VOICE_MILLISECONDS | 2264 | id: VOICE_MILLISECONDS |
@@ -2322,15 +2322,15 @@ voice: "Prozent" | |||
2322 | new: | 2322 | new: |
2323 | 2323 | ||
2324 | id: VOICE_MEGABYTE | 2324 | id: VOICE_MEGABYTE |
2325 | desc: spoken only, a unit postfix | 2325 | desc: DEPRECATED |
2326 | eng: "" | 2326 | eng: "" |
2327 | voice: "Megabyte" | 2327 | voice: "" |
2328 | new: | 2328 | new: |
2329 | 2329 | ||
2330 | id: VOICE_GIGABYTE | 2330 | id: VOICE_GIGABYTE |
2331 | desc: spoken only, a unit postfix | 2331 | desc: DEPRECATED |
2332 | eng: "" | 2332 | eng: "" |
2333 | voice: "Gigabyte" | 2333 | voice: "" |
2334 | new: | 2334 | new: |
2335 | 2335 | ||
2336 | id: VOICE_MILLIAMPHOURS | 2336 | id: VOICE_MILLIAMPHOURS |
@@ -2929,3 +2929,46 @@ desc: in battery settings | |||
2929 | eng: "NiMH" | 2929 | eng: "NiMH" |
2930 | voice: "Nickel-Metallhydrid" | 2930 | voice: "Nickel-Metallhydrid" |
2931 | new: "NiMH" | 2931 | new: "NiMH" |
2932 | |||
2933 | id: LANG_POINT | ||
2934 | desc: decimal separator for composing numbers | ||
2935 | eng: "." | ||
2936 | voice: "Komma" | ||
2937 | new: "," | ||
2938 | |||
2939 | id: LANG_BYTE | ||
2940 | desc: a unit postfix | ||
2941 | eng: "B" | ||
2942 | voice: "" | ||
2943 | new: "B" | ||
2944 | |||
2945 | id: LANG_KILOBYTE | ||
2946 | desc: a unit postfix, also voiced | ||
2947 | eng: "KB" | ||
2948 | voice: "Kilobyte" | ||
2949 | new: "KB" | ||
2950 | |||
2951 | id: LANG_MEGABYTE | ||
2952 | desc: a unit postfix, also voiced | ||
2953 | eng: "MB" | ||
2954 | voice: "Megabyte" | ||
2955 | new: "MB" | ||
2956 | |||
2957 | id: LANG_GIGABYTE | ||
2958 | desc: a unit postfix, also voiced | ||
2959 | eng: "GB" | ||
2960 | voice: "Gigabyte" | ||
2961 | new: "GB" | ||
2962 | |||
2963 | id: LANG_DISK_SIZE_INFO | ||
2964 | desc: disk size info | ||
2965 | eng: "HDD:" | ||
2966 | voice: "" | ||
2967 | new: "Disk:" | ||
2968 | |||
2969 | id: LANG_DISK_FREE_INFO | ||
2970 | desc: disk size info | ||
2971 | eng: "Free:" | ||
2972 | voice: "Freier Plattenplatz:" | ||
2973 | new: "Frei:" | ||
2974 | |||
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 910bfa46fe..5323fa0625 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -998,15 +998,15 @@ voice: "Recording Settings" | |||
998 | new: | 998 | new: |
999 | 999 | ||
1000 | id: LANG_DISK_STAT | 1000 | id: LANG_DISK_STAT |
1001 | desc: disk size info | 1001 | desc: DEPRECATED |
1002 | eng: "Disk: %d.%dGB" | 1002 | eng: "" |
1003 | voice: "" | 1003 | voice: "" |
1004 | new: | 1004 | new: |
1005 | 1005 | ||
1006 | id: LANG_DISK_FREE_STAT | 1006 | id: LANG_DISK_FREE_STAT |
1007 | desc: disk size info | 1007 | desc: DEPRECATED |
1008 | eng: "Free: %d.%dGB" | 1008 | eng: "" |
1009 | voice: "Free diskspace:" | 1009 | voice: "" |
1010 | new: | 1010 | new: |
1011 | 1011 | ||
1012 | id: LANG_POWEROFF | 1012 | id: LANG_POWEROFF |
@@ -2270,9 +2270,9 @@ voice: "plus" | |||
2270 | new: | 2270 | new: |
2271 | 2271 | ||
2272 | id: VOICE_POINT | 2272 | id: VOICE_POINT |
2273 | desc: spoken only, decimal separator for composing numbers | 2273 | desc: DEPRECATED |
2274 | eng: "" | 2274 | eng: "" |
2275 | voice: "point" | 2275 | voice: "" |
2276 | new: | 2276 | new: |
2277 | 2277 | ||
2278 | id: VOICE_MILLISECONDS | 2278 | id: VOICE_MILLISECONDS |
@@ -2336,15 +2336,15 @@ voice: "percent" | |||
2336 | new: | 2336 | new: |
2337 | 2337 | ||
2338 | id: VOICE_MEGABYTE | 2338 | id: VOICE_MEGABYTE |
2339 | desc: spoken only, a unit postfix, currently not used | 2339 | desc: DEPRECATED |
2340 | eng: "" | 2340 | eng: "" |
2341 | voice: "megabyte" | 2341 | voice: "" |
2342 | new: | 2342 | new: |
2343 | 2343 | ||
2344 | id: VOICE_GIGABYTE | 2344 | id: VOICE_GIGABYTE |
2345 | desc: spoken only, a unit postfix | 2345 | desc: DEPRECATED |
2346 | eng: "" | 2346 | eng: "" |
2347 | voice: "gigabyte" | 2347 | voice: "" |
2348 | new: | 2348 | new: |
2349 | 2349 | ||
2350 | id: VOICE_MILLIAMPHOURS | 2350 | id: VOICE_MILLIAMPHOURS |
@@ -2943,3 +2943,46 @@ desc: in battery settings | |||
2943 | eng: "NiMH" | 2943 | eng: "NiMH" |
2944 | voice: "Nickel metal hydride" | 2944 | voice: "Nickel metal hydride" |
2945 | new: | 2945 | new: |
2946 | |||
2947 | id: LANG_POINT | ||
2948 | desc: decimal separator for composing numbers | ||
2949 | eng: "." | ||
2950 | voice: "point" | ||
2951 | new: | ||
2952 | |||
2953 | id: LANG_BYTE | ||
2954 | desc: a unit postfix | ||
2955 | eng: "B" | ||
2956 | voice: "" | ||
2957 | new: | ||
2958 | |||
2959 | id: LANG_KILOBYTE | ||
2960 | desc: a unit postfix, also voiced | ||
2961 | eng: "KB" | ||
2962 | voice: "kilobyte" | ||
2963 | new: | ||
2964 | |||
2965 | id: LANG_MEGABYTE | ||
2966 | desc: a unit postfix, also voiced | ||
2967 | eng: "MB" | ||
2968 | voice: "megabyte" | ||
2969 | new: | ||
2970 | |||
2971 | id: LANG_GIGABYTE | ||
2972 | desc: a unit postfix, also voiced | ||
2973 | eng: "GB" | ||
2974 | voice: "gigabyte" | ||
2975 | new: | ||
2976 | |||
2977 | id: LANG_DISK_SIZE_INFO | ||
2978 | desc: disk size info | ||
2979 | eng: "Disk:" | ||
2980 | voice: "" | ||
2981 | new: | ||
2982 | |||
2983 | id: LANG_DISK_FREE_INFO | ||
2984 | desc: disk size info | ||
2985 | eng: "Free:" | ||
2986 | voice: "Free diskspace:" | ||
2987 | new: | ||
2988 | |||
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 |
138 | bool show_info(void) | 138 | bool 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(); |
diff --git a/apps/misc.c b/apps/misc.c index b4a21a1dac..1024f9bb80 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include "system.h" | 28 | #include "system.h" |
29 | #include "timefuncs.h" | 29 | #include "timefuncs.h" |
30 | #include "screens.h" | 30 | #include "screens.h" |
31 | #include "talk.h" | ||
31 | #include "mpeg.h" | 32 | #include "mpeg.h" |
32 | #include "mp3_playback.h" | 33 | #include "mp3_playback.h" |
33 | #include "settings.h" | 34 | #include "settings.h" |
@@ -42,33 +43,67 @@ | |||
42 | #define ONE_KILOBYTE 1024 | 43 | #define ONE_KILOBYTE 1024 |
43 | #define ONE_MEGABYTE (1024*1024) | 44 | #define ONE_MEGABYTE (1024*1024) |
44 | 45 | ||
45 | /* The point of this function would be to return a string of the input data, | 46 | /* Format a large-range value for output, using the appropriate unit so that |
46 | but never longer than 5 columns. Add suffix k and M when suitable... | 47 | * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" |
47 | Make sure to have space for 6 bytes in the buffer. 5 letters plus the | 48 | * units) if possible, and 3 significant digits are shown. If a buffer is |
48 | terminating zero byte. */ | 49 | * given, the result is snprintf()'d into that buffer, otherwise the result is |
49 | char *num2max5(unsigned int bytes, char *max5) | 50 | * voiced.*/ |
51 | char *output_dyn_value(char *buf, int buf_size, int value, | ||
52 | const unsigned char **units, bool bin_scale) | ||
50 | { | 53 | { |
51 | if(bytes < 100000) { | 54 | int scale = bin_scale ? 1024 : 1000; |
52 | snprintf(max5, 6, "%5d", bytes); | 55 | int fraction = 0; |
53 | return max5; | 56 | int unit_no = 0; |
57 | char tbuf[5]; | ||
58 | |||
59 | while (value >= scale) | ||
60 | { | ||
61 | fraction = value % scale; | ||
62 | value /= scale; | ||
63 | unit_no++; | ||
54 | } | 64 | } |
55 | if(bytes < (9999*ONE_KILOBYTE)) { | 65 | if (bin_scale) |
56 | snprintf(max5, 6, "%4dk", bytes/ONE_KILOBYTE); | 66 | fraction = fraction * 1000 / 1024; |
57 | return max5; | 67 | |
68 | if (buf) | ||
69 | { | ||
70 | if (value >= 100 || !unit_no) | ||
71 | snprintf(tbuf, sizeof(tbuf), "%d", value); | ||
72 | else if (value >= 10) | ||
73 | snprintf(tbuf, sizeof(tbuf), "%d%s%01d", value, str(LANG_POINT), | ||
74 | fraction / 100); | ||
75 | else | ||
76 | snprintf(tbuf, sizeof(tbuf), "%d%s%02d", value, str(LANG_POINT), | ||
77 | fraction / 10); | ||
78 | |||
79 | snprintf(buf, buf_size, "%s %s", tbuf, P2STR(units[unit_no])); | ||
58 | } | 80 | } |
59 | if(bytes < (100*ONE_MEGABYTE)) { | 81 | else |
60 | /* 'XX.XM' is good as long as we're less than 100 megs */ | 82 | { |
61 | snprintf(max5, 6, "%2d.%0dM", | 83 | if (value >= 100 || !unit_no) |
62 | bytes/ONE_MEGABYTE, | 84 | tbuf[0] = '\0'; |
63 | (bytes%ONE_MEGABYTE)/(ONE_MEGABYTE/10) ); | 85 | else if (value >= 10) |
64 | return max5; | 86 | snprintf(tbuf, sizeof(tbuf), "%01d", fraction / 100); |
87 | else | ||
88 | snprintf(tbuf, sizeof(tbuf), "%02d", fraction / 10); | ||
89 | |||
90 | /* strip trailing zeros from the fraction */ | ||
91 | for (i = strlen(tbuf) - 1; (i >= 0) && (tbuf[i] == '0'); i--) | ||
92 | tbuf[i] = '\0'; | ||
93 | |||
94 | talk_number(value, true); | ||
95 | if (strlen(tbuf)) | ||
96 | { | ||
97 | talk_id(LANG_POINT, true); | ||
98 | talk_spell(tbuf, true); | ||
99 | } | ||
100 | talk_id(P2ID(units[unit_no]), true); | ||
65 | } | 101 | } |
66 | snprintf(max5, 6, "%4dM", bytes/ONE_MEGABYTE); | 102 | return buf; |
67 | return max5; | ||
68 | } | 103 | } |
69 | 104 | ||
70 | /* Read (up to) a line of text from fd into buffer and return number of bytes | 105 | /* Read (up to) a line of text from fd into buffer and return number of bytes |
71 | * read (which may be larger than the number of bytes stored in buffer). If | 106 | * read (which may be larger than the number of bytes stored in buffer). If |
72 | * an error occurs, -1 is returned (and buffer contains whatever could be | 107 | * an error occurs, -1 is returned (and buffer contains whatever could be |
73 | * read). A line is terminated by a LF char. Neither LF nor CR chars are | 108 | * read). A line is terminated by a LF char. Neither LF nor CR chars are |
74 | * stored in buffer. | 109 | * stored in buffer. |
diff --git a/apps/misc.h b/apps/misc.h index e31224823d..430afe1a1e 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -19,11 +19,13 @@ | |||
19 | #ifndef MISC_H | 19 | #ifndef MISC_H |
20 | #define MISC_H | 20 | #define MISC_H |
21 | 21 | ||
22 | /* The point of this function would be to return a string of the input data, | 22 | /* Format a large-range value for output, using the appropriate unit so that |
23 | but never longer than 5 columns. Add suffix k and M when suitable... | 23 | * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" |
24 | Make sure to have space for 6 bytes in the buffer. 5 letters plus the | 24 | * units) if possible, and 3 significant digits are shown. If a buffer is |
25 | terminating zero byte. */ | 25 | * given, the result is snprintf()'d into that buffer, otherwise the result is |
26 | char *num2max5(unsigned int bytes, char *max5); | 26 | * voiced.*/ |
27 | void output_dyn_value(char *buf, int buf_size, int value, | ||
28 | const unsigned char **units, bool bin_scale); | ||
27 | 29 | ||
28 | /* Read (up to) a line of text from fd into buffer and return number of bytes | 30 | /* Read (up to) a line of text from fd into buffer and return number of bytes |
29 | * read (which may be larger than the number of bytes stored in buffer). If | 31 | * read (which may be larger than the number of bytes stored in buffer). If |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 0ffa16f31b..35da6f7127 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -248,6 +248,13 @@ bool recording_screen(void) | |||
248 | bool led_state; | 248 | bool led_state; |
249 | int led_delay; | 249 | int led_delay; |
250 | 250 | ||
251 | const unsigned char *byte_units[] = { | ||
252 | ID2P(LANG_BYTE), | ||
253 | ID2P(LANG_KILOBYTE), | ||
254 | ID2P(LANG_MEGABYTE), | ||
255 | ID2P(LANG_GIGABYTE) | ||
256 | }; | ||
257 | |||
251 | cursor = 0; | 258 | cursor = 0; |
252 | mpeg_init_recording(); | 259 | mpeg_init_recording(); |
253 | 260 | ||
@@ -587,10 +594,13 @@ bool recording_screen(void) | |||
587 | dhours, dminutes); | 594 | dhours, dminutes); |
588 | } | 595 | } |
589 | else | 596 | else |
597 | { | ||
598 | output_dyn_value(buf2, sizeof buf2, | ||
599 | mpeg_num_recorded_bytes(), | ||
600 | byte_units, true); | ||
590 | snprintf(buf, 32, "%s %s", | 601 | snprintf(buf, 32, "%s %s", |
591 | str(LANG_RECORDING_SIZE), | 602 | str(LANG_RECORDING_SIZE), buf2); |
592 | num2max5(mpeg_num_recorded_bytes(), | 603 | } |
593 | buf2)); | ||
594 | } | 604 | } |
595 | lcd_puts(0, 1, buf); | 605 | lcd_puts(0, 1, buf); |
596 | 606 | ||