diff options
Diffstat (limited to 'board/bugzzy/led.c')
-rw-r--r-- | board/bugzzy/led.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/board/bugzzy/led.c b/board/bugzzy/led.c index d04026e0f0..17da244534 100644 --- a/board/bugzzy/led.c +++ b/board/bugzzy/led.c @@ -53,12 +53,23 @@ const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); __override void led_set_color_power(enum ec_led_colors color) { + static enum ec_led_colors prev_color = EC_LED_COLOR_COUNT; + /* Don't set led if led_auto_control is disabled. */ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED) || !led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) { return; } + /* + * Sometimes system wakes and sleeps automatically. + * Add LED debounce time to prevent blinking led by this. + */ + if (prev_color != color) { + prev_color = color; + return; + } + if (color == EC_LED_COLOR_BLUE) { gpio_set_level(GPIO_BAT_LED_RED_L, LED_OFF_LVL); @@ -72,6 +83,8 @@ __override void led_set_color_power(enum ec_led_colors color) __override void led_set_color_battery(enum ec_led_colors color) { + static enum ec_led_colors prev_color = EC_LED_COLOR_COUNT; + /* Don't set led if led_auto_control is disabled. */ if (!led_auto_control_is_enabled(EC_LED_ID_POWER_LED) || !led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) { @@ -79,6 +92,14 @@ __override void led_set_color_battery(enum ec_led_colors color) } /* + * Sometimes system wakes and sleeps automatically. + * Add LED debounce time to prevent blinking led by this. + */ + if (prev_color != color) { + prev_color = color; + return; + } + /* * Battery leds must be turn off when blue led is on * because bugzzy has 3-in-1 led. */ |