summaryrefslogtreecommitdiff
path: root/board/coachz
diff options
context:
space:
mode:
authorgaochao <gaochao@huaqin.corp-partner.google.com>2020-11-12 21:41:13 +0800
committerCommit Bot <commit-bot@chromium.org>2020-11-19 04:39:30 +0000
commitd948513ac0caecfb1a68cec320ed9d71ee4126e3 (patch)
tree5a4c3900bebae7bb3541ad396326cbfee1e8e677 /board/coachz
parent8c51f8e778f11535c49d2636fd0a768b99a0374c (diff)
downloadchrome-ec-d948513ac0caecfb1a68cec320ed9d71ee4126e3.tar.gz
Coachz: Modify Battery LED behavior
Modify Battery LED behavior based on spec BRANCH=master BUG=b:173095514 TEST=make BOARD=coachz -j flash ec and check Battery LED behavior Signed-off-by: gaochao <gaochao@huaqin.corp-partner.google.com> Change-Id: Iaf149bc37d65048ce68c96ed6758e018c0bb16c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2534439 Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'board/coachz')
-rw-r--r--board/coachz/led.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/board/coachz/led.c b/board/coachz/led.c
index 8575d8cdaf..9dd8729a04 100644
--- a/board/coachz/led.c
+++ b/board/coachz/led.c
@@ -16,8 +16,11 @@
#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)
- color = LED_AMBER;
- else
+ 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 if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
- /* Discharging in S5: off */
- color = LED_OFF;
- } else if (chipset_in_state(CHIPSET_STATE_ON)) {
- /* Discharging in S0: Blue on */
- color = LED_BLUE;
+ }
+ } 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 {
+ /* G3 or S5 or S0: off */
+ color = LED_OFF;
+ }
}
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 */
- color = LED_BLUE;
+ /* 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) {