summaryrefslogtreecommitdiff
path: root/apps/status.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/status.c')
-rw-r--r--apps/status.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/apps/status.c b/apps/status.c
index 5bbe14710d..4f3afabed8 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -37,6 +37,7 @@ bool statusbar_enabled = true;
37long switch_tick; 37long switch_tick;
38bool plug_state; 38bool plug_state;
39bool battery_state; 39bool battery_state;
40int battery_charge_step = 0;
40#endif 41#endif
41 42
42void status_init(void) 43void status_init(void)
@@ -135,18 +136,21 @@ void status_draw(void)
135#ifdef HAVE_CHARGE_CTRL 136#ifdef HAVE_CHARGE_CTRL
136 if(charger_inserted()) { 137 if(charger_inserted()) {
137 battery_state = true; 138 battery_state = true;
138 if(!charger_enabled) 139 plug_state = true;
139 plug_state = true; 140 if(charger_enabled) { /* animate battery if charging */
140 else if(TIME_AFTER(current_tick, switch_tick)) { 141 battlevel = battery_charge_step * 34; /* 34 for a better look */
141 plug_state = !plug_state; 142 battlevel = battlevel > 100 ? 100 : battlevel;
142 switch_tick = current_tick + HZ; 143 if(TIME_AFTER(current_tick, switch_tick)) {
144 battery_charge_step=(battery_charge_step+1)%4;
145 switch_tick = current_tick + HZ;
146 }
143 } 147 }
144 } 148 }
145 else { 149 else {
146 plug_state=false; 150 plug_state=false;
147 if(battery_level_safe()) 151 if(battery_level_safe())
148 battery_state = true; 152 battery_state = true;
149 else 153 else /* blink battery if level is low */
150 if(TIME_AFTER(current_tick, switch_tick)) { 154 if(TIME_AFTER(current_tick, switch_tick)) {
151 switch_tick = current_tick+HZ; 155 switch_tick = current_tick+HZ;
152 battery_state =! battery_state; 156 battery_state =! battery_state;