summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2017-09-18 06:00:05 -0400
committerMichael Sevakis <jethead71@rockbox.org>2017-11-21 05:01:14 -0500
commitaced667f48c29a160aa4e5c0a8df037092b28189 (patch)
tree66e48e4a27daaf36f01d7ff1ed6876a7de38b0c0 /apps
parent5c9688961ef9166cec5225db50d5f73691d8292d (diff)
downloadrockbox-aced667f48c29a160aa4e5c0a8df037092b28189.tar.gz
rockbox-aced667f48c29a160aa4e5c0a8df037092b28189.zip
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting limitations. I checked grep output for whatever appeared to fit but it's possible I missed some instances because they weren't so obvious. Also, this means sound settings can dynamically work with any number of decimals rather than the current assumption of one or two. Add an ipow() function to help and take advantage of dynamic field width and precision. Consolidate string formatting of sound settings. Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c60
-rw-r--r--apps/gui/option_select.c20
-rw-r--r--apps/gui/skin_engine/skin_tokens.c21
-rw-r--r--apps/misc.c38
-rw-r--r--apps/misc.h2
-rw-r--r--apps/plugins/doom/hu_stuff.c8
-rw-r--r--apps/plugins/doom/wi_stuff.c9
-rw-r--r--apps/plugins/otp.c22
-rw-r--r--apps/recorder/recording.c32
9 files changed, 77 insertions, 135 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index a7dc764523..4af17700c9 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1053,9 +1053,10 @@ static bool view_battery(void)
1053 1053
1054 st = power_input_status() & 1054 st = power_input_status() &
1055 (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY); 1055 (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY);
1056 lcd_putsf(0, line++, "%s%s", 1056
1057 (st & POWER_INPUT_MAIN_CHARGER) ? " Main" : "", 1057 lcd_putsf(0, line++, "%.*s%.*s",
1058 (st & POWER_INPUT_USB_CHARGER) ? " USB" : ""); 1058 !!(st & POWER_INPUT_MAIN_CHARGER)*5, " Main",
1059 !!(st & POWER_INPUT_USB_CHARGER)*4, " USB");
1059 1060
1060 y = ARRAYLEN(chrgstate_strings) - 1; 1061 y = ARRAYLEN(chrgstate_strings) - 1;
1061 1062
@@ -1084,22 +1085,18 @@ static bool view_battery(void)
1084 y / 1000, y % 1000); 1085 y / 1000, y % 1000);
1085 1086
1086 y = battery_adc_charge_current(); 1087 y = battery_adc_charge_current();
1087 if (y < 0) x = '-', y = -y; 1088 lcd_putsf(0, line++, "CHRGISN:% d mA", y);
1088 else x = ' ';
1089 lcd_putsf(0, line++, "CHRGISN:%c%d mA", x, y);
1090 1089
1091 y = cccv_regulator_dissipation(); 1090 y = cccv_regulator_dissipation();
1092 lcd_putsf(0, line++, "P CCCV : %d mW", y); 1091 lcd_putsf(0, line++, "P CCCV : %d mW", y);
1093 1092
1094 y = battery_charge_current(); 1093 y = battery_charge_current();
1095 if (y < 0) x = '-', y = -y; 1094 lcd_putsf(0, line++, "I Charge:% d mA", y);
1096 else x = ' ';
1097 lcd_putsf(0, line++, "I Charge:%c%d mA", x, y);
1098 1095
1099 y = battery_adc_temp(); 1096 y = battery_adc_temp();
1100 1097
1101 if (y != INT_MIN) { 1098 if (y != INT_MIN) {
1102 lcd_putsf(0, line++, "T Battery: %dC (%dF)", y, 1099 lcd_putsf(0, line++, "T Battery: %d\u00b0C (%d\u00b0F)", y,
1103 (9*y + 160) / 5); 1100 (9*y + 160) / 5);
1104 } else { 1101 } else {
1105 /* Conversion disabled */ 1102 /* Conversion disabled */
@@ -1371,6 +1368,8 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1371#elif (CONFIG_STORAGE & STORAGE_ATA) 1368#elif (CONFIG_STORAGE & STORAGE_ATA)
1372static int disk_callback(int btn, struct gui_synclist *lists) 1369static int disk_callback(int btn, struct gui_synclist *lists)
1373{ 1370{
1371 static const char atanums[] = { " 0 1 2 3 4 5 6" };
1372
1374 (void)lists; 1373 (void)lists;
1375 int i; 1374 int i;
1376 char buf[128]; 1375 char buf[128];
@@ -1414,12 +1413,10 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1414 "Read-ahead: %s", i ? "enabled" : "unsupported"); 1413 "Read-ahead: %s", i ? "enabled" : "unsupported");
1415 timing_info_present = identify_info[53] & (1<<1); 1414 timing_info_present = identify_info[53] & (1<<1);
1416 if(timing_info_present) { 1415 if(timing_info_present) {
1417 char pio3[2], pio4[2];pio3[1] = 0;
1418 pio4[1] = 0;
1419 pio3[0] = (identify_info[64] & (1<<0)) ? '3' : 0;
1420 pio4[0] = (identify_info[64] & (1<<1)) ? '4' : 0;
1421 simplelist_addline( 1416 simplelist_addline(
1422 "PIO modes: 0 1 2 %s %s", pio3, pio4); 1417 "PIO modes: 0 1 2%.*s%.*s",
1418 (identify_info[64] & (1<<0)) << 1, &atanums[3*2],
1419 (identify_info[64] & (1<<1)) , &atanums[4*2]);
1423 } 1420 }
1424 else { 1421 else {
1425 simplelist_addline( 1422 simplelist_addline(
@@ -1442,13 +1439,11 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1442 "Physical sector size: %d", sector_size); 1439 "Physical sector size: %d", sector_size);
1443#ifdef HAVE_ATA_DMA 1440#ifdef HAVE_ATA_DMA
1444 if (identify_info[63] & (1<<0)) { 1441 if (identify_info[63] & (1<<0)) {
1445 char mdma0[2], mdma1[2], mdma2[2];
1446 mdma0[1] = mdma1[1] = mdma2[1] = 0;
1447 mdma0[0] = (identify_info[63] & (1<<0)) ? '0' : 0;
1448 mdma1[0] = (identify_info[63] & (1<<1)) ? '1' : 0;
1449 mdma2[0] = (identify_info[63] & (1<<2)) ? '2' : 0;
1450 simplelist_addline( 1442 simplelist_addline(
1451 "MDMA modes: %s %s %s", mdma0, mdma1, mdma2); 1443 "MDMA modes:%.*s%.*s%.*s",
1444 (identify_info[63] & (1<<0)) << 1, &atanums[0*2],
1445 (identify_info[63] & (1<<1)) , &atanums[1*2],
1446 (identify_info[63] & (1<<2)) >> 1, &atanums[2*2]);
1452 simplelist_addline( 1447 simplelist_addline(
1453 "MDMA Cycle times %dns/%dns", 1448 "MDMA Cycle times %dns/%dns",
1454 identify_info[65], 1449 identify_info[65],
@@ -1459,18 +1454,15 @@ static int disk_callback(int btn, struct gui_synclist *lists)
1459 "No MDMA mode info"); 1454 "No MDMA mode info");
1460 } 1455 }
1461 if (identify_info[53] & (1<<2)) { 1456 if (identify_info[53] & (1<<2)) {
1462 char udma0[2], udma1[2], udma2[2], udma3[2], udma4[2], udma5[2], udma6[2];
1463 udma0[1] = udma1[1] = udma2[1] = udma3[1] = udma4[1] = udma5[1] = udma6[1] = 0;
1464 udma0[0] = (identify_info[88] & (1<<0)) ? '0' : 0;
1465 udma1[0] = (identify_info[88] & (1<<1)) ? '1' : 0;
1466 udma2[0] = (identify_info[88] & (1<<2)) ? '2' : 0;
1467 udma3[0] = (identify_info[88] & (1<<3)) ? '3' : 0;
1468 udma4[0] = (identify_info[88] & (1<<4)) ? '4' : 0;
1469 udma5[0] = (identify_info[88] & (1<<5)) ? '5' : 0;
1470 udma6[0] = (identify_info[88] & (1<<6)) ? '6' : 0;
1471 simplelist_addline( 1457 simplelist_addline(
1472 "UDMA modes: %s %s %s %s %s %s %s", udma0, udma1, udma2, 1458 "UDMA modes:%.*s%.*s%.*s%.*s%.*s%.*s%.*s",
1473 udma3, udma4, udma5, udma6); 1459 (identify_info[88] & (1<<0)) << 1, &atanums[0*2],
1460 (identify_info[88] & (1<<1)) , &atanums[1*2],
1461 (identify_info[88] & (1<<2)) >> 1, &atanums[2*2],
1462 (identify_info[88] & (1<<3)) >> 2, &atanums[3*2],
1463 (identify_info[88] & (1<<4)) >> 3, &atanums[4*2],
1464 (identify_info[88] & (1<<5)) >> 4, &atanums[5*2],
1465 (identify_info[88] & (1<<6)) >> 5, &atanums[6*2]);
1474 } 1466 }
1475 else { 1467 else {
1476 simplelist_addline( 1468 simplelist_addline(
@@ -1691,7 +1683,7 @@ static int ata_smart_callback(int btn, struct gui_synclist *lists)
1691 } 1683 }
1692 else 1684 else
1693 { 1685 {
1694 simplelist_addline("ATA SMART error: 0x%x", rc); 1686 simplelist_addline("ATA SMART error: %#x", rc);
1695 } 1687 }
1696 read_done = true; 1688 read_done = true;
1697 } 1689 }
@@ -2165,7 +2157,7 @@ static int radio_callback(int btn, struct gui_synclist *lists)
2165 2157
2166 tuner_get_rds_info(RADIO_RDS_NAME, buf, sizeof (buf)); 2158 tuner_get_rds_info(RADIO_RDS_NAME, buf, sizeof (buf));
2167 tuner_get_rds_info(RADIO_RDS_PROGRAM_INFO, &pi, sizeof (pi)); 2159 tuner_get_rds_info(RADIO_RDS_PROGRAM_INFO, &pi, sizeof (pi));
2168 simplelist_addline("PI:%04X PS:'%8s'", pi, buf); 2160 simplelist_addline("PI:%04X PS:'%-8s'", pi, buf);
2169 tuner_get_rds_info(RADIO_RDS_TEXT, buf, sizeof (buf)); 2161 tuner_get_rds_info(RADIO_RDS_TEXT, buf, sizeof (buf));
2170 simplelist_addline("RT:%s", buf); 2162 simplelist_addline("RT:%s", buf);
2171 tuner_get_rds_info(RADIO_RDS_CURRENT_TIME, &seconds, sizeof (seconds)); 2163 tuner_get_rds_info(RADIO_RDS_CURRENT_TIME, &seconds, sizeof (seconds));
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 0452467994..f99e833a1e 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -106,23 +106,9 @@ const char *option_get_valuestring(const struct settings_list *setting,
106 } 106 }
107 else if ((setting->flags & F_T_SOUND) == F_T_SOUND) 107 else if ((setting->flags & F_T_SOUND) == F_T_SOUND)
108 { 108 {
109 char sign = ' '; 109 format_sound_value(buffer, buf_len,
110 const char *unit = sound_unit(setting->sound_setting->setting); 110 setting->sound_setting->setting,
111 int val = sound_val2phys(setting->sound_setting->setting, (int)temp_var); 111 temp_var);
112 if (sound_numdecimals(setting->sound_setting->setting))
113 {
114 int integer, dec;
115 if(val < 0)
116 {
117 sign = '-';
118 val = abs(val);
119 }
120 integer = val / 10;
121 dec = val % 10;
122 snprintf(buffer, buf_len, "%c%d.%d %s", sign, integer, dec, unit);
123 }
124 else
125 snprintf(buffer, buf_len, "%d %s", val, unit);
126 } 112 }
127 else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING) 113 else if ((setting->flags & F_CHOICE_SETTING) == F_CHOICE_SETTING)
128 { 114 {
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index cbf732fe10..1cff83eb9a 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -70,6 +70,7 @@
70#if CONFIG_TUNER 70#if CONFIG_TUNER
71#include "radio.h" 71#include "radio.h"
72#include "tuner.h" 72#include "tuner.h"
73#include "fixedpoint.h"
73#endif 74#endif
74#include "list.h" 75#include "list.h"
75 76
@@ -432,23 +433,11 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
432/* Returns buf */ 433/* Returns buf */
433static char *format_freq_MHz(int freq, int freq_step, char *buf, int buf_size) 434static char *format_freq_MHz(int freq, int freq_step, char *buf, int buf_size)
434{ 435{
435 int scale, div; 436 int decimals = (freq_step < 100000) + 1;
436 char *fmt; 437 int scale = ipow(10, 6 - decimals);
437 if (freq_step < 100000) 438 int div = 1000000 / scale;
438 {
439 /* Format with two digits after decimal point */
440 scale = 10000;
441 fmt = "%d.%02d";
442 }
443 else
444 {
445 /* Format with one digit after decimal point */
446 scale = 100000;
447 fmt = "%d.%d";
448 }
449 div = 1000000 / scale;
450 freq = freq / scale; 439 freq = freq / scale;
451 snprintf(buf, buf_size, fmt, freq/div, freq%div); 440 snprintf(buf, buf_size, "%d.%.*d", freq/div, decimals, freq%div);
452 return buf; 441 return buf;
453} 442}
454 443
diff --git a/apps/misc.c b/apps/misc.c
index 3fdcab85e6..bfe3e990f5 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -62,6 +62,7 @@
62#include "yesno.h" 62#include "yesno.h"
63#include "viewport.h" 63#include "viewport.h"
64#include "list.h" 64#include "list.h"
65#include "fixedpoint.h"
65 66
66#include "debug.h" 67#include "debug.h"
67 68
@@ -1060,21 +1061,13 @@ char* skip_whitespace(char* const str)
1060 */ 1061 */
1061void format_time(char* buf, int buf_size, long t) 1062void format_time(char* buf, int buf_size, long t)
1062{ 1063{
1063 int const time = abs(t / 1000); 1064 unsigned long time = labs(t / 1000);
1064 int const hours = time / 3600; 1065 unsigned long hours = time / 3600;
1065 int const minutes = time / 60 - hours * 60; 1066 unsigned long minutes = time / 60 - hours * 60;
1066 int const seconds = time % 60; 1067 unsigned long seconds = time % 60;
1067 const char * const sign = &"-"[t < 0 ? 0 : 1]; 1068 int hashours = hours > 0;
1068 1069 snprintf(buf, buf_size, "%.*s%.0lu%.*s%.*lu:%.2lu",
1069 if ( hours == 0 ) 1070 t < 0, "-", hours, hashours, ":", hashours+1, minutes, seconds);
1070 {
1071 snprintf(buf, buf_size, "%s%d:%02d", sign, minutes, seconds);
1072 }
1073 else
1074 {
1075 snprintf(buf, buf_size, "%s%d:%02d:%02d", sign, hours, minutes,
1076 seconds);
1077 }
1078} 1071}
1079 1072
1080/** 1073/**
@@ -1260,3 +1253,18 @@ enum current_activity get_current_activity(void)
1260} 1253}
1261 1254
1262#endif 1255#endif
1256
1257/* format a sound value like: -1.05 dB */
1258int format_sound_value(char *buf, size_t size, int snd, int val)
1259{
1260 int numdec = sound_numdecimals(snd);
1261 const char *unit = sound_unit(snd);
1262 int physval = sound_val2phys(snd, val);
1263
1264 unsigned int factor = ipow(10, numdec);
1265 unsigned int av = abs(physval);
1266 unsigned int i = av / factor;
1267 unsigned int d = av - i*factor;
1268 return snprintf(buf, size, "%c%u%.*s%.*u %s", " -"[physval < 0],
1269 i, numdec, ".", numdec, d, unit);
1270}
diff --git a/apps/misc.h b/apps/misc.h
index 0d4cba6cd3..b13c0b15c6 100644
--- a/apps/misc.h
+++ b/apps/misc.h
@@ -167,5 +167,7 @@ void push_current_activity(enum current_activity screen);
167void pop_current_activity(void); 167void pop_current_activity(void);
168enum current_activity get_current_activity(void); 168enum current_activity get_current_activity(void);
169 169
170/* format a sound value like: -1.05 dB */
171int format_sound_value(char *buf, size_t len, int snd, int val);
170 172
171#endif /* MISC_H */ 173#endif /* MISC_H */
diff --git a/apps/plugins/doom/hu_stuff.c b/apps/plugins/doom/hu_stuff.c
index 639c963f72..6a1b07b238 100644
--- a/apps/plugins/doom/hu_stuff.c
+++ b/apps/plugins/doom/hu_stuff.c
@@ -311,14 +311,14 @@ void HU_Init(void)
311 { 311 {
312 snprintf(buffer, sizeof(buffer), "DIG%d",j-48); 312 snprintf(buffer, sizeof(buffer), "DIG%d",j-48);
313 R_SetPatchNum(hu_font2 +i, buffer); 313 R_SetPatchNum(hu_font2 +i, buffer);
314 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 314 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
315 R_SetPatchNum(&hu_font[i], buffer); 315 R_SetPatchNum(&hu_font[i], buffer);
316 } 316 }
317 else if ('A'<=j && j<='Z') 317 else if ('A'<=j && j<='Z')
318 { 318 {
319 snprintf(buffer, sizeof(buffer), "DIG%c",j); 319 snprintf(buffer, sizeof(buffer), "DIG%c",j);
320 R_SetPatchNum(hu_font2 +i, buffer); 320 R_SetPatchNum(hu_font2 +i, buffer);
321 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 321 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
322 R_SetPatchNum(&hu_font[i], buffer); 322 R_SetPatchNum(&hu_font[i], buffer);
323 } 323 }
324 else if (j=='-') 324 else if (j=='-')
@@ -348,14 +348,14 @@ void HU_Init(void)
348 } 348 }
349 else if (j<97) 349 else if (j<97)
350 { 350 {
351 snprintf(buffer, sizeof(buffer), "STCFN%s%d", (j/10>0?"0":"00"), j); //NOTE ROCKHACK: "STCFN%.3d" 351 snprintf(buffer, sizeof(buffer), "STCFN%.3d", j);
352 R_SetPatchNum(hu_font2 +i, buffer); 352 R_SetPatchNum(hu_font2 +i, buffer);
353 R_SetPatchNum(&hu_font[i], buffer); 353 R_SetPatchNum(&hu_font[i], buffer);
354 //jff 2/23/98 make all font chars defined, useful or not 354 //jff 2/23/98 make all font chars defined, useful or not
355 } 355 }
356 else if (j>122) 356 else if (j>122)
357 { 357 {
358 snprintf(buffer, sizeof(buffer), "STBR%d", j); //NOTE: "STBR%.3d" 358 snprintf(buffer, sizeof(buffer), "STBR%.3d", j);
359 R_SetPatchNum(hu_font2 +i, buffer); 359 R_SetPatchNum(hu_font2 +i, buffer);
360 R_SetPatchNum(&hu_font[i], buffer); 360 R_SetPatchNum(&hu_font[i], buffer);
361 } 361 }
diff --git a/apps/plugins/doom/wi_stuff.c b/apps/plugins/doom/wi_stuff.c
index 7c7831d084..b73839f55b 100644
--- a/apps/plugins/doom/wi_stuff.c
+++ b/apps/plugins/doom/wi_stuff.c
@@ -397,8 +397,7 @@ void WI_unloadData(void);
397void WI_levelNameLump(int epis, int map, char* buf, int bsize) 397void WI_levelNameLump(int epis, int map, char* buf, int bsize)
398{ 398{
399 if (gamemode == commercial) { 399 if (gamemode == commercial) {
400 snprintf(buf, bsize,"CWILV%s%d",(map/10>0?"":"0"), map); //ANOTHER ROCKHACK "CWILV%2.2d" 400 snprintf(buf,bsize, "CWILV%2.2d", map);
401 //snprintf(buf,bsize, "CWILV%2.2d", map);
402 } else { 401 } else {
403 snprintf(buf,bsize, "WILV%d%d", epis, map); 402 snprintf(buf,bsize, "WILV%d%d", epis, map);
404 } 403 }
@@ -1829,8 +1828,7 @@ void WI_loadData(void)
1829 if (wbs->epsd != 1 || j != 8) 1828 if (wbs->epsd != 1 || j != 8)
1830 { 1829 {
1831 // animations 1830 // animations
1832 snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK 1831 snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
1833 //snprintf(name, sizeof(name),"WIA%d%.2d%.2d", wbs->epsd, j, i);
1834 a->p[i] = W_CacheLumpName(name); 1832 a->p[i] = W_CacheLumpName(name);
1835 } 1833 }
1836 else 1834 else
@@ -1872,8 +1870,7 @@ void WI_unloadData(void)
1872 // MONDO HACK! 1870 // MONDO HACK!
1873 if (wbs->epsd != 1 || j != 8) { 1871 if (wbs->epsd != 1 || j != 8) {
1874 // animations 1872 // animations
1875 snprintf(name, sizeof(name),"WIA%d%s%d%s%d", wbs->epsd, (j/10>0?"":"0"), j,(i/10>0?"":"0"), i); //ANOTHER ROCKHACK 1873 snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
1876 //snprintf(name,sizeof(name), "WIA%d%.2d%.2d", wbs->epsd, j, i);
1877 W_UnlockLumpName(name); 1874 W_UnlockLumpName(name);
1878 } 1875 }
1879 } 1876 }
diff --git a/apps/plugins/otp.c b/apps/plugins/otp.c
index 69cb8b7982..6dece4ad38 100644
--- a/apps/plugins/otp.c
+++ b/apps/plugins/otp.c
@@ -516,25 +516,23 @@ static void add_acct(void)
516 516
517static void show_code(int acct) 517static void show_code(int acct)
518{ 518{
519 /* rockbox's printf doesn't support a variable field width afaik */
520 char format_buf[64];
521 if(!accounts[acct].is_totp) 519 if(!accounts[acct].is_totp)
522 { 520 {
523 rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd", accounts[acct].digits); 521 rb->splashf(0, "%0*d", accounts[acct].digits,
524 rb->splashf(0, format_buf, HOTP(accounts[acct].secret, 522 HOTP(accounts[acct].secret,
525 accounts[acct].sec_len, 523 accounts[acct].sec_len,
526 accounts[acct].hotp_counter, 524 accounts[acct].hotp_counter,
527 accounts[acct].digits)); 525 accounts[acct].digits));
528 ++accounts[acct].hotp_counter; 526 ++accounts[acct].hotp_counter;
529 } 527 }
530#if CONFIG_RTC 528#if CONFIG_RTC
531 else 529 else
532 { 530 {
533 rb->snprintf(format_buf, sizeof(format_buf), "%%0%dd (%%ld second(s) left)", accounts[acct].digits); 531 rb->splashf(0, "%0*d (%ld seconds(s) left)", accounts[acct].digits,
534 rb->splashf(0, format_buf, TOTP(accounts[acct].secret, 532 TOTP(accounts[acct].secret,
535 accounts[acct].sec_len, 533 accounts[acct].sec_len,
536 accounts[acct].totp_period, 534 accounts[acct].totp_period,
537 accounts[acct].digits), 535 accounts[acct].digits),
538 accounts[acct].totp_period - get_utc() % accounts[acct].totp_period); 536 accounts[acct].totp_period - get_utc() % accounts[acct].totp_period);
539 } 537 }
540#else 538#else
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 4816b3bad4..7357b469f4 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -548,39 +548,9 @@ static void auto_gain_control(int *peak_l, int *peak_r, int *balance)
548} 548}
549#endif /* HAVE_AGC */ 549#endif /* HAVE_AGC */
550 550
551static const char* const fmtstr[] =
552{
553 "%c%d %s", /* no decimals */
554 "%c%d.%d %s ", /* 1 decimal */
555 "%c%d.%02d %s " /* 2 decimals */
556};
557
558static const char factor[] = {1, 10, 100};
559
560static char *fmt_gain(int snd, int val, char *str, int len) 551static char *fmt_gain(int snd, int val, char *str, int len)
561{ 552{
562 int i, d, numdec; 553 format_sound_value(str, len, snd, val);
563 const char *unit;
564 char sign = ' ';
565
566 val = sound_val2phys(snd, val);
567 if(val < 0)
568 {
569 sign = '-';
570 val = -val;
571 }
572 numdec = sound_numdecimals(snd);
573 unit = sound_unit(snd);
574
575 if(numdec)
576 {
577 i = val / factor[numdec];
578 d = val % factor[numdec];
579 snprintf(str, len, fmtstr[numdec], sign, i, d, unit);
580 }
581 else
582 snprintf(str, len, fmtstr[numdec], sign, val, unit);
583
584 return str; 554 return str;
585} 555}
586 556