Coachz: Modify Battery LED behavior
Modify Battery LED behavior based on spec
BRANCH=master
TEST=make BOARD=coachz -j
flash ec and check Battery LED behavior
#include "led_common.h"
#include "system.h"
#include "util.h"
+#include "extpower.h"
#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
+/* Battery LED blinks every per 400ms */
+#define LED_HALF_ONE_SEC (500 / HOOK_TICK_INTERVAL_MS)
#define BAT_LED_ON 1
#define BAT_LED_OFF 0
@@ -77,33 +80,62 @@ static void board_led_set_battery(void)
break;
case PWR_STATE_DISCHARGE:
if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
- /* Discharging in S3: Amber 1 sec, off 3 sec */
- period = (1 + 3) * LED_ONE_SEC;
+ /* Discharging in S3: White 1 sec, off 1 sec */
+ period = (1 + 1) * LED_ONE_SEC;
+ battery_ticks = battery_ticks % period;
+ if (battery_ticks < 1 * LED_ONE_SEC) {
+ if (charge_get_percent() < 10)
+ {
+ /* Blink amber light (1 sec on, 1 sec off) */
+ color = LED_AMBER;
+ }
+ else
+ {
+ /* Blink white light (1 sec on, 1 sec off) */
+ color = LED_BLUE;
+ }
+ } else {
+ color = LED_OFF;
+ }
+ } else {
+ /* Discharging in S5 and S0: off */
+ /* Blink amber light (1 sec on, 1 sec off) */
+ if (charge_get_percent() < 10) {
+ period = (1 + 1) * LED_ONE_SEC;
battery_ticks = battery_ticks % period;
if (battery_ticks < 1 * LED_ONE_SEC)
color = LED_AMBER;
else
color = LED_OFF;
- } else if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
- /* Discharging in S5: off */
+ } else {
+ /* G3 or S5 or S0: off */
color = LED_OFF;
- } else if (chipset_in_state(CHIPSET_STATE_ON)) {
- /* Discharging in S0: Blue on */
- color = LED_BLUE;
+ }
}
break;
case PWR_STATE_ERROR:
- /* Battery error: Amber 1 sec, off 1 sec */
- period = (1 + 1) * LED_ONE_SEC;
+ /* Battery error: Amber on 0.5 sec, off 0.5 sec */
+ period = (1 + 1) * LED_HALF_ONE_SEC;
battery_ticks = battery_ticks % period;
- if (battery_ticks < 1 * LED_ONE_SEC)
+ if (battery_ticks < 1 * LED_HALF_ONE_SEC)
color = LED_AMBER;
else
color = LED_OFF;
break;
case PWR_STATE_CHARGE_NEAR_FULL:
/* Full Charged: Blue on */
+ /* S3: Blink white light (1 sec on, 1 sec off) */
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
+ period = (1 + 1) * LED_ONE_SEC;
+ battery_ticks = battery_ticks % period;
+ if (battery_ticks < 1 * LED_ONE_SEC)
+ color = LED_BLUE;
+ else
+ color = LED_OFF;
+ } else {
+ /* Full charged: White on */
color = LED_BLUE;
+ }
break;
case PWR_STATE_IDLE: /* External power connected in IDLE */
if (chflags & CHARGE_FLAG_FORCE_IDLE) {
