diff options
-rw-r--r-- | board/paine/led.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/board/paine/led.c b/board/paine/led.c index 15345fbf24..5cd9818731 100644 --- a/board/paine/led.c +++ b/board/paine/led.c @@ -15,8 +15,10 @@ #include "led_common.h" #include "util.h" -#define LED_TOTAL_TICKS 16 -#define LED_ON_TICKS 4 +#define LED_TOTAL_4SECS_TICKS 16 +#define LED_TOTAL_2SECS_TICKS 8 +#define LED_ON_1SEC_TICKS 4 +#define LED_ON_2SECS_TICKS 8 enum led_color { LED_OFF = 0, @@ -124,8 +126,8 @@ static void paine_led_set_power(void) /* Blink once every four seconds. */ paine_led_set_color_power( - (power_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? - LED_AMBER : LED_OFF); + (power_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); previous_state_suspend = 1; return; @@ -154,17 +156,29 @@ static void paine_led_set_battery(void) paine_led_set_color_battery(LED_BLUE); break; case PWR_STATE_DISCHARGE: - paine_led_set_color_battery(LED_OFF); + /* Less than 3%, blink one second every two seconds */ + if (charge_get_percent() < BATTERY_LEVEL_SHUTDOWN) + paine_led_set_color_battery( + (battery_ticks % LED_TOTAL_2SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + /* Less than 10%, blink one second every four seconds */ + else if (charge_get_percent() < BATTERY_LEVEL_LOW) + paine_led_set_color_battery( + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); + else + paine_led_set_color_battery(LED_OFF); break; case PWR_STATE_ERROR: paine_led_set_color_battery( - (battery_ticks % LED_TOTAL_TICKS < LED_ON_TICKS) ? - LED_AMBER : LED_OFF); + (battery_ticks % LED_TOTAL_2SECS_TICKS < + LED_ON_1SEC_TICKS) ? LED_AMBER : LED_OFF); break; case PWR_STATE_IDLE: /* External power connected in IDLE. */ if (chflags & CHARGE_FLAG_FORCE_IDLE) paine_led_set_color_battery( - (battery_ticks & 0x4) ? LED_BLUE : LED_OFF); + (battery_ticks % LED_TOTAL_4SECS_TICKS < + LED_ON_2SECS_TICKS) ? LED_BLUE : LED_AMBER); else paine_led_set_color_battery(LED_BLUE); break; |