Files
MeshCore/variants/thinknode_m8/ThinkNodeM8Board.h
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

56 lines
1.6 KiB
C++

#pragma once
#include <MeshCore.h>
#include <Arduino.h>
#include <helpers/NRF52Board.h>
// built-ins
#define VBAT_MV_PER_LSB (0.5859375F) // 2.4V ADC range and 12-bit ADC resolution = 2400mV/4096
#define VBAT_DIVIDER (0.57F) // 150K + 150K voltage divider on VBAT
#define VBAT_DIVIDER_COMP (1.75F) // Compensation factor for the VBAT divider
#define PIN_VBAT_READ (4)
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class ThinkNodeM8Board : public NRF52Board {
public:
ThinkNodeM8Board() : NRF52Board("THINKNODE_M8_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;
#if defined(P_LORA_TX_LED)
void applyLedPolicy() override {
NRF52Board::applyLedPolicy();
if (!mesh::leds::enabled()) digitalWrite(P_LORA_TX_LED, LOW);
}
void onBeforeTransmit() override {
if (mesh::leds::enabled()) digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
const char* getManufacturerName() const override {
return "Elecrow ThinkNode-M8";
}
void shutdownPeripherals() override {
// power off board
NRF52Board::shutdownPeripherals();
// make sure every gate is closed
digitalWrite(DISP_EN, LOW);
digitalWrite(PIN_PWR_EN, LOW);
digitalWrite(PIN_GPS_EN, LOW);
digitalWrite(SX126X_ANT_SW, LOW);
digitalWrite(ADC_EN, LOW);
#ifdef PIN_BUTTON1 // Use BTN to go out of sleep
nrf_gpio_cfg_sense_input(PIN_BUTTON1, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
#endif
}
};