diff options
author | Hsu Henry <Henry.Hsu@quantatw.com> | 2014-10-13 16:30:12 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-13 22:51:48 +0000 |
commit | 685b5d2fb561d0b0af2c7c0f50323b4db266f6af (patch) | |
tree | b9565a4b3584a96bf78bb8d590807b18968ddb32 | |
parent | aa0ad27cf26c6b796a60ff0c20f2fc62f847a538 (diff) | |
download | chrome-ec-685b5d2fb561d0b0af2c7c0f50323b4db266f6af.tar.gz |
Yuna: add led support.
Implement the led behavior based on customer SPEC.
BUG=chrome-os-partner:32802
BRANCH=yuna
TEST=See below.
RSOC AC battery led note
<97 in amber charging
>=97 in blue near full/idle
<97 out off discharge
>=10
<10 out amber 1s on/3s off low battery
<3 out amber 1s on/1s off critical low battery
Run "ectool chargecontrol idle" make the led "2s on amber, 2s on blue".
Disconnect the battery, the led "amber 1s on/1s off".
Change-Id: I047a52dacf87935ea9e04be8b7fbb1695d32edb2
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/223050
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
-rw-r--r-- | board/yuna/led.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/board/yuna/led.c b/board/yuna/led.c index 35915d230d..8e736c2d5d 100644 --- a/board/yuna/led.c +++ b/board/yuna/led.c @@ -15,8 +15,10 @@ #include "led_common.h" #include "util.h" -#define LED_TOTAL_TICKS 16 -#define LED_ON_TICKS 4 +#define LED_TOTAL_4SECS_TICKS 16 +#define LED_TOTAL_2SECS_TICKS 8 +#define LED_ON_1SEC_TICKS 4 +#define LED_ON_2SECS_TICKS 8 enum led_color { LED_OFF = 0, @@ -124,8 +126,8 @@ static void yuna_led_set_power(void) /* Blink once every four seconds. */ yuna_led_set_color_power( - (power_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? - LED_AMBER : LED_OFF); + (power_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); previous_state_suspend = 1; return; @@ -154,17 +156,29 @@ static void yuna_led_set_battery(void) yuna_led_set_color_battery(LED_BLUE); break; case PWR_STATE_DISCHARGE: - yuna_led_set_color_battery(LED_OFF); + /* Less than 3%, blink one second every two seconds */ + if (charge_get_percent() < BATTERY_LEVEL_SHUTDOWN) + yuna_led_set_color_battery( + (battery_ticks % LED_TOTAL_2SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + /* Less than 10%, blink one second every four seconds */ + else if (charge_get_percent() < BATTERY_LEVEL_LOW) + yuna_led_set_color_battery( + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + else + yuna_led_set_color_battery(LED_OFF); break; case PWR_STATE_ERROR: yuna_led_set_color_battery( - (battery_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? - LED_AMBER : LED_OFF); + (battery_ticks % LED_TOTAL_2SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); break; case PWR_STATE_IDLE: /* External power connected in IDLE. */ if (chflags & CHARGE_FLAG_FORCE_IDLE) yuna_led_set_color_battery( - (battery_ticks & 0x4) ? LED_BLUE : LED_OFF); + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_2SECS_TICKS) ? LED_BLUE : LED_AMBER); else yuna_led_set_color_battery(LED_BLUE); break; |