diff options
Diffstat (limited to 'healthd/healthd_mode_charger.cpp')
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 6800ad2..355c638 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -65,7 +65,7 @@ char *locale; #define BATTERY_UNKNOWN_TIME (2 * MSEC_PER_SEC) #define POWER_ON_KEY_TIME (2 * MSEC_PER_SEC) -#define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC) +#define UNPLUGGED_SHUTDOWN_TIME (1 * MSEC_PER_SEC) #define BATTERY_FULL_THRESH 95 @@ -314,6 +314,7 @@ static void draw_battery(struct charger *charger) batt_anim->cur_frame, frame->min_capacity, frame->disp_time); } + healthd_board_mode_charger_draw_battery(batt_prop); } static void redraw_screen(struct charger *charger) @@ -367,6 +368,7 @@ static void update_screen_state(struct charger *charger, int64_t now) gr_font_size(&char_width, &char_height); #ifndef CHARGER_DISABLE_INIT_BLANK + healthd_board_mode_charger_set_backlight(false); gr_fb_blank(true); #endif minui_inited = true; @@ -376,6 +378,7 @@ static void update_screen_state(struct charger *charger, int64_t now) if (batt_anim->cur_cycle == batt_anim->num_cycles) { reset_animation(batt_anim); charger->next_screen_transition = -1; + healthd_board_mode_charger_set_backlight(false); gr_fb_blank(true); LOGV("[%" PRId64 "] animation done\n", now); if (charger->charger_connected) @@ -406,9 +409,11 @@ static void update_screen_state(struct charger *charger, int64_t now) batt_anim->capacity = batt_prop->batteryLevel; } - /* unblank the screen on first cycle */ - if (batt_anim->cur_cycle == 0) + /* unblank the screen on first cycle */ + if (batt_anim->cur_cycle == 0) { gr_fb_blank(false); + healthd_board_mode_charger_set_backlight(true); + } /* draw the new frame (@ cur_frame) */ redraw_screen(charger); @@ -508,6 +513,7 @@ static void set_next_key_check(struct charger *charger, static void process_key(struct charger *charger, int code, int64_t now) { + struct animation *batt_anim = charger->batt_anim; struct key_state *key = &charger->keys[code]; if (code == KEY_POWER) { @@ -534,17 +540,25 @@ static void process_key(struct charger *charger, int code, int64_t now) * make sure we wake up at the right-ish time to check */ set_next_key_check(charger, key, POWER_ON_KEY_TIME); - - /* Turn on the display and kick animation on power-key press - * rather than on key release - */ - kick_animation(charger->batt_anim); - request_suspend(false); } } else { - /* if the power key got released, force screen state cycle */ if (key->pending) { - kick_animation(charger->batt_anim); + /* If key is pressed when the animation is not running, kick + * the animation and quite suspend; If key is pressed when + * the animation is running, turn off the animation and request + * suspend. + */ + if (!batt_anim->run) { + kick_animation(batt_anim); + request_suspend(false); + } else { + reset_animation(batt_anim); + charger->next_screen_transition = -1; + healthd_board_mode_charger_set_backlight(false); + gr_fb_blank(true); + if (charger->charger_connected) + request_suspend(true); + } } } } @@ -565,6 +579,8 @@ static void handle_power_supply_state(struct charger *charger, int64_t now) if (!charger->have_battery_state) return; + healthd_board_mode_charger_battery_update(batt_prop); + if (!charger->charger_connected) { /* Last cycle would have stopped at the extreme top of battery-icon @@ -683,6 +699,8 @@ void healthd_mode_charger_init(struct healthd_config* config) LOGW("--------------- STARTING CHARGER MODE ---------------\n"); + healthd_board_mode_charger_init(); + ret = ev_init(input_callback, charger); if (!ret) { epollfd = ev_get_epollfd(); |