From 5512185cfea022bc5f1c3ded0c2d9f69c9af21e0 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 8 May 2026 16:03:39 -0500 Subject: [PATCH] Make heartbeat LED play nice with other LEDs (#10423) --- src/modules/StatusLEDModule.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/modules/StatusLEDModule.cpp b/src/modules/StatusLEDModule.cpp index 3ed0585af..4ea34fb52 100644 --- a/src/modules/StatusLEDModule.cpp +++ b/src/modules/StatusLEDModule.cpp @@ -95,20 +95,9 @@ int32_t StatusLEDModule::runOnce() } } } - - if (power_state != charging && power_state != charged && !doing_fast_blink) { - if (CHARGE_LED_state == LED_STATE_ON) { - CHARGE_LED_state = LED_STATE_OFF; - my_interval = 999; - } else { - CHARGE_LED_state = LED_STATE_ON; - my_interval = 1; - } - } - // If we want a LED to be dedicated to the simple hearbeat, we can use that instead of the charge LED #if defined(LED_HEARTBEAT) - if (!config.device.led_heartbeat_disabled) { + if (power_state != charging && power_state != charged && !doing_fast_blink && !config.device.led_heartbeat_disabled) { if (HEARTBEAT_LED_state == LED_STATE_ON) { HEARTBEAT_LED_state = LED_STATE_OFF; my_interval = 999; @@ -117,6 +106,19 @@ int32_t StatusLEDModule::runOnce() my_interval = 1; } digitalWrite(LED_HEARTBEAT, HEARTBEAT_LED_state); + } else { + HEARTBEAT_LED_state = LED_STATE_OFF; + digitalWrite(LED_HEARTBEAT, HEARTBEAT_LED_state); + } +#else + if (power_state != charging && power_state != charged && !doing_fast_blink && !config.device.led_heartbeat_disabled) { + if (CHARGE_LED_state == LED_STATE_ON) { + CHARGE_LED_state = LED_STATE_OFF; + my_interval = 999; + } else { + CHARGE_LED_state = LED_STATE_ON; + my_interval = 1; + } } #endif if (!config.bluetooth.enabled || PAIRING_LED_starttime + 30 * 1000 < millis() || doing_fast_blink) {