diff options
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/statusbar.c | 53 | ||||
-rw-r--r-- | apps/gui/statusbar.h | 12 |
2 files changed, 46 insertions, 19 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 | ||
117 | void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) | 115 | void 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 | */ |
319 | void gui_statusbar_icon_battery(struct screen * display, int percent) | 328 | void 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) { |
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 650b49d63b..03add6a6d9 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h | |||
@@ -53,9 +53,6 @@ struct status_info { | |||
53 | #ifdef HAVE_USB_POWER | 53 | #ifdef HAVE_USB_POWER |
54 | bool usb_power; | 54 | bool usb_power; |
55 | #endif | 55 | #endif |
56 | #ifdef HAVE_CHARGING | ||
57 | int battery_charge_step; | ||
58 | #endif | ||
59 | }; | 56 | }; |
60 | 57 | ||
61 | struct gui_statusbar | 58 | struct gui_statusbar |
@@ -63,12 +60,9 @@ struct gui_statusbar | |||
63 | /* Volume icon stuffs */ | 60 | /* Volume icon stuffs */ |
64 | long volume_icon_switch_tick; | 61 | long volume_icon_switch_tick; |
65 | int last_volume; | 62 | int last_volume; |
66 | 63 | ||
67 | long battery_icon_switch_tick; | 64 | long battery_icon_switch_tick; |
68 | 65 | int animated_level; | |
69 | #ifdef HAVE_CHARGING | ||
70 | int battery_charge_step; | ||
71 | #endif | ||
72 | 66 | ||
73 | struct status_info info; | 67 | struct status_info info; |
74 | struct status_info lastinfo; | 68 | struct status_info lastinfo; |
@@ -101,7 +95,7 @@ extern void gui_statusbar_init(struct gui_statusbar * bar); | |||
101 | */ | 95 | */ |
102 | extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw); | 96 | extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw); |
103 | 97 | ||
104 | void gui_statusbar_icon_battery(struct screen * display, int percent); | 98 | void gui_statusbar_icon_battery(struct screen * display, int percent, int animated_percent); |
105 | bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume); | 99 | bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume); |
106 | void gui_statusbar_icon_play_state(struct screen * display, int state); | 100 | void gui_statusbar_icon_play_state(struct screen * display, int state); |
107 | void gui_statusbar_icon_play_mode(struct screen * display, int mode); | 101 | void gui_statusbar_icon_play_mode(struct screen * display, int mode); |