2025-10-19 20:44:27 +02:00
|
|
|
#include "ThinknodeM2Board.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ThinknodeM2Board::begin() {
|
2025-11-07 09:50:21 +01:00
|
|
|
pinMode(PIN_VEXT_EN, OUTPUT);
|
|
|
|
|
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
|
|
|
|
delay(20); // allow power rail to discharge
|
|
|
|
|
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
|
|
|
|
delay(120); // give display time to bias on cold boot
|
2025-10-19 20:44:27 +02:00
|
|
|
ESP32Board::begin();
|
Add centralized LEDManager for configurable LED behavior
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.
2026-03-20 18:19:44 -07:00
|
|
|
|
|
|
|
|
// Start LEDs with defaults; prefs are applied after loadPrefs()
|
|
|
|
|
static LEDManager _ledManager(PIN_STATUS_LED, -1);
|
|
|
|
|
ledManager = &_ledManager;
|
|
|
|
|
ledManager->begin(LED_STATUS_BOOT_30S, LED_ACTIVITY_BOTH);
|
2025-10-19 20:44:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThinknodeM2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
|
|
|
|
esp_deep_sleep_start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ThinknodeM2Board::powerOff() {
|
|
|
|
|
enterDeepSleep(0);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-07 09:48:57 +01:00
|
|
|
uint16_t ThinknodeM2Board::getBattMilliVolts() {
|
2025-10-19 20:44:27 +02:00
|
|
|
analogReadResolution(12);
|
2025-11-07 09:48:57 +01:00
|
|
|
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
|
|
|
|
|
|
|
|
|
uint32_t mv = 0;
|
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
|
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
|
|
|
|
delayMicroseconds(200);
|
|
|
|
|
}
|
|
|
|
|
mv /= 8;
|
|
|
|
|
|
|
|
|
|
analogReadResolution(10);
|
|
|
|
|
return static_cast<uint16_t>(mv * ADC_MULTIPLIER );
|
|
|
|
|
}
|
2025-10-19 20:44:27 +02:00
|
|
|
|
|
|
|
|
const char* ThinknodeM2Board::getManufacturerName() const {
|
|
|
|
|
return "Elecrow ThinkNode M2";
|
2025-11-07 09:48:57 +01:00
|
|
|
}
|