summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2021-12-30 12:17:30 +0800
committerCommit Bot <commit-bot@chromium.org>2022-01-11 03:59:29 +0000
commita79c1cfef825f1f8ef119235da18c59d143b2648 (patch)
tree7724bf0bb2eecb971b86db971b3b488872542bab
parentbecd6b08ed7a096bbd732760bdce7936542b1a14 (diff)
downloadchrome-ec-a79c1cfef825f1f8ef119235da18c59d143b2648.tar.gz
anahera: Update charging LEDs behavior
This patch updates the LEDs behavior. Change as below: 1. battery error: Original - Blinking white quickly. (0.5 sec ON, 0.5 sec OFF) New - Blinking amber quickly. (0.5 sec ON, 0.5 sec OFF) 2. battery low: Original - Blinking white slowly on right side led. (1 sec ON, 1 sec OFF) New - Blinking amber slowly on both side leds. (1 sec ON, 1 sec OFF) BUG=b:208912133 BRANCH=none TEST=Verify LEDs worked indeed. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I71fff3dd757de59b3edc76ae121fe897d782c25b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3361071 Reviewed-by: Boris Mittelberg <bmbm@google.com> Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r--board/anahera/led.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/board/anahera/led.c b/board/anahera/led.c
index 64c9ff7ba9..b74d018b01 100644
--- a/board/anahera/led.c
+++ b/board/anahera/led.c
@@ -23,6 +23,8 @@
#define POWER_LED_ON 0
#define POWER_LED_OFF 1
+#define BATT_LOW_BCT 10
+
#define LED_TICK_INTERVAL_MS (500 * MSEC)
#define LED_CYCLE_TIME_MS (2000 * MSEC)
#define LED_TICKS_PER_CYCLE (LED_CYCLE_TIME_MS / LED_TICK_INTERVAL_MS)
@@ -168,21 +170,38 @@ static void led_set_battery(void)
set_active_port_color(LED_AMBER);
break;
case PWR_STATE_DISCHARGE:
+ /*
+ * Blinking amber LEDs slowly if battery is lower 10
+ * percentage.
+ */
if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
- if (charge_get_percent() < 10)
+ if (charge_get_percent() < BATT_LOW_BCT)
led_set_color_battery(RIGHT_PORT,
(battery_ticks % LED_TICKS_PER_CYCLE
- < LED_ON_TICKS) ? LED_WHITE : LED_OFF);
+ < LED_ON_TICKS) ? LED_AMBER : LED_OFF);
else
led_set_color_battery(RIGHT_PORT, LED_OFF);
}
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))
- led_set_color_battery(LEFT_PORT, LED_OFF);
+ if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
+ if (charge_get_percent() < BATT_LOW_BCT)
+ led_set_color_battery(LEFT_PORT,
+ (battery_ticks % LED_TICKS_PER_CYCLE
+ < LED_ON_TICKS) ? LED_AMBER : LED_OFF);
+ else
+ led_set_color_battery(LEFT_PORT, LED_OFF);
+ }
break;
case PWR_STATE_ERROR:
- set_active_port_color((battery_ticks & 0x1) ?
- LED_WHITE : LED_OFF);
+ if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
+ led_set_color_battery(RIGHT_PORT, (battery_ticks & 0x1)
+ ? LED_AMBER : LED_OFF);
+ }
+
+ if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
+ led_set_color_battery(LEFT_PORT, (battery_ticks & 0x1)
+ ? LED_AMBER : LED_OFF);
+ }
break;
case PWR_STATE_CHARGE_NEAR_FULL:
set_active_port_color(LED_WHITE);