1
0
Fork 0
forked from len0rd/rockbox

battery is animated while charging

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1713 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Markus Braun 2002-08-13 14:58:09 +00:00
parent 113fffaa86
commit 2ddfabc4fb

View file

@ -37,6 +37,7 @@ bool statusbar_enabled = true;
long switch_tick;
bool plug_state;
bool battery_state;
int battery_charge_step = 0;
#endif
void status_init(void)
@ -135,18 +136,21 @@ void status_draw(void)
#ifdef HAVE_CHARGE_CTRL
if(charger_inserted()) {
battery_state = true;
if(!charger_enabled)
plug_state = true;
else if(TIME_AFTER(current_tick, switch_tick)) {
plug_state = !plug_state;
switch_tick = current_tick + HZ;
plug_state = true;
if(charger_enabled) { /* animate battery if charging */
battlevel = battery_charge_step * 34; /* 34 for a better look */
battlevel = battlevel > 100 ? 100 : battlevel;
if(TIME_AFTER(current_tick, switch_tick)) {
battery_charge_step=(battery_charge_step+1)%4;
switch_tick = current_tick + HZ;
}
}
}
else {
plug_state=false;
if(battery_level_safe())
battery_state = true;
else
else /* blink battery if level is low */
if(TIME_AFTER(current_tick, switch_tick)) {
switch_tick = current_tick+HZ;
battery_state =! battery_state;