mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
thinknode_m5: initial port
This commit is contained in:
parent
ffbc24b3e7
commit
d0f6def4f9
8 changed files with 421 additions and 0 deletions
|
|
@ -5,9 +5,17 @@
|
|||
#define DISPLAY_ROTATION 3
|
||||
#endif
|
||||
|
||||
#ifdef ESP32
|
||||
SPIClass SPI1 = SPIClass(FSPI);
|
||||
#endif
|
||||
|
||||
bool GxEPDDisplay::begin() {
|
||||
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
#ifdef ESP32
|
||||
SPI1.begin(PIN_DISPLAY_SCLK, PIN_DISPLAY_MISO, PIN_DISPLAY_MOSI, PIN_DISPLAY_CS);
|
||||
#else
|
||||
SPI1.begin();
|
||||
#endif
|
||||
display.init(115200, true, 2, false);
|
||||
display.setRotation(DISPLAY_ROTATION);
|
||||
setTextSize(1); // Default to size 1
|
||||
|
|
|
|||
40
variants/thinknode_m5/ThinknodeM5Board.cpp
Normal file
40
variants/thinknode_m5/ThinknodeM5Board.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#include "ThinknodeM5Board.h"
|
||||
|
||||
|
||||
|
||||
void ThinknodeM5Board::begin() {
|
||||
pinMode(PIN_VEXT_EN, OUTPUT);
|
||||
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
||||
delay(20); // allow power rail to discharge
|
||||
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
||||
delay(120); // give display time to bias on cold boot
|
||||
ESP32Board::begin();
|
||||
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
|
||||
}
|
||||
|
||||
void ThinknodeM5Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void ThinknodeM5Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t ThinknodeM5Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||
|
||||
uint32_t mv = 0;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
||||
delayMicroseconds(200);
|
||||
}
|
||||
mv /= 8;
|
||||
|
||||
analogReadResolution(10);
|
||||
return static_cast<uint16_t>(mv * ADC_MULTIPLIER );
|
||||
}
|
||||
|
||||
const char* ThinknodeM5Board::getManufacturerName() const {
|
||||
return "Elecrow ThinkNode M2";
|
||||
}
|
||||
18
variants/thinknode_m5/ThinknodeM5Board.h
Normal file
18
variants/thinknode_m5/ThinknodeM5Board.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class ThinknodeM5Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
};
|
||||
28
variants/thinknode_m5/pins_arduino.h
Normal file
28
variants/thinknode_m5/pins_arduino.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// 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 = GPS_TX;
|
||||
static const uint8_t RX = GPS_RX;
|
||||
|
||||
// Default SPI will be mapped to Radio
|
||||
static const uint8_t SS = P_LORA_NSS;
|
||||
static const uint8_t SCK = P_LORA_SCLK;
|
||||
static const uint8_t MOSI = P_LORA_MISO;
|
||||
static const uint8_t MISO = P_LORA_MOSI;
|
||||
|
||||
// The default Wire will be mapped to PMU and RTC
|
||||
static const uint8_t SCL = PIN_BOARD_SCL;
|
||||
static const uint8_t SDA = PIN_BOARD_SDA;
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
217
variants/thinknode_m5/platformio.ini
Normal file
217
variants/thinknode_m5/platformio.ini
Normal file
|
|
@ -0,0 +1,217 @@
|
|||
[ThinkNode_M5]
|
||||
extends = esp32_base
|
||||
board = ESP32-S3-WROOM-1-N4
|
||||
build_flags = ${esp32_base.build_flags}
|
||||
-I variants/thinknode_m5
|
||||
-D THINKNODE_M5
|
||||
-D GPS_RX=19
|
||||
-D GPS_TX=20
|
||||
-D PIN_VEXT_EN=46
|
||||
-D PIN_BUZZER=9
|
||||
-D PIN_VEXT_EN_ACTIVE=HIGH
|
||||
-D PIN_BOARD_SCL=1
|
||||
-D PIN_BOARD_SDA=2
|
||||
-D P_LORA_DIO_1=4
|
||||
-D P_LORA_NSS=17
|
||||
-D P_LORA_RESET=6 ; RADIOLIB_NC
|
||||
-D P_LORA_BUSY=5 ; DIO2 = 38
|
||||
-D P_LORA_SCLK=16
|
||||
-D P_LORA_MISO=7
|
||||
-D P_LORA_MOSI=15
|
||||
-D PIN_USER_BTN=21
|
||||
-D PIN_STATUS_LED=1
|
||||
-D LED_STATE_ON=HIGH
|
||||
-D PIN_LED=3
|
||||
-D DISPLAY_ROTATION=4
|
||||
-D DISPLAY_CLASS=GxEPDDisplay
|
||||
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
|
||||
-D EINK_SCALE_X=1.5625f
|
||||
-D EINK_SCALE_Y=1.5625f
|
||||
-D EINK_X_OFFSET=0
|
||||
-D EINK_Y_OFFSET=10
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=3.3
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D MESH_DEBUG=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/ui/GxEPDDisplay.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<../variants/thinknode_m5>
|
||||
lib_deps = ${esp32_base.lib_deps}
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
[env:ThinkNode_M5_Repeater]
|
||||
extends = ThinkNode_M5
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-D ADVERT_NAME='"Thinknode M2 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_M5.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
; [env:ThinkNode_M5_Repeater_bridge_rs232]
|
||||
; extends = ThinkNode_M5
|
||||
; build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
; +<helpers/bridges/RS232Bridge.cpp>
|
||||
; +<../examples/simple_repeater/*.cpp>
|
||||
; build_flags =
|
||||
; ${ThinkNode_M5.build_flags}
|
||||
; -D ADVERT_NAME='"RS232 Bridge"'
|
||||
; -D ADVERT_LAT=0.0
|
||||
; -D ADVERT_LON=0.0
|
||||
; -D ADMIN_PASSWORD='"password"'
|
||||
; -D MAX_NEIGHBOURS=8
|
||||
; -D WITH_RS232_BRIDGE=Serial2
|
||||
; -D WITH_RS232_BRIDGE_RX=5
|
||||
; -D WITH_RS232_BRIDGE_TX=6
|
||||
; ; -D MESH_PACKET_LOGGING=1
|
||||
; ; -D MESH_DEBUG=1
|
||||
; lib_deps =
|
||||
; ${ThinkNode_M5.lib_deps}
|
||||
; ${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M5_Repeater_bridge_espnow]
|
||||
extends = ThinkNode_M5
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<helpers/bridges/ESPNowBridge.cpp>
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-D ADVERT_NAME='"ESPNow Bridge"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
-D WITH_ESPNOW_BRIDGE=1
|
||||
-D WITH_ESPNOW_BRIDGE_SECRET='"shared-secret"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M5_room_server]
|
||||
extends = ThinkNode_M5
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-D ADVERT_NAME='"Thinknode M2 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_M5.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M5_terminal_chat]
|
||||
extends = ThinkNode_M5
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ThinkNode_M5_companion_radio_ble]
|
||||
extends = ThinkNode_M5
|
||||
build_flags =
|
||||
${ThinkNode_M5.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
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M5_companion_radio_usb]
|
||||
extends = ThinkNode_M5
|
||||
build_flags =
|
||||
${ThinkNode_M5.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_M5.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M5_companion_radio_wifi]
|
||||
extends = ThinkNode_M5
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"Livebox-633C"'
|
||||
-D WIFI_PWD='"vvQUHGSxsWd7fKMYSr"'
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M5_companion_radio_serial]
|
||||
extends = ThinkNode_M5
|
||||
build_flags =
|
||||
${ThinkNode_M5.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D SERIAL_TX=D6
|
||||
-D SERIAL_RX=D7
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M5.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M5.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
57
variants/thinknode_m5/target.cpp
Normal file
57
variants/thinknode_m5/target.cpp
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
ThinknodeM5Board board;
|
||||
|
||||
#if defined(P_LORA_SCLK)
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
#else
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
|
||||
#endif
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
// pinMode(21, INPUT);
|
||||
// pinMode(48, OUTPUT);
|
||||
#if defined(P_LORA_SCLK)
|
||||
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
|
||||
return radio.std_init(&spi);
|
||||
#else
|
||||
return radio.std_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
32
variants/thinknode_m5/target.h
Normal file
32
variants/thinknode_m5/target.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
//#include <helpers/ESP32Board.h>
|
||||
#include <ThinknodeM5Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/GxEPDDisplay.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern ThinknodeM5Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
|
||||
21
variants/thinknode_m5/variant.h
Normal file
21
variants/thinknode_m5/variant.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#define I2C_SCL 1
|
||||
#define I2C_SDA 2
|
||||
#define PIN_VBAT_READ 8
|
||||
#define AREF_VOLTAGE (3.0)
|
||||
#define ADC_MULTIPLIER (2.11F)
|
||||
#define PIN_BUZZER 9
|
||||
#define PIN_VEXT_EN_ACTIVE HIGH
|
||||
#define PIN_VEXT_EN 46
|
||||
#define PIN_USER_BTN 21
|
||||
#define PIN_LED 3
|
||||
#define PIN_STATUS_LED 1
|
||||
#define PIN_PWRBTN 14
|
||||
|
||||
#define PIN_DISPLAY_MISO (-1)
|
||||
#define PIN_DISPLAY_MOSI (45)
|
||||
#define PIN_DISPLAY_SCLK (38)
|
||||
#define PIN_DISPLAY_CS (39)
|
||||
#define PIN_DISPLAY_DC (40)
|
||||
#define PIN_DISPLAY_RST (41)
|
||||
#define PIN_DISPLAY_BUSY (42)
|
||||
#define DISP_BACKLIGHT (5)
|
||||
Loading…
Add table
Add a link
Reference in a new issue