summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/skin_engine/skin_tokens.c53
-rw-r--r--manual/appendix/wps_tags.tex8
2 files changed, 35 insertions, 26 deletions
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index b9d4bd6..3d944a5 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -345,12 +345,30 @@ const char *get_id3_token(struct wps_token *token, struct mp3entry *id3,
#if CONFIG_TUNER
-/* Formats the frequency (specified in Hz) in MHz, */
-/* with two digits after the decimal point */
-static void format_freq_MHz(int freq, char *buf, int buf_size)
+/* Formats the frequency (specified in Hz) in MHz, */
+/* with one or two digits after the decimal point -- */
+/* depending on the frequency changing step. */
+/* Returns buf */
+static char *format_freq_MHz(int freq, int freq_step, char *buf, int buf_size)
{
- freq = freq / 10000;
- snprintf(buf, buf_size, "%d.%02d", freq/100, freq%100);
+ int scale, div;
+ char *fmt;
+ if (freq_step < 100000)
+ {
+ /* Format with two digits after decimal point */
+ scale = 10000;
+ fmt = "%d.%02d";
+ }
+ else
+ {
+ /* Format with one digit after decimal point */
+ scale = 100000;
+ fmt = "%d.%d";
+ }
+ div = 1000000 / scale;
+ freq = freq / scale;
+ snprintf(buf, buf_size, fmt, freq/div, freq%div);
+ return buf;
}
@@ -358,6 +376,8 @@ static void format_freq_MHz(int freq, char *buf, int buf_size)
const char *get_radio_token(struct wps_token *token, int preset_offset,
char *buf, int buf_size, int limit, int *intval)
{
+ const struct fm_region_data *region_data =
+ &(fm_region_data[global_settings.fm_region]);
(void)limit;
switch (token->type)
{
@@ -375,23 +395,14 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
return "s";
return NULL;
case WPS_TOKEN_TUNER_MINFREQ: /* changes based on "region" */
- {
- format_freq_MHz(fm_region_data[global_settings.fm_region].freq_min,
- buf, buf_size);
- return buf;
- }
+ return format_freq_MHz(region_data->freq_min,
+ region_data->freq_step, buf, buf_size);
case WPS_TOKEN_TUNER_MAXFREQ: /* changes based on "region" */
- {
- format_freq_MHz(fm_region_data[global_settings.fm_region].freq_max,
- buf, buf_size);
- return buf;
- }
+ return format_freq_MHz(region_data->freq_max,
+ region_data->freq_step, buf, buf_size);
case WPS_TOKEN_TUNER_CURFREQ:
- {
- format_freq_MHz(radio_current_frequency(),
- buf, buf_size);
- return buf;
- }
+ return format_freq_MHz(radio_current_frequency(),
+ region_data->freq_step, buf, buf_size);
case WPS_TOKEN_PRESET_ID:
snprintf(buf, buf_size, "%d", radio_current_preset() + 1 + preset_offset);
return buf;
@@ -414,7 +425,7 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
else
{
format_freq_MHz(radio_get_preset(preset)->frequency,
- buf, buf_size);
+ region_data->freq_step, buf, buf_size);
}
return buf;
}
diff --git a/manual/appendix/wps_tags.tex b/manual/appendix/wps_tags.tex
index 591d8ea..577d31e 100644
--- a/manual/appendix/wps_tags.tex
+++ b/manual/appendix/wps_tags.tex
@@ -386,11 +386,9 @@ Examples:
\config{\%tt} & Is the tuner tuned?\\
\config{\%tm} & Scan or preset mode? Scan is ``true'', preset is ``false''.\\
\config{\%ts} & Is the station in stereo?\\
- \config{\%ta} & Minimum frequency (region specific) in MHz, with two
- decimal digits.\\
- \config{\%tb} & Maximum frequency (region specific) in MHz, with two
- decimal digits.\\
- \config{\%tf} & Current frequency in MHz, with two decimal digits.\\
+ \config{\%ta} & Minimum frequency (region specific) in MHz.\\
+ \config{\%tb} & Maximum frequency (region specific) in MHz.\\
+ \config{\%tf} & Current frequency in MHz.\\
\config{\%Ti} & Current preset id, i.e. 1-based number of the preset
within the presets list (usable in playlist viewer).\\
\config{\%Tn} & Current preset name (usable in playlist viewer).\\