1
0
Fork 0
forked from len0rd/rockbox

Make battery level (%bl) work with the bmp bars drawer like %pb and %pv

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25710 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-04-25 11:32:51 +00:00
parent cbc65befa8
commit 4c65a1970e
3 changed files with 17 additions and 5 deletions

View file

@ -27,6 +27,7 @@
#include "system.h"
#include "rbunicode.h"
#include "sound.h"
#include "powermgmt.h"
#ifdef DEBUG
#include "debug.h"
#endif
@ -145,6 +146,11 @@ static void draw_progressbar(struct gui_wps *gwps,
length = maxvol-minvol;
elapsed = global_settings.volume-minvol;
}
else if (pb->type == WPS_TOKEN_BATTERY_PERCENTBAR)
{
length = 100;
elapsed = battery_level();
}
else if (id3 && id3->length)
{
length = id3->length;
@ -608,8 +614,9 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index)
/* clear all pictures in the conditional and nested ones */
if (data->tokens[i].type == WPS_TOKEN_IMAGE_PRELOAD_DISPLAY)
clear_image_pos(gwps, find_image(data->tokens[i].value.i&0xFF, data));
else if (data->tokens[i].type == WPS_TOKEN_VOLUMEBAR ||
data->tokens[i].type == WPS_TOKEN_PROGRESSBAR)
else if (data->tokens[i].type == WPS_TOKEN_VOLUMEBAR ||
data->tokens[i].type == WPS_TOKEN_PROGRESSBAR ||
data->tokens[i].type == WPS_TOKEN_BATTERY_PERCENTBAR )
{
struct progressbar *bar = (struct progressbar*)data->tokens[i].value.data;
bar->draw = false;
@ -677,6 +684,7 @@ static bool get_line(struct gui_wps *gwps,
#ifdef HAVE_LCD_BITMAP
case WPS_TOKEN_VOLUMEBAR:
case WPS_TOKEN_BATTERY_PERCENTBAR:
case WPS_TOKEN_PROGRESSBAR:
{
struct progressbar *bar = (struct progressbar*)data->tokens[i].value.data;

View file

@ -202,7 +202,7 @@ static const struct wps_tag all_tags[] = {
{ WPS_TOKEN_ALIGN_RIGHT_RTL, "aR", 0, NULL },
{ WPS_NO_TOKEN, "ax", 0, parse_languagedirection },
{ WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, NULL },
{ WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, parse_progressbar },
{ WPS_TOKEN_BATTERY_VOLTS, "bv", WPS_REFRESH_DYNAMIC, NULL },
{ WPS_TOKEN_BATTERY_TIME, "bt", WPS_REFRESH_DYNAMIC, NULL },
{ WPS_TOKEN_BATTERY_SLEEPTIME, "bs", WPS_REFRESH_DYNAMIC, NULL },
@ -1166,7 +1166,7 @@ static int parse_progressbar(const char *wps_bufptr,
pb->width = vp->width;
pb->height = SYSFONT_HEIGHT-2;
pb->y = -line_num - 1; /* Will be computed during the rendering */
if (token->type == WPS_TOKEN_VOLUME)
if (token->type == WPS_TOKEN_VOLUME || token->type == WPS_TOKEN_BATTERY_PERCENT)
return 0; /* dont add it, let the regular token handling do the work */
add_to_ll_chain(&wps_data->progressbars, item);
return 0;
@ -1233,12 +1233,15 @@ static int parse_progressbar(const char *wps_bufptr,
add_to_ll_chain(&wps_data->progressbars, item);
if (token->type == WPS_TOKEN_VOLUME)
token->type = WPS_TOKEN_VOLUMEBAR;
else if (token->type == WPS_TOKEN_BATTERY_PERCENT)
token->type = WPS_TOKEN_BATTERY_PERCENTBAR;
pb->type = token->type;
return ptr+1-wps_bufptr;
#else
(void)wps_bufptr;
if (token->type != WPS_TOKEN_VOLUME)
if (token->type != WPS_TOKEN_VOLUME &&
token->type != WPS_TOKEN_BATTERY_PERCENTBAR)
{
wps_data->full_line_progressbar =
token->type == WPS_TOKEN_PLAYER_PROGRESSBAR;

View file

@ -59,6 +59,7 @@ enum wps_token_type {
/* Battery */
TOKEN_MARKER_BATTERY,
WPS_TOKEN_BATTERY_PERCENT,
WPS_TOKEN_BATTERY_PERCENTBAR,
WPS_TOKEN_BATTERY_VOLTS,
WPS_TOKEN_BATTERY_TIME,
WPS_TOKEN_BATTERY_CHARGER_CONNECTED,