mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
lucid: fix LED charge state
When the device is discharging, but has a battery percentage greater than 97 show a solid green LED. BUG=chrome-os-partner:48661 BRANCH=none TEST=make BOARD=lucid Change-Id: Ia5c0946fbc47e37a295db3419a0edf925aacf484 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/322738 Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
|
||||
#define CRITICAL_LOW_BATTERY_PERCENTAGE 5
|
||||
#define LOW_BATTERY_PERCENTAGE 20
|
||||
#define HIGH_BATTERY_PERCENTAGE 95
|
||||
#define HIGH_BATTERY_PERCENTAGE 97
|
||||
|
||||
#define LED_TOTAL_2SECS_TICKS 2
|
||||
#define LED_ON_1SEC_TICKS 1
|
||||
@@ -122,6 +122,7 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
|
||||
static void lucid_update_charge_display(void)
|
||||
{
|
||||
uint32_t chflags = charge_get_flags();
|
||||
int charge_percent;
|
||||
|
||||
/* BAT LED behavior:
|
||||
* Fully charged: Green
|
||||
@@ -137,17 +138,20 @@ static void lucid_update_charge_display(void)
|
||||
LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF);
|
||||
break;
|
||||
case PWR_STATE_DISCHARGE:
|
||||
if (charge_get_percent() < CRITICAL_LOW_BATTERY_PERCENTAGE)
|
||||
charge_percent = charge_get_percent();
|
||||
if (charge_percent < CRITICAL_LOW_BATTERY_PERCENTAGE)
|
||||
/* Blink once every two seconds */
|
||||
lucid_led_set_color_battery(
|
||||
(battery_ticks % LED_TOTAL_2SECS_TICKS <
|
||||
LED_ON_1SEC_TICKS) ? LED_RED : LED_OFF);
|
||||
else if (!led_enabled)
|
||||
lucid_led_set_color_battery(LED_OFF);
|
||||
else if (charge_get_percent() < LOW_BATTERY_PERCENTAGE)
|
||||
else if (charge_percent < LOW_BATTERY_PERCENTAGE)
|
||||
lucid_led_set_color_battery(LED_RED);
|
||||
else
|
||||
else if (charge_percent < HIGH_BATTERY_PERCENTAGE)
|
||||
lucid_led_set_color_battery(LED_AMBER);
|
||||
else
|
||||
lucid_led_set_color_battery(LED_GREEN);
|
||||
break;
|
||||
case PWR_STATE_ERROR:
|
||||
lucid_led_set_color_battery(
|
||||
|
||||
Reference in New Issue
Block a user