summaryrefslogtreecommitdiff
path: root/apps/gui
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/gui
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/gui')
-rw-r--r--apps/gui/option_select.c20
-rw-r--r--apps/gui/skin_engine/skin_tokens.c21
2 files changed, 8 insertions, 33 deletions
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