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
This commit is contained in:
Jonathan Gordon 2011-01-13 06:48:39 +00:00
parent c8535f27d1
commit 261c56ba59
8 changed files with 66 additions and 7 deletions

View File

@ -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))
{

View File

@ -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

View File

@ -138,6 +138,12 @@ static bool do_non_text_tags(struct gui_wps *gwps, struct skin_draw_info *info,
if (do_refresh)
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:

View File

@ -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:

View File

@ -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);

View File

@ -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[],

View File

@ -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 },

View File

@ -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,