summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-11-18 11:47:42 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-11-18 11:47:42 +0000
commit1ce7ba4931c64a7ae6a95981e838db97d7e05699 (patch)
tree0bb3de85e23bb64951f3acbd176a20301f7efb30 /apps/gui
parent62b8efe6741b61ef10d3c7b98dd0d3416b7fce11 (diff)
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
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/skin_engine/skin_display.c19
-rw-r--r--apps/gui/skin_engine/skin_parser.c5
-rw-r--r--apps/gui/skin_engine/skin_render.c1
-rw-r--r--apps/gui/skin_engine/skin_tokens.c14
4 files changed, 36 insertions, 3 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 78db4eb371..47de4638d8 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -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)
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index c94ef4e5b5..818edfbd07 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -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:
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index a9e6319317..68a5433eb1 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -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)
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index efe67a186e..c2ee7bf426 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -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));