summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2011-01-13 06:48:39 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2011-01-13 06:48:39 +0000
commit261c56ba59235c2da2aa644fbea0b1fa492bd1c6 (patch)
treecdf37e93496f9dc3aaf71f45537ff3d5371c074f
parentc8535f27d140a2030cedf695a66595aae5b95c27 (diff)
downloadrockbox-261c56ba59235c2da2aa644fbea0b1fa492bd1c6.tar.gz
rockbox-261c56ba59235c2da2aa644fbea0b1fa492bd1c6.zip
FS#11867 - Add 2 new tags to allow skins to display themed peakmeters
%pL for the left channel, %pR for the right channel... usable as a value, conditional or bar (exactly the same as %pv/%bl/etc) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29043 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/gui/skin_engine/skin_display.c10
-rw-r--r--apps/gui/skin_engine/skin_parser.c6
-rw-r--r--apps/gui/skin_engine/skin_render.c6
-rw-r--r--apps/gui/skin_engine/skin_tokens.c18
-rw-r--r--apps/recorder/peakmeter.c24
-rw-r--r--apps/recorder/peakmeter.h2
-rw-r--r--lib/skin_parser/tag_table.c3
-rw-r--r--lib/skin_parser/tag_table.h4
8 files changed, 66 insertions, 7 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index 47de4638d8..d38c8fd0ce 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -42,6 +42,7 @@
#include "playlist.h"
#include "audio.h"
#include "tagcache.h"
+#include "peakmeter.h"
#ifdef HAVE_LCD_BITMAP
#include "peakmeter.h"
@@ -159,6 +160,15 @@ void draw_progressbar(struct gui_wps *gwps, int line, struct progressbar *pb)
length = 100;
end = battery_level();
}
+ else if (pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ||
+ pb->type == SKIN_TOKEN_PEAKMETER_RIGHTBAR)
+ {
+ int left, right, val;
+ peak_meter_current_vals(&left, &right);
+ val = pb->type == SKIN_TOKEN_PEAKMETER_LEFTBAR ? left : right;
+ length = MAX_PEAK;
+ end = peak_meter_scale_value(val, length);
+ }
#if CONFIG_TUNER
else if (in_radio_screen() || (get_radio_status() != FMRADIO_OFF))
{
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index f292ff3946..5a90873d86 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -744,6 +744,10 @@ static int parse_progressbar_tag(struct skin_element* element,
token->type = SKIN_TOKEN_BATTERY_PERCENTBAR;
else if (token->type == SKIN_TOKEN_TUNER_RSSI)
token->type = SKIN_TOKEN_TUNER_RSSI_BAR;
+ else if (token->type == SKIN_TOKEN_PEAKMETER_LEFT)
+ token->type = SKIN_TOKEN_PEAKMETER_LEFTBAR;
+ else if (token->type == SKIN_TOKEN_PEAKMETER_RIGHT)
+ token->type = SKIN_TOKEN_PEAKMETER_RIGHTBAR;
pb->type = token->type;
return 0;
@@ -1410,6 +1414,8 @@ 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:
+ case SKIN_TOKEN_PEAKMETER_LEFT:
+ case SKIN_TOKEN_PEAKMETER_RIGHT:
#ifdef HAVE_RADIO_RSSI
case SKIN_TOKEN_TUNER_RSSI:
#endif
diff --git a/apps/gui/skin_engine/skin_render.c b/apps/gui/skin_engine/skin_render.c
index 68a5433eb1..424e0c29cc 100644
--- a/apps/gui/skin_engine/skin_render.c
+++ b/apps/gui/skin_engine/skin_render.c
@@ -139,6 +139,12 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
draw_peakmeters(gwps, info->line_number, vp);
break;
#endif
+#ifdef HAVE_LCD_BITMAP
+ case SKIN_TOKEN_PEAKMETER_LEFTBAR:
+ case SKIN_TOKEN_PEAKMETER_RIGHTBAR:
+ data->peak_meter_enabled = true;
+ /* fall through to the progressbar code */
+#endif
case SKIN_TOKEN_VOLUMEBAR:
case SKIN_TOKEN_BATTERY_PERCENTBAR:
#ifdef HAVE_LCD_BITMAP
diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c
index 217835a1e2..c644d5b3aa 100644
--- a/apps/gui/skin_engine/skin_tokens.c
+++ b/apps/gui/skin_engine/skin_tokens.c
@@ -59,6 +59,7 @@
#include "skin_engine.h"
#include "statusbar-skinned.h"
#include "root_menu.h"
+#include "peakmeter.h"
#ifdef HAVE_RECORDING
#include "recording.h"
#include "pcm_record.h"
@@ -1267,6 +1268,23 @@ const char *get_token_value(struct gui_wps *gwps,
#endif
+#ifdef HAVE_LCD_BITMAP
+ /* peakmeter */
+ case SKIN_TOKEN_PEAKMETER_LEFT:
+ case SKIN_TOKEN_PEAKMETER_RIGHT:
+ {
+ int left, right, val;
+ peak_meter_current_vals(&left, &right);
+ val = token->type == SKIN_TOKEN_PEAKMETER_LEFT ?
+ left : right;
+ val = peak_meter_scale_value(val, limit==1 ? MAX_PEAK : limit);
+ if (intval)
+ *intval = val;
+ snprintf(buf, buf_size, "%d", val);
+ data->peak_meter_enabled = true;
+ return buf;
+ }
+#endif
#if (CONFIG_CODEC == SWCODEC)
case SKIN_TOKEN_CROSSFADE:
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index aacfc23cee..ca1b8c8750 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -930,6 +930,21 @@ void peak_meter_screen(struct screen *display, int x, int y, int height)
peak_meter_draw(display, &scales[display->screen_type], x, y,
display->getwidth() - x, height);
}
+
+/* sets *left and *right to the current *unscaled* values */
+void peak_meter_current_vals(int *left, int *right)
+{
+ static int left_level = 0, right_level = 0;
+ if (level_check){
+ /* only read the volume info from MAS if peek since last read*/
+ left_level = peak_meter_read_l();
+ right_level = peak_meter_read_r();
+ level_check = false;
+ }
+ *left = left_level;
+ *right = right_level;
+}
+
/**
* Draws a peak meter in the specified size at the specified position.
* @param int x - The x coordinate.
@@ -944,7 +959,7 @@ void peak_meter_screen(struct screen *display, int x, int y, int height)
static void peak_meter_draw(struct screen *display, struct meter_scales *scales,
int x, int y, int width, int height)
{
- static int left_level = 0, right_level = 0;
+ int left_level = 0, right_level = 0;
int left = 0, right = 0;
int meterwidth = width - 3;
int i, delta;
@@ -964,12 +979,7 @@ static void peak_meter_draw(struct screen *display, struct meter_scales *scales,
if (peak_meter_enabled) {
- if (level_check){
- /* only read the volume info from MAS if peek since last read*/
- left_level = peak_meter_read_l();
- right_level = peak_meter_read_r();
- level_check = false;
- }
+ peak_meter_current_vals(&left_level, &right_level);
/* scale the samples dBfs */
left = peak_meter_scale_value(left_level, meterwidth);
diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h
index 4abcc154f3..fee4882679 100644
--- a/apps/recorder/peakmeter.h
+++ b/apps/recorder/peakmeter.h
@@ -34,6 +34,8 @@ extern void pm_reset_clipcount(void);
extern void pm_activate_clipcount(bool active);
extern void peak_meter_enable(bool enable);
+/* sets *left and *right to the current *unscaled* values */
+extern void peak_meter_current_vals(int *left, int *right);
extern void peak_meter_playback(bool playback);
extern int peak_meter_draw_get_btn(int action_context, int x[], int y[],
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index 197963f2ac..1b7fdbdb64 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -125,6 +125,9 @@ static const struct tag_info legal_tags[] =
{ SKIN_TOKEN_BUTTON_VOLUME, "mv", "|D", SKIN_REFRESH_DYNAMIC },
{ SKIN_TOKEN_PEAKMETER, "pm", "", SKIN_REFRESH_PEAK_METER },
+ { SKIN_TOKEN_PEAKMETER_LEFT, "pL", BAR_PARAMS, SKIN_REFRESH_PEAK_METER },
+ { SKIN_TOKEN_PEAKMETER_RIGHT, "pR", BAR_PARAMS, SKIN_REFRESH_PEAK_METER },
+
{ SKIN_TOKEN_PLAYER_PROGRESSBAR, "pf", "", SKIN_REFRESH_DYNAMIC|SKIN_REFRESH_PLAYER_PROGRESS },
{ SKIN_TOKEN_PROGRESSBAR, "pb" , BAR_PARAMS, SKIN_REFRESH_PLAYER_PROGRESS },
{ SKIN_TOKEN_VOLUME, "pv" , BAR_PARAMS, SKIN_REFRESH_DYNAMIC },
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index a39939d225..31a5ec215f 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -185,6 +185,10 @@ enum skin_token_type {
SKIN_TOKEN_PLAYER_PROGRESSBAR,
/* Peakmeter */
SKIN_TOKEN_PEAKMETER,
+ SKIN_TOKEN_PEAKMETER_LEFT,
+ SKIN_TOKEN_PEAKMETER_LEFTBAR,
+ SKIN_TOKEN_PEAKMETER_RIGHT,
+ SKIN_TOKEN_PEAKMETER_RIGHTBAR,
/* Current track */
SKIN_TOKEN_TRACK_ELAPSED_PERCENT,