mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Adds a LEDManager class (src/helpers/ui/LEDManager.h) that centralizes all LED control into one component with begin()/loop() lifecycle and per-pin active-HIGH/LOW polarity support. LED settings are exposed as custom vars (led.status, led.activity) accessible via companion radio binary protocol, CLI set/get commands, and the SensorManager settings interface. Status LED modes: off, boot-30s, slow blink (200ms/4s), always on. Activity LED modes: off, BLE only, LoRa TX only, BLE + LoRa TX. Integrated into 23 board variants, replacing scattered hardcoded digitalWrite calls in onBeforeTransmit/onAfterTransmit/powerOff.
48 lines
1 KiB
C++
48 lines
1 KiB
C++
#pragma once
|
|
|
|
#include <MeshCore.h>
|
|
#include <Arduino.h>
|
|
#include <helpers/NRF52Board.h>
|
|
#include <helpers/ui/LEDManager.h>
|
|
|
|
// built-ins
|
|
#define PIN_VBAT_READ 5
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
|
|
|
#define PIN_3V3_EN (34)
|
|
#define WB_IO2 PIN_3V3_EN
|
|
|
|
class RAK3401Board : public NRF52BoardDCDC {
|
|
protected:
|
|
#ifdef NRF52_POWER_MANAGEMENT
|
|
void initiateShutdown(uint8_t reason) override;
|
|
#endif
|
|
public:
|
|
RAK3401Board() : NRF52Board("RAK3401_OTA") {}
|
|
void begin();
|
|
|
|
#define BATTERY_SAMPLES 8
|
|
|
|
uint16_t getBattMilliVolts() override {
|
|
analogReadResolution(12);
|
|
|
|
uint32_t raw = 0;
|
|
for (int i = 0; i < BATTERY_SAMPLES; i++) {
|
|
raw += analogRead(PIN_VBAT_READ);
|
|
}
|
|
raw = raw / BATTERY_SAMPLES;
|
|
|
|
return (ADC_MULTIPLIER * raw) / 4096;
|
|
}
|
|
|
|
const char* getManufacturerName() const override {
|
|
return "RAK 3401";
|
|
}
|
|
|
|
void onBeforeTransmit() override {
|
|
if (ledManager) ledManager->onBeforeTransmit();
|
|
}
|
|
void onAfterTransmit() override {
|
|
if (ledManager) ledManager->onAfterTransmit();
|
|
}
|
|
};
|