mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
Add hysteresis to host events for battery capacity changed
Adds a small threshold for sending a host event to battery whenever the full capacity changes. This helps avoid constant host events when the battery decides the capacity is going back and forth 1mAh BUG=none BRANCH=none TEST=load on samus. set LFCC_EVENT_THRESHOLD to 1 and see host events very often. set LFCC_EVENT_THRESHOLD to 5 and see no host events. Change-Id: I2dc38f04e1a634539837dfed19b10ccfcfd0a8a3 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213668 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
e307172bd5
commit
1b82905cfe
@@ -29,6 +29,7 @@
|
||||
|
||||
#define LOW_BATTERY_SHUTDOWN_TIMEOUT_US (LOW_BATTERY_SHUTDOWN_TIMEOUT * SECOND)
|
||||
#define PRECHARGE_TIMEOUT_US (PRECHARGE_TIMEOUT * SECOND)
|
||||
#define LFCC_EVENT_THRESH 5 /* Full-capacity change reqd for host event */
|
||||
|
||||
/*
|
||||
* State for charger_task(). Here so we can reset it on a HOOK_INIT, and
|
||||
@@ -187,7 +188,8 @@ static void update_dynamic_battery_info(void)
|
||||
|
||||
cap_changed = 0;
|
||||
if (!(curr.batt.flags & BATT_FLAG_BAD_FULL_CAPACITY) &&
|
||||
curr.batt.full_capacity != *memmap_lfcc) {
|
||||
(curr.batt.full_capacity <= (*memmap_lfcc - LFCC_EVENT_THRESH) ||
|
||||
curr.batt.full_capacity >= (*memmap_lfcc + LFCC_EVENT_THRESH))) {
|
||||
*memmap_lfcc = curr.batt.full_capacity;
|
||||
cap_changed = 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user