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 <yjlou@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/189757
This commit is contained in:
Louis Yung-Chieh Lo
2014-03-12 18:21:39 -07:00
committed by chrome-internal-fetch
parent daeddb75e9
commit be17ca9d91

View File

@@ -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;