Merge pull request #1524 from recrof/thinknode-m3-m6-fixes

Elecrow ThinkNode M3, M6 build errors fix after NRF52Board base class migration
This commit is contained in:
fdlamotte 2026-01-29 11:07:32 -04:00 committed by GitHub
commit acca73f57e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 101 additions and 86 deletions

View file

@ -0,0 +1,28 @@
#include <Arduino.h>
#include "ThinkNodeM3Board.h"
#include <Wire.h>
#include <bluefruit.h>
void ThinkNodeM3Board::begin() {
NRF52Board::begin();
btn_prev_state = HIGH;
Wire.begin();
delay(10); // give sx1262 some time to power up
}
uint16_t ThinkNodeM3Board::getBattMilliVolts() {
int adcvalue = 0;
analogReference(AR_INTERNAL_2_4);
analogReadResolution(ADC_RESOLUTION);
delay(10);
// ADC range is 0..2400mV and resolution is 12-bit (0..4095)
adcvalue = analogRead(PIN_VBAT_READ);
// Convert the raw value to compensated mv, taking the resistor-
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * ADC_FACTOR);
}

View file

@ -0,0 +1,54 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
class ThinkNodeM3Board : public NRF52BoardDCDC {
protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
uint8_t btn_prev_state;
public:
ThinkNodeM3Board() : NRF52Board("THINKNODE_M3_OTA") {}
void begin();
uint16_t getBattMilliVolts() override;
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
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 M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override {
// turn off all leds, sd_power_system_off will not do this for us
#ifdef P_LORA_TX_LED
digitalWrite(P_LORA_TX_LED, LOW);
#endif
// power off board
sd_power_system_off();
}
};

View file

@ -1,14 +0,0 @@
#include <Arduino.h>
#include "ThinknodeM3Board.h"
#include <Wire.h>
#include <bluefruit.h>
void ThinknodeM3Board::begin() {
Nrf52BoardDCDC::begin();
btn_prev_state = HIGH;
Wire.begin();
delay(10); // give sx1262 some time to power up
}

View file

@ -1,58 +0,0 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
#include <helpers/NRF52Board.h>
#define ADC_FACTOR ((1000.0*ADC_MULTIPLIER*AREF_VOLTAGE)/ADC_MAX)
class ThinknodeM3Board : public Nrf52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
void begin();
uint16_t getBattMilliVolts() override {
int adcvalue = 0;
analogReference(AR_INTERNAL_2_4);
analogReadResolution(ADC_RESOLUTION);
delay(10);
// ADC range is 0..2400mV and resolution is 12-bit (0..4095)
adcvalue = analogRead(PIN_VBAT_READ);
// Convert the raw value to compensated mv, taking the resistor-
// divider into account (providing the actual LIPO voltage)
return (uint16_t)((float)adcvalue * ADC_FACTOR);
}
#if defined(P_LORA_TX_LED)
#if !defined(P_LORA_TX_LED_ON)
#define P_LORA_TX_LED_ON HIGH
#endif
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, P_LORA_TX_LED_ON); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, !P_LORA_TX_LED_ON); // turn TX LED off
}
#endif
const char* getManufacturerName() const override {
return "Elecrow ThinkNode M3";
}
int buttonStateChanged() {
#ifdef BUTTON_PIN
uint8_t v = digitalRead(BUTTON_PIN);
if (v != btn_prev_state) {
btn_prev_state = v;
return (v == LOW) ? 1 : -1;
}
#endif
return 0;
}
void powerOff() override { sd_power_system_off(); }
};

View file

@ -2,7 +2,7 @@
#include "target.h" #include "target.h"
#include <helpers/sensors/MicroNMEALocationProvider.h> #include <helpers/sensors/MicroNMEALocationProvider.h>
ThinknodeM3Board board; ThinkNodeM3Board board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);

View file

@ -3,7 +3,7 @@
#define RADIOLIB_STATIC_ONLY 1 #define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h> #include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h> #include <helpers/radiolib/RadioLibWrappers.h>
#include "ThinknodeM3Board.h" #include "ThinkNodeM3Board.h"
#include <helpers/radiolib/CustomLR1110Wrapper.h> #include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/ArduinoHelpers.h> #include <helpers/ArduinoHelpers.h>
#include <helpers/sensors/EnvironmentSensorManager.h> #include <helpers/sensors/EnvironmentSensorManager.h>
@ -17,7 +17,7 @@
extern NullDisplayDriver display; extern NullDisplayDriver display;
#endif #endif
extern ThinknodeM3Board board; extern ThinkNodeM3Board board;
extern WRAPPER_CLASS radio_driver; extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock; extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors; extern EnvironmentSensorManager sensors;

View file

@ -12,9 +12,14 @@
#define PIN_VBAT_READ BATTERY_PIN #define PIN_VBAT_READ BATTERY_PIN
#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
class ThinkNodeM6Board : public Nrf52BoardOTA { class ThinkNodeM6Board : public NRF52BoardDCDC {
protected:
#if NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public: public:
ThinkNodeM6Board() : NRF52BoardOTA("THINKNODE_M1_OTA") {} ThinkNodeM6Board() : NRF52Board("THINKNODE_M6_OTA") {}
void begin(); void begin();
uint16_t getBattMilliVolts() override; uint16_t getBattMilliVolts() override;
@ -25,10 +30,10 @@ public:
void onAfterTransmit() override { void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
} }
#endif #endif
const char* getManufacturerName() const override { const char* getManufacturerName() const override {
return "Elecrow ThinkNode-M6"; return "Elecrow ThinkNode M6";
} }
void powerOff() override { void powerOff() override {