summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parker <dparker@chromium.org>2014-04-11 13:38:54 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-04-22 00:47:29 +0000
commit4b530d9fce5f939e4470adc6fcb7e5ee833c509d (patch)
tree2a4dff38660d2c8032e0ae677d38ca16bb1f6de8
parent58878e79e07f33050d6ff8d280e5db63b5902e10 (diff)
downloadchrome-ec-4b530d9fce5f939e4470adc6fcb7e5ee833c509d.tar.gz
Squawks: Adjust charge thresholds for altering LED behavior
The EC and host have different ways of computing and presenting the battery charge level. This change adjusts the charge levels at which the charging LED indicates a full and low battery to match what is presented to the user in the host UI. BUG=chrome-os-partner:27743,chrome-os-partner:27746 BRANCH=rambi,tot TEST=Run "battfake 91" which charging, verify charging LED turns green and the UI reports 95%. Run "battfake 13" while discharging, verify charging LED blinks amber (1 sec on, 1 sec off) and the UI reports 10%. Change-Id: Iaffffb57a7fbfd14ebb90363cbd4aa1a9becf022 Original-Change-Id: I203c90a65e4aa2907a14077a9276674ecfa292f2 Signed-off-by: Dave Parker <dparker@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/194347 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/195848
-rw-r--r--board/squawks/led.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/board/squawks/led.c b/board/squawks/led.c
index 6b2f3ffe25..970ca89306 100644
--- a/board/squawks/led.c
+++ b/board/squawks/led.c
@@ -130,9 +130,12 @@ static enum led_color new_battery_led_color(void)
(charge_get_flags() & CHARGE_FLAG_FORCE_IDLE))
return (ticks & 0x4) ? LED_GREEN : LED_OFF;
- /* If the system is charging, orange under 95%; green if over */
+ /*
+ * If the system is charging, orange; green if 95% or over.
+ * Subtract 5% to compensate for how the UI reports charge remaining.
+ */
if (chstate == PWR_STATE_CHARGE)
- return charge_get_percent() < 95 ? LED_ORANGE : LED_GREEN;
+ return charge_get_percent() < 90 ? LED_ORANGE : LED_GREEN;
/* If AC connected and fully charged (or close to it), solid green */
if (chstate == PWR_STATE_CHARGE_NEAR_FULL ||
@@ -140,9 +143,13 @@ static enum led_color new_battery_led_color(void)
return LED_GREEN;
}
- /* Otherwise, discharging; flash orange if less than 10% power */
- if (charge_get_percent() < 10)
- return (ticks % 8 < 2) ? LED_ORANGE : LED_OFF;
+ /*
+ * Otherwise, discharging; flash orange if 10% or less power, 50%
+ * duty cycle, 2 sec period. Adding 4% bias to compensate for how
+ * the UI reports charge remaining.
+ */
+ if (charge_get_percent() < 14)
+ return (ticks & 0x4) ? LED_ORANGE : LED_OFF;
/* Discharging and greater than 10% power, so off */
return LED_OFF;