summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--firmware/general.c6
-rw-r--r--lib/fixedpoint/fixedpoint.c29
-rw-r--r--lib/fixedpoint/fixedpoint.h2
-rw-r--r--lib/fixedpoint/fixedpoint.make3
13 files changed, 110 insertions, 142 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
diff --git a/firmware/general.c b/firmware/general.c
index c70d21c4a0..a4e7fba0f6 100644
--- a/firmware/general.c
+++ b/firmware/general.c
@@ -107,7 +107,6 @@ char *create_numbered_filename(char *buffer, const char *path,
107 int pathlen; 107 int pathlen;
108 int prefixlen = strlen(prefix); 108 int prefixlen = strlen(prefix);
109 int suffixlen = strlen(suffix); 109 int suffixlen = strlen(suffix);
110 char fmtstring[12];
111 110
112 if (buffer != path) 111 if (buffer != path)
113 strlcpy(buffer, path, MAX_PATH); 112 strlcpy(buffer, path, MAX_PATH);
@@ -152,9 +151,8 @@ char *create_numbered_filename(char *buffer, const char *path,
152 151
153 max_num++; 152 max_num++;
154 153
155 snprintf(fmtstring, sizeof(fmtstring), "/%%s%%0%dd%%s", numberlen); 154 snprintf(buffer + pathlen, MAX_PATH - pathlen, "/%s%0*d%s", prefix,
156 snprintf(buffer + pathlen, MAX_PATH - pathlen, fmtstring, prefix, 155 numberlen, max_num, suffix);
157 max_num, suffix);
158 156
159#ifdef IF_CNFN_NUM 157#ifdef IF_CNFN_NUM
160 if (num) 158 if (num)
diff --git a/lib/fixedpoint/fixedpoint.c b/lib/fixedpoint/fixedpoint.c
index 645419d102..d1307bb248 100644
--- a/lib/fixedpoint/fixedpoint.c
+++ b/lib/fixedpoint/fixedpoint.c
@@ -211,6 +211,35 @@ long fp_sqrt(long x, unsigned int fracbits)
211 return g; 211 return g;
212} 212}
213 213
214/* raise an integer to an integer power */
215long ipow(long x, long y)
216{
217 /* y[k] = bit k of y, 0 or 1; k=0...n; n=|_ lg(y) _|
218 *
219 * x^y = x^(y[0]*2^0 + y[1]*2^1 + ... + y[n]*2^n)
220 * = x^(y[0]*2^0) * x^(y[1]*2^1) * ... * x^(y[n]*2^n)
221 */
222 long a = 1;
223
224 if (y < 0 && x != -1)
225 {
226 a = 0; /* would be < 1 or +inf if x == 0 */
227 }
228 else
229 {
230 while (y)
231 {
232 if (y & 1)
233 a *= x;
234
235 y /= 2;
236 x *= x;
237 }
238 }
239
240 return a;
241}
242
214/** 243/**
215 * Fixed point sinus using a lookup table 244 * Fixed point sinus using a lookup table
216 * don't forget to divide the result by 16384 to get the actual sinus value 245 * don't forget to divide the result by 16384 to get the actual sinus value
diff --git a/lib/fixedpoint/fixedpoint.h b/lib/fixedpoint/fixedpoint.h
index bc50ff687d..dcd7c8298c 100644
--- a/lib/fixedpoint/fixedpoint.h
+++ b/lib/fixedpoint/fixedpoint.h
@@ -85,6 +85,8 @@ long fp14_sin(int val);
85long fp16_log(int x); 85long fp16_log(int x);
86long fp16_exp(int x); 86long fp16_exp(int x);
87 87
88long ipow(long x, long y);
89
88/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit, 90/* fast unsigned multiplication (16x16bit->32bit or 32x32bit->32bit,
89 * whichever is faster for the architecture) */ 91 * whichever is faster for the architecture) */
90#ifdef CPU_ARM 92#ifdef CPU_ARM
diff --git a/lib/fixedpoint/fixedpoint.make b/lib/fixedpoint/fixedpoint.make
index 0233e9499b..5be0e38ea7 100644
--- a/lib/fixedpoint/fixedpoint.make
+++ b/lib/fixedpoint/fixedpoint.make
@@ -13,11 +13,8 @@ FIXEDPOINTLIB_OBJ := $(call c2obj, $(FIXEDPOINTLIB_SRC))
13INCLUDES += -I$(FIXEDPOINTLIB_DIR) 13INCLUDES += -I$(FIXEDPOINTLIB_DIR)
14OTHER_SRC += $(FIXEDPOINTLIB_SRC) 14OTHER_SRC += $(FIXEDPOINTLIB_SRC)
15 15
16# If not SOFTWARECODECS, then only plugins depend upon us
17ifdef SOFTWARECODECS
18CORE_LIBS += $(FIXEDPOINTLIB) 16CORE_LIBS += $(FIXEDPOINTLIB)
19CORE_GCSECTIONS := yes 17CORE_GCSECTIONS := yes
20endif
21 18
22FIXEDPOINTLIB_FLAGS := $(CFLAGS) $(SHARED_CFLAGS) 19FIXEDPOINTLIB_FLAGS := $(CFLAGS) $(SHARED_CFLAGS)
23 20