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.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
#include <MeshCore.h>
|
|
#include <helpers/NRF52Board.h>
|
|
#include <helpers/ui/LEDManager.h>
|
|
|
|
class MeshtinyBoard : public NRF52BoardDCDC {
|
|
protected:
|
|
uint8_t btn_prev_state;
|
|
|
|
public:
|
|
MeshtinyBoard() : NRF52Board("Meshtiny OTA") {}
|
|
void begin();
|
|
|
|
void onBeforeTransmit() override {
|
|
if (ledManager) ledManager->onBeforeTransmit();
|
|
}
|
|
void onAfterTransmit() override {
|
|
if (ledManager) ledManager->onAfterTransmit();
|
|
}
|
|
|
|
uint16_t getBattMilliVolts() override {
|
|
int adcvalue = 0;
|
|
analogReadResolution(12);
|
|
analogReference(AR_INTERNAL_3_0);
|
|
delay(10);
|
|
adcvalue = analogRead(PIN_VBAT_READ);
|
|
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
|
|
}
|
|
|
|
const char *getManufacturerName() const override { return "Meshtiny"; }
|
|
|
|
void reboot() override { NVIC_SystemReset(); }
|
|
|
|
void powerOff() override {
|
|
|
|
#ifdef PIN_USER_BTN
|
|
while (digitalRead(PIN_USER_BTN) == LOW) {
|
|
delay(10);
|
|
}
|
|
#endif
|
|
|
|
#ifdef PIN_3V3_EN
|
|
pinMode(PIN_3V3_EN, OUTPUT);
|
|
digitalWrite(PIN_3V3_EN, LOW);
|
|
#endif
|
|
|
|
if (ledManager) ledManager->powerOff();
|
|
|
|
#ifdef PIN_USER_BTN
|
|
nrf_gpio_cfg_sense_input(g_ADigitalPinMap[PIN_USER_BTN], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
|
#endif
|
|
|
|
sd_power_system_off();
|
|
}
|
|
|
|
};
|