mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 18:11:05 +00:00
charge_state_v2: Correct Smart battery charging/discharging status
AverageTimeToFull() and AverageTimeToEmpty() are the predicted time based
on the AverageCurrent(), these do not reflect the instant time of charging
or discharging. Hence we observe huge number of time (1092h because
register has 65535) to full time when battery starts accepting current
upon reaching 100%. To overcome this issue, explicitly checking if the
AverageTimeToFull() and AverageTimeToEmpty() register values are updated
with the valid data.
BUG=chrome-os-partner:60802
BRANCH=none
TEST=Manually tested on Reef. Charge the battery to 100%, once the
battery starts accepting current again observed time to full
is not huge number.
Change-Id: I6d6c21b72ab824dbe47e44e1e77f1c5319ac2720
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/425324
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
4fa1c8b9e3
commit
7db78001c2
@@ -314,8 +314,31 @@ static void dump_charge_state(void)
|
||||
|
||||
static void show_charging_progress(void)
|
||||
{
|
||||
int rv, minutes, to_full;
|
||||
int rv = 0, minutes, to_full;
|
||||
|
||||
#ifdef CONFIG_BATTERY_SMART
|
||||
/*
|
||||
* Predicted remaining battery capacity based on AverageCurrent().
|
||||
* 65535 = Battery is not being discharged.
|
||||
*/
|
||||
if (!battery_time_to_empty(&minutes) && minutes != 65535)
|
||||
to_full = 0;
|
||||
/*
|
||||
* Predicted time-to-full charge based on AverageCurrent().
|
||||
* 65535 = Battery is not being discharged.
|
||||
*/
|
||||
else if (!battery_time_to_full(&minutes) && minutes != 65535)
|
||||
to_full = 1;
|
||||
/*
|
||||
* If both time to empty and time to full have invalid data, consider
|
||||
* measured current from the coulomb counter and ac present status to
|
||||
* decide whether battery is about to full or empty.
|
||||
*/
|
||||
else {
|
||||
to_full = curr.batt_is_charging;
|
||||
rv = EC_ERROR_UNKNOWN;
|
||||
}
|
||||
#else
|
||||
if (!curr.batt_is_charging) {
|
||||
rv = battery_time_to_empty(&minutes);
|
||||
to_full = 0;
|
||||
@@ -323,6 +346,7 @@ static void show_charging_progress(void)
|
||||
rv = battery_time_to_full(&minutes);
|
||||
to_full = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rv)
|
||||
CPRINTS("Battery %d%% / ??h:?? %s%s",
|
||||
|
||||
Reference in New Issue
Block a user