diff options
author | Hsu Henry <Henry.Hsu@quantatw.com> | 2014-10-14 09:05:17 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-10-14 20:34:57 +0000 |
commit | 750f52225fe5894ffdc38672d7d80ad56da95cd5 (patch) | |
tree | 950ad1c56976f66a490f26fb18df9155a4063191 | |
parent | 685b5d2fb561d0b0af2c7c0f50323b4db266f6af (diff) | |
download | chrome-ec-750f52225fe5894ffdc38672d7d80ad56da95cd5.tar.gz |
Paine: add led support.
Implement the led behavior based on customer SPEC.
BUG=chrome-os-partner:32802
BRANCH=paine
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: Id0dc3dc0507309ee050d760fc50344ef64688d73
Signed-off-by: Henry Hsu <Henry.Hsu@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/223014
Reviewed-by: Mohammed Habibulla <moch@chromium.org>
-rw-r--r-- | board/paine/led.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/board/paine/led.c b/board/paine/led.c index 15345fbf24..5cd9818731 100644 --- a/board/paine/led.c +++ b/board/paine/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 paine_led_set_power(void) /* Blink once every four seconds. */ paine_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 paine_led_set_battery(void) paine_led_set_color_battery(LED_BLUE); break; case PWR_STATE_DISCHARGE: - paine_led_set_color_battery(LED_OFF); + /* Less than 3%, blink one second every two seconds */ + if (charge_get_percent() < BATTERY_LEVEL_SHUTDOWN) + paine_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) + paine_led_set_color_battery( + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + else + paine_led_set_color_battery(LED_OFF); break; case PWR_STATE_ERROR: paine_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) paine_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 paine_led_set_color_battery(LED_BLUE); break; |