From 4b530d9fce5f939e4470adc6fcb7e5ee833c509d Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Fri, 11 Apr 2014 13:38:54 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/194347 Reviewed-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/195848 --- board/squawks/led.c | 17 ++++++++++++----- 1 file 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; -- cgit v1.2.1