diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-10-29 14:12:07 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-08 00:48:02 -0800 |
commit | ba92cadcf87075d80e065bfe606286d1885817b1 (patch) | |
tree | bfea75008b8a90bfe20376e28766baba8085c4dc | |
parent | 776eadc1b4b1a92688c441cbebfacf1eea6471fc (diff) | |
download | chrome-ec-ba92cadcf87075d80e065bfe606286d1885817b1.tar.gz |
chgstv2: Notify on display percentage change
This patch makes the charger task v2 notify HOOK_BATTERY_SOC_CHANGE
handlers when the display charge percentage changes. This allows EC
to update LEDs synchronously to the number on the display.
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:109954565,b:80270446
BRANCH=none
TEST=Verify charge LED changes to white (full) on Sona synchronously
to the display percentage.
TEST=Verify charge LED changes to blinking white (low) on Sona
within 30 seconds synchronously to the display percentage.
Change-Id: Ib2c587ad3307fe62b268a25a93344c88c6c137f3
Reviewed-on: https://chromium-review.googlesource.com/1309034
Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | common/charge_state_v2.c | 21 | ||||
-rw-r--r-- | include/charge_state.h | 5 |
2 files changed, 21 insertions, 5 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index aed3e02ad0..bdba1218bf 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -78,7 +78,7 @@ static int charge_request(int voltage, int current); static const struct battery_info *batt_info; static struct charge_state_data curr; static enum charge_state_v2 prev_state; -static int prev_ac, prev_charge, prev_full; +static int prev_ac, prev_charge, prev_full, prev_disp_charge; static enum battery_present prev_bp; static int is_full; /* battery not accepting current */ static enum ec_charge_control_mode chg_ctl_mode; @@ -1109,13 +1109,17 @@ static void show_charging_progress(void) #endif if (rv) - CPRINTS("Battery %d%% / ??h:?? %s%s", + CPRINTS("Battery %d%% (Display %d.%d %%) / ??h:?? %s%s", curr.batt.state_of_charge, + curr.batt.display_charge / 10, + curr.batt.display_charge % 10, to_full ? "to full" : "to empty", is_full ? ", not accepting current" : ""); else - CPRINTS("Battery %d%% / %dh:%d %s%s", + CPRINTS("Battery %d%% (Display %d.%d %%) / %dh:%d %s%s", curr.batt.state_of_charge, + curr.batt.display_charge / 10, + curr.batt.display_charge % 10, minutes / 60, minutes % 60, to_full ? "to full" : "to empty", is_full ? ", not accepting current" : ""); @@ -1510,7 +1514,7 @@ void charger_task(void *u) /* Get the battery-specific values */ batt_info = battery_get_info(); - prev_ac = prev_charge = -1; + prev_ac = prev_charge = prev_disp_charge = -1; chg_ctl_mode = CHARGE_CONTROL_NORMAL; shutdown_warning_time.val = 0UL; battery_seems_to_be_dead = 0; @@ -1813,9 +1817,11 @@ wait_for_it: (charge_base != prev_charge_base) || #endif (is_full != prev_full) || - (curr.state != prev_state)) { + (curr.state != prev_state) || + (curr.batt.display_charge != prev_disp_charge)) { show_charging_progress(); prev_charge = curr.batt.state_of_charge; + prev_disp_charge = curr.batt.display_charge; #ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER prev_charge_base = charge_base; #endif @@ -2118,6 +2124,11 @@ int charge_get_percent(void) return is_full ? 100 : curr.batt.state_of_charge; } +int charge_get_display_charge(void) +{ + return curr.batt.display_charge; +} + int charge_get_battery_temp(int idx, int *temp_ptr) { if (curr.batt.flags & BATT_FLAG_BAD_TEMPERATURE) diff --git a/include/charge_state.h b/include/charge_state.h index bcf9071d6b..e19a2a9ab1 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -92,6 +92,11 @@ uint32_t charge_get_flags(void); int charge_get_percent(void); /** + * Return current display charge in 10ths of a percent (e.g. 1000 = 100.0%) + */ +int charge_get_display_charge(void); + +/** * Check if board is consuming full input current * * This returns true if the battery charge percentage is between 2% and 95% |