Merge pull request #17 from meshcore-dev/dev

merge Dev
This commit is contained in:
Quency-D
2026-07-15 14:49:40 +08:00
committed by GitHub
53 changed files with 1633 additions and 104 deletions
@@ -13,6 +13,11 @@ build_flags = ${nrf52_base.build_flags}
-D LORA_TX_POWER=22
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D HAS_EXTERNAL_WATCHDOG
-D EXTERNAL_WATCHDOG_DONE_PIN=9
-D EXTERNAL_WATCHDOG_WAKE_PIN=10
-D EXTERNAL_WATCHDOG_FEED_INTERVAL_MS=480000 ; 8 minute feed interval, safely inside the hardware watchdog timeout
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<../variants/heltec_mesh_solar>
+32
View File
@@ -13,6 +13,7 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
SolarSensorManager sensors = SolarSensorManager(nmea);
SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
@@ -106,3 +107,34 @@ bool SolarSensorManager::setSettingValue(const char* name, const char* value) {
}
return false; // not supported
}
bool SolarExternalWatchdog::begin() {
last_feed_watchdog = 0;
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
delay(1);
feed();
return true;
}
void SolarExternalWatchdog::loop() {
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
feed();
}
}
unsigned long SolarExternalWatchdog::getIntervalMs() const {
unsigned long elapsed_ms = millis() - last_feed_watchdog;
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
return 0;
}
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
}
void SolarExternalWatchdog::feed() {
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
last_feed_watchdog = millis();
}
+11
View File
@@ -8,6 +8,7 @@
#include <helpers/AutoDiscoverRTCClock.h>
#include <helpers/SensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#include <helpers/ExternalWatchdogManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/ST7789Display.h>
#endif
@@ -30,10 +31,20 @@ public:
bool setSettingValue(const char* name, const char* value) override;
};
class SolarExternalWatchdog : public ExternalWatchdogManager {
public:
SolarExternalWatchdog() {}
bool begin() override;
void loop() override;
unsigned long getIntervalMs() const override;
void feed() override;
};
extern MeshSolarBoard board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern SolarSensorManager sensors;
extern SolarExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
+2 -2
View File
@@ -34,8 +34,8 @@
#define PIN_SERIAL1_RX (37)
#define PIN_SERIAL1_TX (39)
#define PIN_SERIAL2_RX (9)
#define PIN_SERIAL2_TX (10)
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
////////////////////////////////////////////////////////////////////////////////
// I2C pin definition
+1 -1
View File
@@ -51,7 +51,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
lib_deps =
${nrf52_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
debug_tool = jlink
upload_protocol = nrfutil
+1 -1
View File
@@ -33,7 +33,7 @@ void T114Board::initiateShutdown(uint8_t reason) {
#endif // NRF52_POWER_MANAGEMENT
void T114Board::begin() {
NRF52Board::begin();
NRF52BoardDCDC::begin();
pinMode(PIN_VBAT_READ, INPUT);
+33
View File
@@ -14,6 +14,7 @@ VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
TowerV2ExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
DISPLAY_CLASS display;
@@ -29,3 +30,35 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng);
}
bool TowerV2ExternalWatchdog::begin() {
last_feed_watchdog = 0;
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
delay(1);
feed();
return true;
}
void TowerV2ExternalWatchdog::loop() {
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
feed();
}
}
unsigned long TowerV2ExternalWatchdog::getIntervalMs() const {
unsigned long elapsed_ms = millis() - last_feed_watchdog;
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
return 0;
}
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
}
void TowerV2ExternalWatchdog::feed() {
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
delay(1);
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
last_feed_watchdog = millis();
}
+11
View File
@@ -8,16 +8,27 @@
#include <helpers/radiolib/RadioLibWrappers.h>
#include <helpers/sensors/EnvironmentSensorManager.h>
#include <helpers/sensors/LocationProvider.h>
#include <helpers/ExternalWatchdogManager.h>
#ifdef DISPLAY_CLASS
#include <helpers/ui/MomentaryButton.h>
#include "helpers/ui/NullDisplayDriver.h"
#endif
class TowerV2ExternalWatchdog : public ExternalWatchdogManager {
public:
TowerV2ExternalWatchdog() {}
bool begin() override;
void loop() override;
unsigned long getIntervalMs() const override;
void feed() override;
};
extern HeltecTowerV2Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
extern TowerV2ExternalWatchdog external_watchdog;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
+4 -4
View File
@@ -82,10 +82,10 @@
#define PIN_SERIAL2_RX (-1)
#define PIN_SERIAL2_TX (-1)
#define HAS_HARDWARE_WATCHDOG
#define HARDWARE_WATCHDOG_DONE (0 + 9)
#define HARDWARE_WATCHDOG_WAKE (0 + 10)
#define HARDWARE_WATCHDOG_TIMEOUT_MS (8 * 60 * 1000)
#define HAS_EXTERNAL_WATCHDOG
#define EXTERNAL_WATCHDOG_DONE_PIN (0 + 9)
#define EXTERNAL_WATCHDOG_WAKE_PIN (0 + 10)
#define EXTERNAL_WATCHDOG_FEED_INTERVAL_MS (8 * 60 * 1000)
#define SERIAL_PRINT_PORT 0
+1 -1
View File
@@ -47,7 +47,7 @@ build_src_filter = ${esp32_base.build_src_filter}
lib_deps =
${esp32_base.lib_deps}
stevemarple/MicroNMEA @ ^2.0.6
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
[env:Heltec_Wireless_Tracker_companion_radio_usb]
extends = Heltec_tracker_base
+1 -1
View File
@@ -55,7 +55,7 @@ build_src_filter = ${esp32_base.build_src_filter}
lib_deps =
${esp32_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
bodmer/TFT_eSPI @ ^2.4.31
[env:heltec_tracker_v2_repeater]
extends = Heltec_tracker_v2
+2 -2
View File
@@ -21,8 +21,8 @@ build_flags =
-D RADIO_CLASS=CustomSX1276
-D WRAPPER_CLASS=CustomSX1276Wrapper
-D SX127X_CURRENT_LIMIT=120
-D SX176X_RXEN=21
-D SX176X_TXEN=10
-D SX127X_RXEN=21
-D SX127X_TXEN=10
-D LORA_TX_POWER=20
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/lilygo_t3s3_sx1276>
+1 -1
View File
@@ -6,7 +6,7 @@
#ifdef LILYGO_TECHO
void TechoBoard::begin() {
NRF52Board::begin();
NRF52BoardDCDC::begin();
// Configure battery measurement control BEFORE Wire.begin()
// to ensure P0.02 is not claimed by another peripheral
@@ -15,6 +15,7 @@ build_flags = ${nrf52_base.build_flags}
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D SX126X_USE_REGULATOR_LDO=1
-D P_LORA_TX_LED=LED_GREEN
-D DISABLE_DIAGNOSTIC_OUTPUT
-D ENV_INCLUDE_GPS=1
+1
View File
@@ -58,6 +58,7 @@ build_flags =
-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
build_src_filter = ${ThinkNode_M1.build_src_filter}
+3 -2
View File
@@ -48,8 +48,8 @@ build_flags =
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
; -D MESH_PACKET_LOGGING=1
-D MESH_DEBUG=1
-D GPS_NMEA_DEBUG=1
; -D MESH_DEBUG=1
; -D GPS_NMEA_DEBUG=1
build_src_filter = ${ThinkNode_M6.build_src_filter}
+<../examples/simple_repeater/*.cpp>
lib_deps =
@@ -63,6 +63,7 @@ build_flags =
-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
build_src_filter = ${ThinkNode_M6.build_src_filter}
@@ -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=50
; -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 @@
@@ -0,0 +1,23 @@
#include "ThinkNodeM9Board.h"
void ThinkNodeM9Board::begin() {
// power on screen
pinMode(VEXT_ENABLE, OUTPUT);
digitalWrite(VEXT_ENABLE, VEXT_ON_VALUE);
ESP32Board::begin();
}
void ThinkNodeM9Board::powerOff() {
enterDeepSleep(0);
}
uint32_t ThinkNodeM9Board::getIRQGpio() {
return LORA_DIO0;
}
const char* ThinkNodeM9Board::getManufacturerName() const {
return "Elecrow ThinkNode M9";
}
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include <Arduino.h>
#include <helpers/ESP32Board.h>
class ThinkNodeM9Board : public ESP32Board {
public:
void begin();
void powerOff() override;
const char* getManufacturerName() const override;
uint32_t getIRQGpio() override;
};
+64
View File
@@ -0,0 +1,64 @@
// Need this file for ESP32-S3
// No need to modify this file, changes to pins imported from variant.h
// Most is similar to https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h
#ifndef Pins_Arduino_h
#define Pins_Arduino_h
#include <stdint.h>
#include <variant.h>
#define USB_VID 0x303a
#define USB_PID 0x1001
// Serial
static const uint8_t TX = 43;
static const uint8_t RX = 44;
// Default SPI will be mapped to Radio
static const uint8_t SS = LORA_CS;
static const uint8_t SCK = SPI_SCK;
static const uint8_t MOSI = SPI_MOSI;
static const uint8_t MISO = SPI_MISO;
// The default Wire will be mapped to PMU and RTC
static const uint8_t SCL = I2C_SCL;
static const uint8_t SDA = I2C_SDA;
static const uint8_t A0 = 1;
static const uint8_t A1 = 2;
static const uint8_t A2 = 3;
static const uint8_t A3 = 4;
static const uint8_t A4 = 5;
static const uint8_t A5 = 6;
static const uint8_t A6 = 7;
static const uint8_t A7 = 8;
static const uint8_t A8 = 9;
static const uint8_t A9 = 10;
static const uint8_t A10 = 11;
static const uint8_t A11 = 12;
static const uint8_t A12 = 13;
static const uint8_t A13 = 14;
static const uint8_t A14 = 15;
static const uint8_t A15 = 16;
static const uint8_t A16 = 17;
static const uint8_t A17 = 18;
static const uint8_t A18 = 19;
static const uint8_t A19 = 20;
static const uint8_t T1 = 1;
static const uint8_t T2 = 2;
static const uint8_t T3 = 3;
static const uint8_t T4 = 4;
static const uint8_t T5 = 5;
static const uint8_t T6 = 6;
static const uint8_t T7 = 7;
static const uint8_t T8 = 8;
static const uint8_t T9 = 9;
static const uint8_t T10 = 10;
static const uint8_t T11 = 11;
static const uint8_t T12 = 12;
static const uint8_t T13 = 13;
static const uint8_t T14 = 14;
#endif /* Pins_Arduino_h */
+160
View File
@@ -0,0 +1,160 @@
[ThinkNode_M9]
extends = esp32_base
board = thinknode_m9
board_check = true
board_build.partitions = default_16MB.csv
upload_protocol = esptool
build_flags =
${esp32_base.build_flags}
${sensor_base.build_flags}
-I variants/thinknode_m9
-I src/helpers/esp32
-I src/helpers/sensors
-D THINKNODE_M9
-D PIN_BUZZER=9
-D PIN_BOARD_SCL=6
-D PIN_BOARD_SDA=7
-D P_LORA_NSS=39
-D P_LORA_RESET=45
-D P_LORA_BUSY=41
-D P_LORA_SCLK=40
-D P_LORA_MISO=38
-D P_LORA_MOSI=47
-D P_LORA_DIO_1=42
-D USE_LR1110
-D RF_SWITCH_TABLE
-D RADIO_CLASS=CustomLR1110
-D WRAPPER_CLASS=CustomLR1110Wrapper
-D LR11X0_DIO_AS_RF_SWITCH=true
-D LR11X0_DIO3_TCXO_VOLTAGE=3.3
-D LORA_TX_POWER=22
-D DISPLAY_CLASS=ST7789Display
-D DISPLAY_FLIP_VERTICALLY=1
-D DISPLAY_SCALE_X=2.5f ; 320 / 128
-D DISPLAY_SCALE_Y=3.75f ; 240 / 64
-D ST7789
-D PIN_TFT_VDD_CTL=-1
-D PIN_TFT_LEDA_CTL=17
-D PIN_TFT_RST=14
-D PIN_GPS_RX=3
-D PIN_GPS_TX=2
-D PIN_GPS_EN=11
-D PIN_GPS_EN_ACTIVE=LOW
-D PIN_GPS_RESET=5
-D PIN_GPS_RESET_ACTIVE=HIGH
-D GPS_BAUD_RATE=115200
-D ENV_INCLUDE_GPS=1
-D PIN_VBAT_READ=13
build_src_filter = ${esp32_base.build_src_filter}
+<helpers/sensors/EnvironmentSensorManager.cpp>
+<helpers/ui/ST7789Display.cpp>
+<helpers/ui/OLEDDisplay.cpp>
+<helpers/ui/OLEDDisplayFonts.cpp>
+<helpers/*.cpp>
+<../variants/thinknode_m9>
lib_deps = ${esp32_base.lib_deps}
${sensor_base.lib_deps}
adafruit/Adafruit GFX Library @ ^1.12.1
[env:ThinkNode_M9_repeater_]
extends = ThinkNode_M9
build_flags =
${ThinkNode_M9.build_flags}
-D ADVERT_NAME='"ThinkNode M9 Repeater"'
-D ADVERT_LAT=0.0
-D ADVERT_LON=0.0
-D ADMIN_PASSWORD='"password"'
-D MAX_NEIGHBOURS=50
;-D MESH_PACKET_LOGGING=1
;-D MESH_DEBUG=1
build_src_filter = ${ThinkNode_M9.build_src_filter}
+<../examples/simple_repeater/*.cpp>
lib_deps =
${ThinkNode_M9.lib_deps}
${esp32_ota.lib_deps}
[env:ThinkNode_M9_room_server_]
extends = ThinkNode_M9
build_src_filter = ${ThinkNode_M9.build_src_filter}
+<../examples/simple_room_server>
build_flags =
${ThinkNode_M9.build_flags}
-D ADVERT_NAME='"ThinkNode M9 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_M9.lib_deps}
${esp32_ota.lib_deps}
[env:ThinkNode_M9_companion_radio_ble_]
extends = ThinkNode_M9
build_flags =
${ThinkNode_M9.build_flags}
-I examples/companion_radio/ui-new
-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_M9.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ThinkNode_M9.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:ThinkNode_M9_companion_radio_usb_]
extends = ThinkNode_M9
build_flags =
${ThinkNode_M9.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-D OFFLINE_QUEUE_SIZE=256
build_src_filter = ${ThinkNode_M9.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ThinkNode_M9.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:ThinkNode_M9_companion_radio_wifi_]
extends = ThinkNode_M9
build_flags =
${ThinkNode_M9.build_flags}
-I examples/companion_radio/ui-new
-D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40
-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_M9.build_src_filter}
+<helpers/esp32/*.cpp>
+<helpers/ui/buzzer.cpp>
+<helpers/ui/MomentaryButton.cpp>
+<../examples/companion_radio/*.cpp>
+<../examples/companion_radio/ui-new/*.cpp>
lib_deps =
${ThinkNode_M9.lib_deps}
densaugeo/base64 @ ~1.4.0
end2endzone/NonBlockingRTTTL@^1.3.0
[env:ThinkNode_M9_kiss_modem]
extends = ThinkNode_M9
build_src_filter = ${ThinkNode_M9.build_src_filter}
+<../examples/kiss_modem/>
+78
View File
@@ -0,0 +1,78 @@
#include <Arduino.h>
#include "target.h"
ThinkNodeM9Board board;
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
#include <helpers/sensors/MicroNMEALocationProvider.h>
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,
};
#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
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 <ThinkNodeM9Board.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 <helpers/ui/ST7789Display.h>
#include <helpers/ui/MomentaryButton.h>
#endif
extern ThinkNodeM9Board board;
extern WRAPPER_CLASS radio_driver;
extern AutoDiscoverRTCClock rtc_clock;
extern EnvironmentSensorManager sensors;
#ifdef DISPLAY_CLASS
extern DISPLAY_CLASS display;
extern MomentaryButton user_btn;
#endif
bool radio_init();
mesh::LocalIdentity radio_new_identity();
+7
View File
@@ -0,0 +1,7 @@
#include "variant.h"
#include <Arduino.h>
void initVariant() {
}
+114
View File
@@ -0,0 +1,114 @@
/*Power*/
#define VEXT_ENABLE 18
#define VEXT_ON_VALUE LOW
#define PIN_GPS_EN 11
#define GPS_EN_ACTIVE LOW
/*Wire Interface*/
#define WIRE_INTERFACES_COUNT 2
// I2C keybuttons
#define I2C_SCL1 21
#define I2C_SDA1 20
#define KB_INT 12
// I2C peripheral`
#define I2C_SCL 6
#define I2C_SDA 7
/*LED*/
#define PIN_LED 13
#define KB_LED 46
/*BUZZER*/
#define PIN_BUZZER 9
/*CHARGE_CHECK*/
#define DONE 8
#define EXT_PWR_DETECT 1
#define EXT_CHRG_DETECT 1
#define EXT_CHRG_DETECT_VALUE LOW
/*GPS*/
#define GPS_L76K
#define GPS_BAUDRATE 9600
#define PIN_GPS_RESET 5
#define PIN_GPS_PPS 4
#define PIN_GPS_STANDBY 10 // An output to wake GPS, low means allow sleep, high means force wake
#define GPS_TX_PIN 3
#define GPS_RX_PIN 2
#define GPS_THREAD_INTERVAL 50
/*SPI*/
#define SPI_MOSI 47
#define SPI_SCK 40
#define SPI_MISO 38
/*SD Card*/
#define SDCARD_CS 48
#define SD_SPI_FREQUENCY 80000000U
/*Screen*/
// #define USE_ST7789 1
#define ST7789_CS 16
#define ST7789_RS 15
#define ST7789_TE 19
#define ST7789_SDA SPI_MOSI // MOSI
#define ST7789_SCK SPI_SCK
#define ST7789_RESET 14
#define ST7789_MISO SPI_MISO
#define ST7789_BUSY -1
#define ST7789_BL 17
#define ST7789_SPI_HOST SPI2_HOST
#define SPI_FREQUENCY 80000000
#define SPI_READ_FREQUENCY 16000000
#define USE_TFTDISPLAY 1
#define TFT_CS ST7789_CS
#define TFT_BL ST7789_BL
#define TFT_HEIGHT 320
#define TFT_WIDTH 240
#define TFT_OFFSET_X 0
#define TFT_OFFSET_Y 0
#define TFT_OFFSET_ROTATION 0
#define TFT_PWM_FREQ 44000
#define TFT_PWM_CHANNEL 7
#define TFT_INVERT_LIGHT true
#define TFT_BACKLIGHT_ON LOW
#define SCREEN_ROTATE
#define SCREEN_TRANSITION_FRAMERATE 5
#define BRIGHTNESS_DEFAULT 128
#define LGFX_PANEL ST7789
#define DISPLAY_SIZE 320x240
#define LGFX_ROTATION 0
#define LGFX_CFG_HOST SPI2_HOST
#define LGFX_PIN_SCK ST7789_SCK
#define LGFX_PIN_MOSI ST7789_SDA
#define LGFX_PIN_DC ST7789_RS
#define LGFX_PIN_CS ST7789_CS
#define LGFX_PIN_BL ST7789_BL
#define LGFX_SCREEN_WIDTH TFT_WIDTH
#define LGFX_SCREEN_HEIGHT TFT_HEIGHT
#define LGFX_INVERT_LIGHT true
#define LGFX_PWM_FREQ 44000
#define LGFX_PWM_CHANNEL 7
/*Lora radio*/
#define LORA_SCK SPI_SCK
#define LORA_MISO SPI_MISO
#define LORA_MOSI SPI_MOSI
#define LORA_CS 39
#define LORA_RESET 45
#define LORA_DIO0 41
#define USE_LR1110
#define LR1110_IRQ_PIN 42
#define LR1110_NRESET_PIN LORA_RESET
#define LR1110_BUSY_PIN LORA_DIO0
#define LR1110_SPI_NSS_PIN LORA_CS
#define LR1110_SPI_SCK_PIN LORA_SCK
#define LR1110_SPI_MOSI_PIN LORA_MOSI
#define LR1110_SPI_MISO_PIN LORA_MISO
#define LR11X0_DIO3_TCXO_VOLTAGE 3.3
#define LR11X0_DIO_AS_RF_SWITCH
/*RTC*/
#define PCF8563_RTC 0x51