diff options
-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 4291e5f9bc..64fc7332ac 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -79,7 +79,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; @@ -1146,13 +1146,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" : ""); @@ -1572,7 +1576,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; @@ -1875,9 +1879,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 @@ -2180,6 +2186,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 4ac41cbe4d..7d71c68cd2 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -99,6 +99,11 @@ int board_get_battery_soc(void); #endif /** + * 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% |