From be17ca9d91d097f2ec742393e7c69928f46f1e17 Mon Sep 17 00:00:00 2001 From: Louis Yung-Chieh Lo Date: Wed, 12 Mar 2014 18:21:39 -0700 Subject: big: fixed a LED corner case while almost full Vic points out a corner case that the battery LED could be off by the followng steps: 1. charge the battery to very full 2. disconnact the AC so that the LED is off for discharge. 3. plug AC again, then charger enters INIT state --> IDLE0 --> IDLE where those states don't toggle LED. BUG=none BRANCH=big TEST=Reproduced this bug on big. Verified this has been fixed by this CL. Change-Id: I7125acd6b11953675ac6d4085e31e0560b384015 Signed-off-by: Louis Yung-Chieh Lo Reviewed-on: https://chromium-review.googlesource.com/189757 --- board/big/led.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/board/big/led.c b/board/big/led.c index 0d3b33567d..82c9de6b55 100644 --- a/board/big/led.c +++ b/board/big/led.c @@ -121,11 +121,13 @@ static void big_led_set_power(void) static void big_led_set_battery(void) { static int battery_second; + uint32_t chflags = charge_get_flags(); battery_second++; /* BAT LED behavior: - * Fully charged: Blue + * Fully charged / idle: Blue + * Force idle (for factory): 2 secs of blue, 2 secs of yellow * Under charging: Orange * Battery low (10%): Orange in breeze mode (1 sec on, 3 sec off) * Battery critical low (less than 3%) or abnormal battery @@ -152,6 +154,13 @@ static void big_led_set_battery(void) case PWR_STATE_CHARGE_NEAR_FULL: bat_led_set_color(LED_BLUE); break; + case PWR_STATE_IDLE: /* External power connected in IDLE. */ + if (chflags & CHARGE_FLAG_FORCE_IDLE) + bat_led_set_color( + (battery_second & 0x2) ? LED_BLUE : LED_ORANGE); + else + bat_led_set_color(LED_BLUE); + break; default: /* Other states don't alter LED behavior */ break; -- cgit v1.2.1