···345345346346#if CONFIG_TUNER
347347348348-/* Formats the frequency (specified in Hz) in MHz, */
349349-/* with two digits after the decimal point */
350350-static void format_freq_MHz(int freq, char *buf, int buf_size)
348348+/* Formats the frequency (specified in Hz) in MHz, */
349349+/* with one or two digits after the decimal point -- */
350350+/* depending on the frequency changing step. */
351351+/* Returns buf */
352352+static char *format_freq_MHz(int freq, int freq_step, char *buf, int buf_size)
351353{
352352- freq = freq / 10000;
353353- snprintf(buf, buf_size, "%d.%02d", freq/100, freq%100);
354354+ int scale, div;
355355+ char *fmt;
356356+ if (freq_step < 100000)
357357+ {
358358+ /* Format with two digits after decimal point */
359359+ scale = 10000;
360360+ fmt = "%d.%02d";
361361+ }
362362+ else
363363+ {
364364+ /* Format with one digit after decimal point */
365365+ scale = 100000;
366366+ fmt = "%d.%d";
367367+ }
368368+ div = 1000000 / scale;
369369+ freq = freq / scale;
370370+ snprintf(buf, buf_size, fmt, freq/div, freq%div);
371371+ return buf;
354372}
355373356374···358376const char *get_radio_token(struct wps_token *token, int preset_offset,
359377 char *buf, int buf_size, int limit, int *intval)
360378{
379379+ const struct fm_region_data *region_data =
380380+ &(fm_region_data[global_settings.fm_region]);
361381 (void)limit;
362382 switch (token->type)
363383 {
···375395 return "s";
376396 return NULL;
377397 case WPS_TOKEN_TUNER_MINFREQ: /* changes based on "region" */
378378- {
379379- format_freq_MHz(fm_region_data[global_settings.fm_region].freq_min,
380380- buf, buf_size);
381381- return buf;
382382- }
398398+ return format_freq_MHz(region_data->freq_min,
399399+ region_data->freq_step, buf, buf_size);
383400 case WPS_TOKEN_TUNER_MAXFREQ: /* changes based on "region" */
384384- {
385385- format_freq_MHz(fm_region_data[global_settings.fm_region].freq_max,
386386- buf, buf_size);
387387- return buf;
388388- }
401401+ return format_freq_MHz(region_data->freq_max,
402402+ region_data->freq_step, buf, buf_size);
389403 case WPS_TOKEN_TUNER_CURFREQ:
390390- {
391391- format_freq_MHz(radio_current_frequency(),
392392- buf, buf_size);
393393- return buf;
394394- }
404404+ return format_freq_MHz(radio_current_frequency(),
405405+ region_data->freq_step, buf, buf_size);
395406 case WPS_TOKEN_PRESET_ID:
396407 snprintf(buf, buf_size, "%d", radio_current_preset() + 1 + preset_offset);
397408 return buf;
···414425 else
415426 {
416427 format_freq_MHz(radio_get_preset(preset)->frequency,
417417- buf, buf_size);
428428+ region_data->freq_step, buf, buf_size);
418429 }
419430 return buf;
420431 }
+3-5
manual/appendix/wps_tags.tex
···386386 \config{\%tt} & Is the tuner tuned?\\
387387 \config{\%tm} & Scan or preset mode? Scan is ``true'', preset is ``false''.\\
388388 \config{\%ts} & Is the station in stereo?\\
389389- \config{\%ta} & Minimum frequency (region specific) in MHz, with two
390390- decimal digits.\\
391391- \config{\%tb} & Maximum frequency (region specific) in MHz, with two
392392- decimal digits.\\
393393- \config{\%tf} & Current frequency in MHz, with two decimal digits.\\
389389+ \config{\%ta} & Minimum frequency (region specific) in MHz.\\
390390+ \config{\%tb} & Maximum frequency (region specific) in MHz.\\
391391+ \config{\%tf} & Current frequency in MHz.\\
394392 \config{\%Ti} & Current preset id, i.e. 1-based number of the preset
395393 within the presets list (usable in playlist viewer).\\
396394 \config{\%Tn} & Current preset name (usable in playlist viewer).\\