mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
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:
commit
acca73f57e
7 changed files with 101 additions and 86 deletions
28
variants/thinknode_m3/ThinkNodeM3Board.cpp
Normal file
28
variants/thinknode_m3/ThinkNodeM3Board.cpp
Normal 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);
|
||||||
|
}
|
||||||
54
variants/thinknode_m3/ThinkNodeM3Board.h
Normal file
54
variants/thinknode_m3/ThinkNodeM3Board.h
Normal 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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
@ -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(); }
|
|
||||||
};
|
|
||||||
|
|
@ -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);
|
||||||
|
|
||||||
|
|
@ -30,26 +30,26 @@ static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
|
||||||
RADIOLIB_LR11X0_DIO5,
|
RADIOLIB_LR11X0_DIO5,
|
||||||
RADIOLIB_LR11X0_DIO6,
|
RADIOLIB_LR11X0_DIO6,
|
||||||
RADIOLIB_NC,
|
RADIOLIB_NC,
|
||||||
RADIOLIB_NC,
|
RADIOLIB_NC,
|
||||||
RADIOLIB_NC
|
RADIOLIB_NC
|
||||||
};
|
};
|
||||||
|
|
||||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||||
// mode DIO5 DIO6
|
// mode DIO5 DIO6
|
||||||
{ LR11x0::MODE_STBY, {LOW , LOW }},
|
{ LR11x0::MODE_STBY, {LOW , LOW }},
|
||||||
{ LR11x0::MODE_RX, {HIGH, LOW }},
|
{ LR11x0::MODE_RX, {HIGH, LOW }},
|
||||||
{ LR11x0::MODE_TX, {HIGH, HIGH }},
|
{ LR11x0::MODE_TX, {HIGH, HIGH }},
|
||||||
{ LR11x0::MODE_TX_HP, {LOW , HIGH }},
|
{ LR11x0::MODE_TX_HP, {LOW , HIGH }},
|
||||||
{ LR11x0::MODE_TX_HF, {LOW , LOW }},
|
{ LR11x0::MODE_TX_HF, {LOW , LOW }},
|
||||||
{ LR11x0::MODE_GNSS, {LOW , LOW }},
|
{ LR11x0::MODE_GNSS, {LOW , LOW }},
|
||||||
{ LR11x0::MODE_WIFI, {LOW , LOW }},
|
{ LR11x0::MODE_WIFI, {LOW , LOW }},
|
||||||
END_OF_MODE_TABLE,
|
END_OF_MODE_TABLE,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool radio_init() {
|
bool radio_init() {
|
||||||
rtc_clock.begin(Wire);
|
rtc_clock.begin(Wire);
|
||||||
|
|
||||||
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
|
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
|
||||||
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
|
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
|
||||||
#else
|
#else
|
||||||
|
|
@ -64,7 +64,7 @@ bool radio_init() {
|
||||||
Serial.println(status);
|
Serial.println(status);
|
||||||
return false; // fail
|
return false; // fail
|
||||||
}
|
}
|
||||||
|
|
||||||
radio.setCRC(2);
|
radio.setCRC(2);
|
||||||
radio.explicitHeader();
|
radio.explicitHeader();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue