Make the %tr (radio RSSI) tag work as a bar tag or as a conditional.

As a conditional it scales its value to the number of options you give it (like volume)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28613 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-11-18 11:47:42 +00:00
parent 62b8efe674
commit 1ce7ba4931
8 changed files with 72 additions and 13 deletions

View file

@ -162,9 +162,22 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
#if CONFIG_TUNER
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
{
int min = fm_region_data[global_settings.fm_region].freq_min;
end = radio_current_frequency() - min;
length = fm_region_data[global_settings.fm_region].freq_max - min;
#ifdef HAVE_RADIO_RSSI
if (pb->type == SKIN_TOKEN_TUNER_RSSI_BAR)
{
int val = tuner_get(RADIO_RSSI);
int min = tuner_get(RADIO_RSSI_MIN);
int max = tuner_get(RADIO_RSSI_MAX);
end = val - min;
length = max - min;
}
else
#endif
{
int min = fm_region_data[global_settings.fm_region].freq_min;
end = radio_current_frequency() - min;
length = fm_region_data[global_settings.fm_region].freq_max - min;
}
}
#endif
else if (id3 && id3->length)

View file

@ -742,6 +742,8 @@ static int parse_progressbar_tag(struct skin_element* element,
token->type = SKIN_TOKEN_VOLUMEBAR;
else if (token->type == SKIN_TOKEN_BATTERY_PERCENT)
token->type = SKIN_TOKEN_BATTERY_PERCENTBAR;
else if (token->type == SKIN_TOKEN_TUNER_RSSI)
token->type = SKIN_TOKEN_TUNER_RSSI_BAR;
pb->type = token->type;
return 0;
@ -1408,6 +1410,9 @@ static int skin_element_callback(struct skin_element* element, void* data)
case SKIN_TOKEN_VOLUME:
case SKIN_TOKEN_BATTERY_PERCENT:
case SKIN_TOKEN_PLAYER_PROGRESSBAR:
#ifdef HAVE_RADIO_RSSI
case SKIN_TOKEN_TUNER_RSSI:
#endif
function = parse_progressbar_tag;
break;
case SKIN_TOKEN_SUBLINE_TIMEOUT:

View file

@ -143,6 +143,7 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
case SKIN_TOKEN_BATTERY_PERCENTBAR:
#ifdef HAVE_LCD_BITMAP
case SKIN_TOKEN_PROGRESSBAR:
case SKIN_TOKEN_TUNER_RSSI_BAR:
{
struct progressbar *bar = (struct progressbar*)token->value.data;
if (do_refresh)

View file

@ -478,6 +478,20 @@ const char *get_radio_token(struct wps_token *token, int preset_offset,
#ifdef HAVE_RADIO_RSSI
case SKIN_TOKEN_TUNER_RSSI:
snprintf(buf, buf_size, "%d",tuner_get(RADIO_RSSI));
if (intval)
{
int val = tuner_get(RADIO_RSSI);
int min = tuner_get(RADIO_RSSI_MIN);
int max = tuner_get(RADIO_RSSI_MAX);
if (limit == TOKEN_VALUE_ONLY)
{
*intval = val;
}
else
{
*intval = 1+(limit-1)*(val-min)/(max-1-min);
}
}
return buf;
case SKIN_TOKEN_TUNER_RSSI_MIN:
snprintf(buf, buf_size, "%d",tuner_get(RADIO_RSSI_MIN));

View file

@ -94,14 +94,6 @@ extern const struct fm_region_data fm_region_data[TUNER_NUM_REGIONS];
#if CONFIG_TUNER
#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
int tuner_set(int setting, int value);
int tuner_get(int setting);
#ifdef HAVE_RDS_CAP
char* tuner_get_rds_info(int setting);
#endif
#else
#ifdef CONFIG_TUNER_MULTI
extern int tuner_detect_type(void);
extern int (*tuner_set)(int setting, int value);
@ -146,7 +138,14 @@ extern int (*tuner_get)(int setting);
#include "ipod_remote_tuner.h"
#endif
#endif /* PLATFORM_HOSTED */
#ifdef SIMULATOR
#undef tuner_set
int tuner_set(int setting, int value);
#undef tuner_get
int tuner_get(int setting);
#endif
/* Additional messages that get enumerated after tuner driver headers */

View file

@ -153,7 +153,7 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_TUNER_MINFREQ, "ta", "", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_TUNER_MAXFREQ, "tb", "", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_TUNER_CURFREQ, "tf", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TUNER_RSSI, "tr", "", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TUNER_RSSI, "tr", BAR_PARAMS, SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_TUNER_RSSI_MIN, "tl", "", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_TUNER_RSSI_MAX, "th", "", SKIN_REFRESH_STATIC },
{ SKIN_TOKEN_PRESET_ID, "Ti", "", SKIN_REFRESH_STATIC },

View file

@ -252,6 +252,7 @@ enum skin_token_type {
SKIN_TOKEN_TUNER_RSSI,
SKIN_TOKEN_TUNER_RSSI_MIN,
SKIN_TOKEN_TUNER_RSSI_MAX,
SKIN_TOKEN_TUNER_RSSI_BAR,
SKIN_TOKEN_PRESET_ID, /* "id" of this preset.. really the array element number */
SKIN_TOKEN_PRESET_NAME,
SKIN_TOKEN_PRESET_FREQ,

View file

@ -67,6 +67,9 @@ int tuner_set(int setting, int value)
int tuner_get(int setting)
{
int val = 0;
#ifdef HAVE_RADIO_RSSI
static int rssi = 0, rssidiff = 2;
#endif
switch(setting)
{
@ -83,6 +86,29 @@ int tuner_get(int setting)
if(frequency == 99500000)
val = mono?0:1;
break;
#ifdef HAVE_RADIO_RSSI
case RADIO_RSSI_MIN:
val = 5;
break;
case RADIO_RSSI_MAX:
val = 75;
break;
case RADIO_RSSI:
rssi += rssidiff;
if (rssi >= 75)
{
rssi = 75;
rssidiff = -2;
}
else if (rssi < 5)
{
rssi = 5;
rssidiff = 2;
}
val = rssi;
break;
#endif
case RADIO_ALL: /* debug query */
break;