summaryrefslogtreecommitdiff
path: root/apps/gui/statusbar.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/statusbar.c')
-rw-r--r--apps/gui/statusbar.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index 8acfd1ca7f..c9b27aea7c 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -109,9 +109,7 @@ void gui_statusbar_init(struct gui_statusbar * bar)
109{ 109{
110 bar->last_volume = -1000; /* -1000 means "first update ever" */ 110 bar->last_volume = -1000; /* -1000 means "first update ever" */
111 bar->battery_icon_switch_tick = 0; 111 bar->battery_icon_switch_tick = 0;
112#ifdef HAVE_CHARGING 112 bar->animated_level = 0;
113 bar->battery_charge_step = 0;
114#endif
115} 113}
116 114
117void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) 115void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
@@ -199,11 +197,20 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
199 { 197 {
200#endif 198#endif
201 /* animate in three steps (34% per step for a better look) */ 199 /* animate in three steps (34% per step for a better look) */
202 bar->info.battlevel = bar->battery_charge_step * 34; 200#ifndef HAVE_CHARGE_STATE
203 if (bar->info.battlevel > 100) 201 bar->info.battlevel = 0;
204 bar->info.battlevel = 100; 202#endif
205 if(TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) { 203 if(TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) {
206 bar->battery_charge_step=(bar->battery_charge_step+1)%4; 204 if (bar->animated_level == 100)
205 {
206 bar->animated_level = bar->info.battlevel;
207 }
208 else
209 {
210 bar->animated_level += 34;
211 if (bar->animated_level > 100)
212 bar->animated_level = 100;
213 }
207 bar->battery_icon_switch_tick = current_tick + HZ; 214 bar->battery_icon_switch_tick = current_tick + HZ;
208 } 215 }
209 } 216 }
@@ -211,6 +218,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
211 else 218 else
212#endif /* HAVE_CHARGING */ 219#endif /* HAVE_CHARGING */
213 { 220 {
221 bar->animated_level = 0;
214 if (bar->info.battery_safe) 222 if (bar->info.battery_safe)
215 battery_state = true; 223 battery_state = true;
216 else { 224 else {
@@ -224,7 +232,8 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
224 } 232 }
225#ifdef HAVE_LCD_BITMAP 233#ifdef HAVE_LCD_BITMAP
226 if (battery_state) 234 if (battery_state)
227 gui_statusbar_icon_battery(display, bar->info.battlevel); 235 gui_statusbar_icon_battery(display, bar->info.battlevel,
236 bar->animated_level);
228#ifdef HAVE_USB_POWER 237#ifdef HAVE_USB_POWER
229 if (bar->info.usb_power) 238 if (bar->info.usb_power)
230 display->mono_bitmap(bitmap_icons_7x8[Icon_USBPlug], 239 display->mono_bitmap(bitmap_icons_7x8[Icon_USBPlug],
@@ -316,11 +325,15 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
316/* 325/*
317 * Print battery icon to status bar 326 * Print battery icon to status bar
318 */ 327 */
319void gui_statusbar_icon_battery(struct screen * display, int percent) 328void gui_statusbar_icon_battery(struct screen * display, int percent,
329 int animated_percent)
320{ 330{
321 int fill; 331 int fill, endfill;
322 char buffer[5]; 332 char buffer[5];
323 unsigned int width, height; 333 unsigned int width, height;
334#if LCD_DEPTH > 1
335 unsigned int prevfg = LCD_DEFAULT_FG;
336#endif
324 337
325 /* fill battery */ 338 /* fill battery */
326 fill = percent; 339 fill = percent;
@@ -329,6 +342,12 @@ void gui_statusbar_icon_battery(struct screen * display, int percent)
329 if (fill > 100) 342 if (fill > 100)
330 fill = 100; 343 fill = 100;
331 344
345 endfill = animated_percent;
346 if (endfill < 0)
347 endfill = 0;
348 if (endfill > 100)
349 endfill = 100;
350
332#if (defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE)) && \ 351#if (defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE)) && \
333 !defined(SIMULATOR) /* Certain charge controlled targets */ 352 !defined(SIMULATOR) /* Certain charge controlled targets */
334 /* show graphical animation when charging instead of numbers */ 353 /* show graphical animation when charging instead of numbers */
@@ -358,6 +377,20 @@ void gui_statusbar_icon_battery(struct screen * display, int percent)
358 fill = fill * 15 / 100; 377 fill = fill * 15 / 100;
359 display->fillrect(STATUSBAR_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1, 378 display->fillrect(STATUSBAR_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1,
360 fill, 5); 379 fill, 5);
380#if LCD_DEPTH > 1
381 if (display->depth > 1)
382 {
383 prevfg = display->get_foreground();
384 display->set_foreground(LCD_DARKGRAY);
385 }
386#endif
387 endfill = endfill * 15 / 100 - fill;
388 display->fillrect(STATUSBAR_BATTERY_X_POS + 1 + fill,
389 STATUSBAR_Y_POS + 1, endfill, 5);
390#if LCD_DEPTH > 1
391 if (display->depth > 1)
392 display->set_foreground(prevfg);
393#endif
361 } 394 }
362 395
363 if (percent == -1) { 396 if (percent == -1) {