initial support for elecrow thinknode m7

This commit is contained in:
liamcottle
2026-06-25 16:03:27 +12:00
parent c2cfba4af3
commit b975180fc8
9 changed files with 357 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-D BOARD_HAS_PSRAM",
"-D ARDUINO_USB_CDC_ON_BOOT=0",
"-D ARDUINO_USB_MODE=0",
"-D ARDUINO_RUNNING_CORE=1",
"-D ARDUINO_EVENT_RUNNING_CORE=0"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"psram_type": "qio_opi",
"hwids": [["0x303A", "0x1001"]],
"mcu": "esp32s3",
"variant": "ELECROW-ThinkNode-M7"
},
"connectivity": ["wifi", "bluetooth", "lora"],
"debug": {
"default_tool": "esp-builtin",
"onboard_tools": ["esp-builtin"],
"openocd_target": "esp32s3.cfg"
},
"frameworks": ["arduino", "espidf"],
"name": "ELECROW ThinkNode M7",
"upload": {
"flash_size": "8MB",
"maximum_ram_size": 524288,
"maximum_size": 8388608,
"use_1200bps_touch": true,
"wait_for_upload_port": true,
"require_upload_port": true,
"speed": 921600
},
"url": "https://www.elecrow.com",
"vendor": "ELECROW"
}
@@ -0,0 +1,17 @@
#include "ThinkNodeM7Board.h"
void ThinkNodeM7Board::begin() {
ESP32Board::begin();
}
void ThinkNodeM7Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
esp_deep_sleep_start();
}
void ThinkNodeM7Board::powerOff() {
enterDeepSleep(0);
}
const char* ThinkNodeM7Board::getManufacturerName() const {
return "Elecrow ThinkNode M7";
}
+23
View File
@@ -0,0 +1,23 @@
#pragma once
#include <Arduino.h>
#include <helpers/RefCountedDigitalPin.h>
#include <helpers/ESP32Board.h>
#include "variant.h"
#include "NullDisplayDriver.h"
#include "MomentaryButton.h"
class ThinkNodeM7Board : public ESP32Board {
public:
void begin();
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
void powerOff() override;
const char* getManufacturerName() const override;
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW);
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH);
}
};
+19
View File
@@ -0,0 +1,19 @@
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
// The default Wire will be mapped to PMU and RTC
static const uint8_t SDA = 17;
static const uint8_t SCL = 18;
// Default SPI is the LR1110 radio bus
static const uint8_t SS = 12;
static const uint8_t MOSI = 10;
static const uint8_t MISO = 9;
static const uint8_t SCK = 11;
#endif /* Pins_Arduino_h */
+134
View File
@@ -0,0 +1,134 @@
[ThinkNode_M7]
extends = esp32_base
board = thinknode_m7
build_flags = ${esp32_base.build_flags}
-I src/helpers/esp32
-I variants/thinknode_m7
-I src/helpers/sensors
-I src/helpers/ui
-D THINKNODE_M7
-D PIN_USER_BTN_ANA=4
-D PIN_STATUS_LED=3 ; green
-D LED_STATE_ON=LOW
-D RADIO_CLASS=CustomLR1110
-D WRAPPER_CLASS=CustomLR1110Wrapper
-D USE_LR1110
-D LORA_TX_POWER=22
-D RF_SWITCH_TABLE
-D RX_BOOSTED_GAIN=true
-D P_LORA_BUSY=13
-D P_LORA_SCLK=11
-D P_LORA_NSS=12
-D P_LORA_DIO_1=38
-D P_LORA_MISO=9
-D P_LORA_MOSI=10
-D P_LORA_RESET=39
-D P_LORA_TX_LED=46 ; blue
-D LR11X0_DIO_AS_RF_SWITCH=true
-D LR11X0_DIO3_TCXO_VOLTAGE=1.8
build_src_filter = ${esp32_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../variants/thinknode_m7>
lib_deps = ${esp32_base.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
[env:ThinkNode_M7_repeater]
extends = ThinkNode_M7
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<../examples/simple_repeater/*.cpp>
build_flags =
${ThinkNode_M7.build_flags}
-D ADVERT_NAME='"ThinkNode M7 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=8
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps =
${ThinkNode_M7.lib_deps}
${esp32_ota.lib_deps}
[env:ThinkNode_M7_room_server]
extends = ThinkNode_M7
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<../examples/simple_room_server>
build_flags =
${ThinkNode_M7.build_flags}
-D ADVERT_NAME='"ThinkNode M7 Room Server"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D ROOM_PASSWORD='"hello"'
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
lib_deps =
${ThinkNode_M7.lib_deps}
${esp32_ota.lib_deps}
[env:ThinkNode_M7_companion_radio_ble]
extends = ThinkNode_M7
build_flags =
${ThinkNode_M7.build_flags}
-I examples/companion_radio/ui-orig
-D DISPLAY_CLASS=NullDisplayDriver
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D BLE_PIN_CODE=123456
-D OFFLINE_QUEUE_SIZE=256
; -D BLE_DEBUG_LOGGING=1
; -D MESH_PACKET_LOGGING=1
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps =
${ThinkNode_M7.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:ThinkNode_M7_companion_radio_usb]
extends = ThinkNode_M7
build_flags =
${ThinkNode_M7.build_flags}
-I examples/companion_radio/ui-orig
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps =
${ThinkNode_M7.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:ThinkNode_M7_companion_radio_wifi]
extends = ThinkNode_M7
build_flags =
${ThinkNode_M7.build_flags}
-I examples/companion_radio/ui-orig
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D DISPLAY_CLASS=NullDisplayDriver
-D WIFI_DEBUG_LOGGING=1
-D WIFI_SSID='"myssid"'
-D WIFI_PWD='"mypwd"'
-D OFFLINE_QUEUE_SIZE=256
-D MESH_PACKET_LOGGING=1
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-orig/*.cpp>
lib_deps =
${ThinkNode_M7.lib_deps}
densaugeo/base64 @ ~1.4.0
[env:ThinkNode_M7_kiss_modem]
extends = ThinkNode_M7
build_src_filter = ${ThinkNode_M7.build_src_filter}
+<../examples/kiss_modem/>
+84
View File
@@ -0,0 +1,84 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/sensors/MicroNMEALocationProvider.h>
ThinkNodeM7Board board;
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
WRAPPER_CLASS radio_driver(radio, board);
ESP32RTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
#endif
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
#endif
#ifdef RF_SWITCH_TABLE
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
RADIOLIB_LR11X0_DIO5,
RADIOLIB_LR11X0_DIO6,
RADIOLIB_NC,
RADIOLIB_NC,
RADIOLIB_NC
};
static const Module::RfSwitchMode_t rfswitch_table[] = {
// mode DIO5 DIO6
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}},
{LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}},
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
END_OF_MODE_TABLE,
};
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
rtc_clock.begin(Wire);
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI, P_LORA_NSS);
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(2);
radio.explicitHeader();
#ifdef RF_SWITCH_TABLE
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
#endif
#ifdef RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
#endif
return true; // success
}
mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#define RADIOLIB_STATIC_ONLY 1
#include <RadioLib.h>
#include <helpers/radiolib/RadioLibWrappers.h>
#include <ThinkNodeM7Board.h>
#include <helpers/radiolib/CustomLR1110Wrapper.h>
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#ifdef DISPLAY_CLASS
#include "NullDisplayDriver.h"
#endif
extern ThinkNodeM7Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern NullDisplayDriver display;
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+8
View File
@@ -0,0 +1,8 @@
#include "variant.h"
#include "Arduino.h"
void initVariant()
{
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, HIGH);
}
+1
View File
@@ -0,0 +1 @@