From 6ff7a74006d5b4ee74091e196d81c17bb8bb0578 Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Thu, 6 Feb 2014 12:33:26 -0800 Subject: rambi: Update LED charging algorithm Green when charged and ext. power plugged in. Orange when charging. Blinking orange if there is a charging/battery related error. Blinking green if in "charge force idle mode" in the factory. Off otherwise. BUG=chrome-os-partner:23634 BRANCH=rambi TEST=test each of the states above To fake battery error, unplug battery and wait 30 secs To force idle, 'ectool chargecontrol idle' Change-Id: I85fff72d1df85bbbaa1da66572f44f58a960244e Signed-off-by: Randall Spangler Reviewed-on: https://chromium-review.googlesource.com/185240 Reviewed-by: Dave Parker --- board/rambi/led.c | 48 +++++++++--------------------------------------- 1 file changed, 9 insertions(+), 39 deletions(-) diff --git a/board/rambi/led.c b/board/rambi/led.c index 189c179810..5e3e2edb37 100644 --- a/board/rambi/led.c +++ b/board/rambi/led.c @@ -19,9 +19,9 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); enum led_color { LED_OFF = 0, LED_RED, + LED_ORANGE, LED_YELLOW, LED_GREEN, - LED_DIM_GREEN, /* Number of colors, not a color itself */ LED_COLOR_COUNT @@ -31,9 +31,9 @@ enum led_color { static const uint8_t color_brightness[LED_COLOR_COUNT][2] = { {0, 0}, {100, 0}, - {40, 80}, + {30, 45}, + {20, 60}, {0, 100}, - {0, 10}, }; /** @@ -80,31 +80,18 @@ DECLARE_HOOK(HOOK_INIT, led_init, HOOK_PRIO_DEFAULT); */ static void led_tick(void) { - static int suspended_prev; static unsigned ticks; - int blink_on; - - int suspended = chipset_in_state(CHIPSET_STATE_SUSPEND); int chstate = charge_get_state(); + ticks++; + /* If we don't control the LED, nothing to do */ if (!led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) return; - /* If we're just suspending now, reset ticks so LED changes quickly */ - if (suspended && !suspended_prev) - ticks = 0; - else - ticks++; - - suspended_prev = suspended; - - /* Blink with 25% duty cycle, 4 sec period */ - blink_on = ticks % 16 < 4; - - /* If charging error, blink red */ + /* If charging error, blink orange, 25% duty cycle, 4 sec period */ if (chstate == PWR_STATE_ERROR) { - set_color(blink_on ? LED_RED : LED_OFF); + set_color((ticks % 16) < 4 ? LED_ORANGE : LED_OFF); return; } @@ -115,20 +102,9 @@ static void led_tick(void) return; } - /* - * If the system is charging, solid yellow. - * - * Note that this means you can't distinguish power states - * (on/suspend/off) when the system is charging. - */ + /* If the system is charging, solid orange */ if (chstate == PWR_STATE_CHARGE) { - set_color(LED_YELLOW); - return; - } - - /* If suspended, blink yellow */ - if (suspended) { - set_color(blink_on ? LED_YELLOW : LED_OFF); + set_color(LED_ORANGE); return; } @@ -139,12 +115,6 @@ static void led_tick(void) return; } - /* If powered on, dim green (just as an indicator we're on) */ - if (chipset_in_state(CHIPSET_STATE_ON)) { - set_color(LED_DIM_GREEN); - return; - } - /* Otherwise, system is off and AC not connected, LED off */ set_color(LED_OFF); } -- cgit v1.2.1