Battery meter now shows '?' after boot instead of nothing at all.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4103 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2003-12-03 23:21:13 +00:00
parent 66d165819a
commit 34a4111ade
2 changed files with 17 additions and 7 deletions

View file

@ -158,17 +158,19 @@ void statusbar_icon_battery(int percent, bool charging)
fill = 100; fill = 100;
#ifdef SIMULATOR #ifdef SIMULATOR
if (global_settings.battery_type) { if (global_settings.battery_type && (percent > -1)) {
#else #else
#ifdef HAVE_CHARGE_CTRL /* Recorder */ #ifdef HAVE_CHARGE_CTRL /* Recorder */
/* show graphical animation when charging instead of numbers */ /* show graphical animation when charging instead of numbers */
if ((global_settings.battery_type) && (charge_state != 1)) { if ((global_settings.battery_type) &&
(charge_state != 1) &&
(percent > -1)) {
#else /* FM */ #else /* FM */
if (global_settings.battery_type) { if (global_settings.battery_type && (percent > -1)) {
#endif /* HAVE_CHARGE_CTRL */ #endif /* HAVE_CHARGE_CTRL */
#endif #endif
/* Numeric display */ /* Numeric display */
snprintf(buffer, sizeof(buffer), "%3d", percent); snprintf(buffer, sizeof(buffer), "%3d", fill);
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize(buffer, &width, &height); lcd_getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT) if (height <= STATUSBAR_HEIGHT)
@ -188,6 +190,13 @@ void statusbar_icon_battery(int percent, bool charging)
lcd_fillrect(ICON_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1, fill, 5); lcd_fillrect(ICON_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1, fill, 5);
} }
if (percent == -1) {
lcd_setfont(FONT_SYSFIXED);
lcd_putsxy(ICON_BATTERY_X_POS + ICON_BATTERY_WIDTH / 2 - 4,
STATUSBAR_Y_POS, "?");
lcd_setfont(FONT_UI);
}
/* draw power plug if charging */ /* draw power plug if charging */
if (charging) if (charging)
lcd_bitmap(bitmap_icons_7x8[Icon_Plug], ICON_PLUG_X_POS, lcd_bitmap(bitmap_icons_7x8[Icon_Plug], ICON_PLUG_X_POS,

View file

@ -40,7 +40,7 @@ static enum playmode current_mode = STATUS_STOP;
static long switch_tick; static long switch_tick;
static int battery_charge_step = 0; static int battery_charge_step = 0;
static bool plug_state; static bool plug_state;
static bool battery_state; static bool battery_state = true;
struct status_info { struct status_info {
int battlevel; int battlevel;
@ -167,7 +167,8 @@ void status_draw(bool force_redraw)
battery_state = true; battery_state = true;
else { else {
/* blink battery if level is low */ /* blink battery if level is low */
if(TIME_AFTER(current_tick, switch_tick)) { if(TIME_AFTER(current_tick, switch_tick) &&
(info.battlevel > -1)) {
switch_tick = current_tick+HZ; switch_tick = current_tick+HZ;
battery_state =! battery_state; battery_state =! battery_state;
} }
@ -175,7 +176,7 @@ void status_draw(bool force_redraw)
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if (battery_state && (info.battlevel > -1)) if (battery_state)
statusbar_icon_battery(info.battlevel, plug_state); statusbar_icon_battery(info.battlevel, plug_state);
statusbar_icon_volume(info.volume); statusbar_icon_volume(info.volume);