From 0f854862e795bc14ff67f33d94350e8a6190005a Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 7 May 2026 13:17:29 -0500 Subject: [PATCH] Give ThinkNode-m4 a heartbeat (#10408) --- src/modules/StatusLEDModule.cpp | 13 +++++++++++++ src/modules/StatusLEDModule.h | 3 +++ variants/nrf52840/ELECROW-ThinkNode-M4/variant.cpp | 3 +++ variants/nrf52840/ELECROW-ThinkNode-M4/variant.h | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modules/StatusLEDModule.cpp b/src/modules/StatusLEDModule.cpp index f828f4a16..3ed0585af 100644 --- a/src/modules/StatusLEDModule.cpp +++ b/src/modules/StatusLEDModule.cpp @@ -106,6 +106,19 @@ int32_t StatusLEDModule::runOnce() } } +// 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 (HEARTBEAT_LED_state == LED_STATE_ON) { + HEARTBEAT_LED_state = LED_STATE_OFF; + my_interval = 999; + } else { + HEARTBEAT_LED_state = LED_STATE_ON; + my_interval = 1; + } + digitalWrite(LED_HEARTBEAT, HEARTBEAT_LED_state); + } +#endif if (!config.bluetooth.enabled || PAIRING_LED_starttime + 30 * 1000 < millis() || doing_fast_blink) { PAIRING_LED_state = LED_STATE_OFF; } else if (ble_state == unpaired) { diff --git a/src/modules/StatusLEDModule.h b/src/modules/StatusLEDModule.h index 972e26737..f66a536f6 100644 --- a/src/modules/StatusLEDModule.h +++ b/src/modules/StatusLEDModule.h @@ -43,6 +43,9 @@ class StatusLEDModule : private concurrency::OSThread private: bool CHARGE_LED_state = LED_STATE_OFF; bool PAIRING_LED_state = LED_STATE_OFF; +#if defined(LED_HEARTBEAT) + bool HEARTBEAT_LED_state = LED_STATE_OFF; +#endif uint32_t PAIRING_LED_starttime = 0; uint32_t lastUserbuttonTime = 0; diff --git a/variants/nrf52840/ELECROW-ThinkNode-M4/variant.cpp b/variants/nrf52840/ELECROW-ThinkNode-M4/variant.cpp index 999f326db..da257a39b 100644 --- a/variants/nrf52840/ELECROW-ThinkNode-M4/variant.cpp +++ b/variants/nrf52840/ELECROW-ThinkNode-M4/variant.cpp @@ -35,6 +35,9 @@ void initVariant() pinMode(LED_PAIRING, OUTPUT); ledOff(LED_PAIRING); + pinMode(LED_HEARTBEAT, OUTPUT); + ledOff(LED_HEARTBEAT); + pinMode(Battery_LED_1, OUTPUT); ledOff(Battery_LED_1); pinMode(Battery_LED_2, OUTPUT); diff --git a/variants/nrf52840/ELECROW-ThinkNode-M4/variant.h b/variants/nrf52840/ELECROW-ThinkNode-M4/variant.h index 2cfe948e3..560af284b 100644 --- a/variants/nrf52840/ELECROW-ThinkNode-M4/variant.h +++ b/variants/nrf52840/ELECROW-ThinkNode-M4/variant.h @@ -41,7 +41,8 @@ extern "C" { // LEDs #define LED_BLUE -1 -#define LED_NOTIFICATION (32 + 9) +// #define LED_NOTIFICATION (32 + 9) +#define LED_HEARTBEAT (32 + 9) #define LED_PAIRING (13) #define Battery_LED_1 (15)