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-21 21:01:20 +0000
commita8ab038e023804fc256d1bfe8e97a331e503ba18 (patch)
tree1b86eb6ec2c42a422475b40e31897ff678108d9c
parent1b30dc54a2b9137d4584ba268e6178825f5237c1 (diff)
downloadchrome-ec-a8ab038e023804fc256d1bfe8e97a331e503ba18.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: I326731c46e61a953b445cd9eda875d7dab3da4dd 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/195847
-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 c4d4bb6bb7..6aade59f7b 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;