Files
MeshCore/src/helpers/LedPolicy.cpp
T
9d52b1fd68 Add saved LED controls across supported boards
Add get leds and set leds on|off for Companion, repeater, room server and
sensor builds. Preserve the setting across reboots and cover GPIO, RGB,
Bluetooth, notification and expander indicators without changing radio
amplifier controls or screen backlights.

RAK Companions blink while advertising and keep the Bluetooth LED off once
connected, including late timer callbacks.

Adapted from meshcore-dev/MeshCore#3605 and #2694.
Validated with host regressions and firmware builds for SenseCAP Solar,
RAK4631, T096, Heltec V4, T-Beam, Xiao S3, Pico W and Wio E5 Mini.

Co-authored-by: R0ck <develop@hectospark.co.uk>
Co-authored-by: Nick Dunklee <nick@dunklee.org>
2026-10-20 08:59:39 -07:00

25 lines
601 B
C++

#include "LedPolicy.h"
#include <Arduino.h>
#include <target.h>
namespace mesh { namespace leds {
void applyStatusPolicy() {
if (enabled()) return;
#if defined(PIN_STATUS_LED_R) && defined(PIN_STATUS_LED_G) && defined(PIN_STATUS_LED_B)
analogWrite(PIN_STATUS_LED_R, 0);
analogWrite(PIN_STATUS_LED_G, 0);
analogWrite(PIN_STATUS_LED_B, 0);
#elif defined(PIN_STATUS_LED)
if (PIN_STATUS_LED < 0) return;
#ifdef LED_STATE_ON
digitalWrite(PIN_STATUS_LED, !LED_STATE_ON);
#else
digitalWrite(PIN_STATUS_LED, LOW);
#endif
pinMode(PIN_STATUS_LED, OUTPUT);
#endif
}
}} // namespace mesh::leds