summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c43
-rw-r--r--apps/lang/deutsch.lang69
-rw-r--r--apps/lang/english.lang65
-rw-r--r--apps/main_menu.c29
-rw-r--r--apps/misc.c75
-rw-r--r--apps/misc.h12
-rw-r--r--apps/recorder/recording.c16
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 */
1272static 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
1285bool dbg_mmc_info(void) 1271bool 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"
985new: "Aufnahmeeinstellungen" 985new: "Aufnahmeeinstellungen"
986 986
987id: LANG_DISK_STAT 987id: LANG_DISK_STAT
988desc: disk size info 988desc: DEPRECATED
989eng: "Disk: %d.%dGB" 989eng: ""
990voice: "" 990voice: ""
991new: "HDD: %d,%dGB" 991new:
992 992
993id: LANG_DISK_FREE_STAT 993id: LANG_DISK_FREE_STAT
994desc: disk size info 994desc: DEPRECATED
995eng: "Free: %d.%dGB" 995eng: ""
996voice: "Freier Plattenplatz:" 996voice: ""
997new: "Frei: %d,%dGB" 997new:
998 998
999id: LANG_POWEROFF 999id: LANG_POWEROFF
1000desc: disk poweroff flag 1000desc: disk poweroff flag
@@ -2256,9 +2256,9 @@ voice: "Plus"
2256new: 2256new:
2257 2257
2258id: VOICE_POINT 2258id: VOICE_POINT
2259desc: spoken only, decimal separator for composing numbers 2259desc: DEPRECATED
2260eng: "" 2260eng: ""
2261voice: "Komma" 2261voice: ""
2262new: 2262new:
2263 2263
2264id: VOICE_MILLISECONDS 2264id: VOICE_MILLISECONDS
@@ -2322,15 +2322,15 @@ voice: "Prozent"
2322new: 2322new:
2323 2323
2324id: VOICE_MEGABYTE 2324id: VOICE_MEGABYTE
2325desc: spoken only, a unit postfix 2325desc: DEPRECATED
2326eng: "" 2326eng: ""
2327voice: "Megabyte" 2327voice: ""
2328new: 2328new:
2329 2329
2330id: VOICE_GIGABYTE 2330id: VOICE_GIGABYTE
2331desc: spoken only, a unit postfix 2331desc: DEPRECATED
2332eng: "" 2332eng: ""
2333voice: "Gigabyte" 2333voice: ""
2334new: 2334new:
2335 2335
2336id: VOICE_MILLIAMPHOURS 2336id: VOICE_MILLIAMPHOURS
@@ -2929,3 +2929,46 @@ desc: in battery settings
2929eng: "NiMH" 2929eng: "NiMH"
2930voice: "Nickel-Metallhydrid" 2930voice: "Nickel-Metallhydrid"
2931new: "NiMH" 2931new: "NiMH"
2932
2933id: LANG_POINT
2934desc: decimal separator for composing numbers
2935eng: "."
2936voice: "Komma"
2937new: ","
2938
2939id: LANG_BYTE
2940desc: a unit postfix
2941eng: "B"
2942voice: ""
2943new: "B"
2944
2945id: LANG_KILOBYTE
2946desc: a unit postfix, also voiced
2947eng: "KB"
2948voice: "Kilobyte"
2949new: "KB"
2950
2951id: LANG_MEGABYTE
2952desc: a unit postfix, also voiced
2953eng: "MB"
2954voice: "Megabyte"
2955new: "MB"
2956
2957id: LANG_GIGABYTE
2958desc: a unit postfix, also voiced
2959eng: "GB"
2960voice: "Gigabyte"
2961new: "GB"
2962
2963id: LANG_DISK_SIZE_INFO
2964desc: disk size info
2965eng: "HDD:"
2966voice: ""
2967new: "Disk:"
2968
2969id: LANG_DISK_FREE_INFO
2970desc: disk size info
2971eng: "Free:"
2972voice: "Freier Plattenplatz:"
2973new: "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"
998new: 998new:
999 999
1000id: LANG_DISK_STAT 1000id: LANG_DISK_STAT
1001desc: disk size info 1001desc: DEPRECATED
1002eng: "Disk: %d.%dGB" 1002eng: ""
1003voice: "" 1003voice: ""
1004new: 1004new:
1005 1005
1006id: LANG_DISK_FREE_STAT 1006id: LANG_DISK_FREE_STAT
1007desc: disk size info 1007desc: DEPRECATED
1008eng: "Free: %d.%dGB" 1008eng: ""
1009voice: "Free diskspace:" 1009voice: ""
1010new: 1010new:
1011 1011
1012id: LANG_POWEROFF 1012id: LANG_POWEROFF
@@ -2270,9 +2270,9 @@ voice: "plus"
2270new: 2270new:
2271 2271
2272id: VOICE_POINT 2272id: VOICE_POINT
2273desc: spoken only, decimal separator for composing numbers 2273desc: DEPRECATED
2274eng: "" 2274eng: ""
2275voice: "point" 2275voice: ""
2276new: 2276new:
2277 2277
2278id: VOICE_MILLISECONDS 2278id: VOICE_MILLISECONDS
@@ -2336,15 +2336,15 @@ voice: "percent"
2336new: 2336new:
2337 2337
2338id: VOICE_MEGABYTE 2338id: VOICE_MEGABYTE
2339desc: spoken only, a unit postfix, currently not used 2339desc: DEPRECATED
2340eng: "" 2340eng: ""
2341voice: "megabyte" 2341voice: ""
2342new: 2342new:
2343 2343
2344id: VOICE_GIGABYTE 2344id: VOICE_GIGABYTE
2345desc: spoken only, a unit postfix 2345desc: DEPRECATED
2346eng: "" 2346eng: ""
2347voice: "gigabyte" 2347voice: ""
2348new: 2348new:
2349 2349
2350id: VOICE_MILLIAMPHOURS 2350id: VOICE_MILLIAMPHOURS
@@ -2943,3 +2943,46 @@ desc: in battery settings
2943eng: "NiMH" 2943eng: "NiMH"
2944voice: "Nickel metal hydride" 2944voice: "Nickel metal hydride"
2945new: 2945new:
2946
2947id: LANG_POINT
2948desc: decimal separator for composing numbers
2949eng: "."
2950voice: "point"
2951new:
2952
2953id: LANG_BYTE
2954desc: a unit postfix
2955eng: "B"
2956voice: ""
2957new:
2958
2959id: LANG_KILOBYTE
2960desc: a unit postfix, also voiced
2961eng: "KB"
2962voice: "kilobyte"
2963new:
2964
2965id: LANG_MEGABYTE
2966desc: a unit postfix, also voiced
2967eng: "MB"
2968voice: "megabyte"
2969new:
2970
2971id: LANG_GIGABYTE
2972desc: a unit postfix, also voiced
2973eng: "GB"
2974voice: "gigabyte"
2975new:
2976
2977id: LANG_DISK_SIZE_INFO
2978desc: disk size info
2979eng: "Disk:"
2980voice: ""
2981new:
2982
2983id: LANG_DISK_FREE_INFO
2984desc: disk size info
2985eng: "Free:"
2986voice: "Free diskspace:"
2987new:
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
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();
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
49char *num2max5(unsigned int bytes, char *max5) 50 * voiced.*/
51char *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
26char *num2max5(unsigned int bytes, char *max5); 26 * voiced.*/
27void 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