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:
parent
113fffaa86
commit
2ddfabc4fb
1 changed files with 10 additions and 6 deletions
|
@ -37,6 +37,7 @@ bool statusbar_enabled = true;
|
||||||
long switch_tick;
|
long switch_tick;
|
||||||
bool plug_state;
|
bool plug_state;
|
||||||
bool battery_state;
|
bool battery_state;
|
||||||
|
int battery_charge_step = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void status_init(void)
|
void status_init(void)
|
||||||
|
@ -135,18 +136,21 @@ void status_draw(void)
|
||||||
#ifdef HAVE_CHARGE_CTRL
|
#ifdef HAVE_CHARGE_CTRL
|
||||||
if(charger_inserted()) {
|
if(charger_inserted()) {
|
||||||
battery_state = true;
|
battery_state = true;
|
||||||
if(!charger_enabled)
|
|
||||||
plug_state = true;
|
plug_state = true;
|
||||||
else if(TIME_AFTER(current_tick, switch_tick)) {
|
if(charger_enabled) { /* animate battery if charging */
|
||||||
plug_state = !plug_state;
|
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;
|
switch_tick = current_tick + HZ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
plug_state=false;
|
plug_state=false;
|
||||||
if(battery_level_safe())
|
if(battery_level_safe())
|
||||||
battery_state = true;
|
battery_state = true;
|
||||||
else
|
else /* blink battery if level is low */
|
||||||
if(TIME_AFTER(current_tick, switch_tick)) {
|
if(TIME_AFTER(current_tick, switch_tick)) {
|
||||||
switch_tick = current_tick+HZ;
|
switch_tick = current_tick+HZ;
|
||||||
battery_state =! battery_state;
|
battery_state =! battery_state;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue