diff options
Diffstat (limited to 'board/scarlet/led.c')
-rw-r--r-- | board/scarlet/led.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/board/scarlet/led.c b/board/scarlet/led.c index d327ee46d6..6f42f462cf 100644 --- a/board/scarlet/led.c +++ b/board/scarlet/led.c @@ -1,4 +1,4 @@ -/* Copyright 2017 The Chromium OS Authors. All rights reserved. +/* Copyright 2017 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -28,7 +28,7 @@ enum led_color { LED_RED, LED_AMBER, LED_GREEN, - LED_COLOR_COUNT /* Number of colors, not a color itself */ + LED_COLOR_COUNT /* Number of colors, not a color itself */ }; static int bat_led_set_color(enum led_color color) @@ -69,13 +69,13 @@ static void scarlet_led_set_battery(void) break; case PWR_STATE_DISCHARGE: if (charge_get_percent() < 3) - bat_led_set_color((battery_second & 1) - ? LED_OFF : LED_AMBER); + bat_led_set_color((battery_second & 1) ? LED_OFF : + LED_AMBER); else if (charge_get_percent() < 10) - bat_led_set_color((battery_second & 3) - ? LED_OFF : LED_AMBER); + bat_led_set_color((battery_second & 3) ? LED_OFF : + LED_AMBER); else if (charge_get_percent() >= BATTERY_LEVEL_NEAR_FULL && - (chflags & CHARGE_FLAG_EXTERNAL_POWER)) + (chflags & CHARGE_FLAG_EXTERNAL_POWER)) bat_led_set_color(LED_GREEN); else bat_led_set_color(LED_OFF); @@ -87,11 +87,11 @@ static void scarlet_led_set_battery(void) bat_led_set_color(LED_GREEN); break; case PWR_STATE_IDLE: /* External power connected in IDLE. */ - if (chflags & CHARGE_FLAG_FORCE_IDLE) - bat_led_set_color( - (battery_second & 0x2) ? LED_GREEN : LED_AMBER); - else - bat_led_set_color(LED_GREEN); + bat_led_set_color(LED_GREEN); + break; + case PWR_STATE_FORCED_IDLE: + bat_led_set_color((battery_second & 0x2) ? LED_GREEN : + LED_AMBER); break; default: /* Other states don't alter LED behavior */ @@ -112,10 +112,12 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) if (led_id == EC_LED_ID_BATTERY_LED) { gpio_set_level(GPIO_BAT_LED_RED, (brightness[EC_LED_COLOR_RED] != 0) ? - BAT_LED_ON : BAT_LED_OFF); + BAT_LED_ON : + BAT_LED_OFF); gpio_set_level(GPIO_BAT_LED_GREEN, (brightness[EC_LED_COLOR_GREEN] != 0) ? - BAT_LED_ON : BAT_LED_OFF); + BAT_LED_ON : + BAT_LED_OFF); return EC_SUCCESS; } return EC_ERROR_UNKNOWN; |