mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-07-21 04:42:16 +00:00
@@ -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"
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "esp32s3_out.ld",
|
||||
"memory_type": "qio_opi",
|
||||
"partitions": "default_16MB.csv"
|
||||
},
|
||||
"core": "esp32",
|
||||
"extra_flags": [
|
||||
"-DBOARD_HAS_PSRAM",
|
||||
"-DARDUINO_USB_CDC_ON_BOOT=0",
|
||||
"-DARDUINO_USB_MODE=0",
|
||||
"-DARDUINO_RUNNING_CORE=1",
|
||||
"-DARDUINO_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-M9"
|
||||
},
|
||||
"connectivity": [
|
||||
"wifi",
|
||||
"bluetooth",
|
||||
"lora"
|
||||
],
|
||||
"debug": {
|
||||
"default_tool": "esp-builtin",
|
||||
"onboard_tools": [
|
||||
"esp-builtin"
|
||||
],
|
||||
"openocd_target": "esp32s3.cfg"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"espidf"
|
||||
],
|
||||
"name": "elecrow-thinknode-m9",
|
||||
"upload": {
|
||||
"flash_size": "16MB",
|
||||
"maximum_ram_size": 524288,
|
||||
"maximum_size": 16777216,
|
||||
"use_1200bps_touch": true,
|
||||
"wait_for_upload_port": true,
|
||||
"require_upload_port": true,
|
||||
"speed": 921600
|
||||
},
|
||||
"url": "https://www.elecrow.com/thinknode-m1-meshtastic-lora-signal-transceiver-powered-by-nrf52840-with-154-screen-support-gps.html",
|
||||
"vendor": "ELECROW"
|
||||
}
|
||||
@@ -18,6 +18,7 @@ Once you have a working app/project, you need to be able to demonstrate it exist
|
||||
| 0100 | MeshCore Open | zsylvester@monitormx.com — https://github.com/zjs81/meshcore-open |
|
||||
| 0110 - 011F | Ripple | ripple_biz@protonmail.com — https://buymeacoffee.com/ripplebiz |
|
||||
| 0120 | MCO Advanced | most.original.address@gmail.com — https://hdden.ru/MCOa/ |
|
||||
| 0130 - 013F | StreamSensor | william@housedillon.com - https://housedillon.com/blog/lora-e5-with-seeed-fusion |
|
||||
| FF00 - FFFF | -reserved for testing/dev- | |
|
||||
|
||||
(add rows, inside the range 0100 - FEFF for custom apps)
|
||||
|
||||
@@ -116,6 +116,10 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DisplayDriver* disp = NULL;
|
||||
if (display.begin()) {
|
||||
@@ -249,7 +253,10 @@ void loop() {
|
||||
ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.loop();
|
||||
#endif
|
||||
|
||||
if (!the_mesh.hasPendingWork()) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
|
||||
|
||||
@@ -33,6 +33,10 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
#if defined(MESH_DEBUG) && defined(NRF52_PLATFORM)
|
||||
// give some extra time for serial to settle so
|
||||
// boot debug messages can be seen on terminal
|
||||
@@ -152,6 +156,9 @@ void loop() {
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.loop();
|
||||
#endif
|
||||
if (the_mesh.getNodePrefs()->powersaving_enabled && !the_mesh.hasPendingWork()) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
|
||||
|
||||
@@ -24,6 +24,10 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
@@ -115,4 +119,7 @@ void loop() {
|
||||
ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -560,6 +560,10 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
if (!radio_init()) { halt(); }
|
||||
|
||||
fast_rng.begin(radio_driver.getRngSeed());
|
||||
@@ -591,4 +595,7 @@ void setup() {
|
||||
void loop() {
|
||||
the_mesh.loop();
|
||||
rtc_clock.tick();
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -58,6 +58,10 @@ void setup() {
|
||||
|
||||
board.begin();
|
||||
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.begin();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
if (display.begin()) {
|
||||
display.startFrame();
|
||||
@@ -147,4 +151,7 @@ void loop() {
|
||||
ui_task.loop();
|
||||
#endif
|
||||
rtc_clock.tick();
|
||||
#ifdef HAS_EXTERNAL_WATCHDOG
|
||||
external_watchdog.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@ monitor_speed = 115200
|
||||
lib_deps =
|
||||
SPI
|
||||
Wire
|
||||
jgromes/RadioLib @ ^7.6.0
|
||||
;jgromes/RadioLib @ ^7.7.1
|
||||
https://github.com/jgromes/RadioLib.git#6d8934836678d8894e3d556550475b37dce3e2b6
|
||||
rweather/Crypto @ ^0.4.0
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
melopero/Melopero RV3028 @ ^1.1.0
|
||||
|
||||
@@ -42,6 +42,7 @@ void AutoDiscoverRTCClock::begin(TwoWire& wire) {
|
||||
}
|
||||
|
||||
if (i2c_probe(wire, PCF8563_ADDRESS)) {
|
||||
MESH_DEBUG_PRINTLN("PCF8563: Found");
|
||||
rtc_8563_success = rtc_8563.begin(&wire);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
class ExternalWatchdogManager {
|
||||
protected:
|
||||
unsigned long last_feed_watchdog;
|
||||
public:
|
||||
ExternalWatchdogManager() { last_feed_watchdog = 0; }
|
||||
virtual bool begin() { return false; }
|
||||
virtual void loop() { }
|
||||
virtual unsigned long getIntervalMs() const { return 0; }
|
||||
virtual void feed() { }
|
||||
};
|
||||
@@ -93,13 +93,15 @@ bool RegionMap::load(FILESYSTEM* _fs, const char* path) {
|
||||
while (num_regions < MAX_REGION_ENTRIES) {
|
||||
auto r = ®ions[num_regions];
|
||||
|
||||
success = file.read((uint8_t *) &r->id, sizeof(r->id)) == sizeof(r->id);
|
||||
int n = file.read((uint8_t *) &r->id, sizeof(r->id));
|
||||
if (n == 0) break; // clean EOF
|
||||
success = (n == sizeof(r->id));
|
||||
success = success && file.read((uint8_t *) &r->parent, sizeof(r->parent)) == sizeof(r->parent);
|
||||
success = success && file.read((uint8_t *) r->name, sizeof(r->name)) == sizeof(r->name);
|
||||
success = success && file.read((uint8_t *) &r->flags, sizeof(r->flags)) == sizeof(r->flags);
|
||||
success = success && file.read(pad, sizeof(pad)) == sizeof(pad);
|
||||
|
||||
if (!success) break; // EOF
|
||||
if (!success) break; // partial read or corruption
|
||||
|
||||
if (r->id >= next_id) { // make sure next_id is valid
|
||||
next_id = r->id + 1;
|
||||
@@ -108,7 +110,7 @@ bool RegionMap::load(FILESYSTEM* _fs, const char* path) {
|
||||
}
|
||||
}
|
||||
file.close();
|
||||
return true;
|
||||
return success;
|
||||
}
|
||||
}
|
||||
return false; // failed
|
||||
|
||||
@@ -66,11 +66,11 @@ class CustomLLCC68 : public LLCC68 {
|
||||
setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
#if defined(SX126X_RXEN) || defined(SX126X_TXEN)
|
||||
#ifndef SX1262X_RXEN
|
||||
#define SX1262X_RXEN RADIOLIB_NC
|
||||
#ifndef SX126X_RXEN
|
||||
#define SX126X_RXEN RADIOLIB_NC
|
||||
#endif
|
||||
#ifndef SX1262X_TXEN
|
||||
#define SX1262X_TXEN RADIOLIB_NC
|
||||
#ifndef SX126X_TXEN
|
||||
#define SX126X_TXEN RADIOLIB_NC
|
||||
#endif
|
||||
setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
||||
#endif
|
||||
|
||||
@@ -66,11 +66,11 @@ class CustomSX1268 : public SX1268 {
|
||||
setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
#if defined(SX126X_RXEN) || defined(SX126X_TXEN)
|
||||
#ifndef SX1262X_RXEN
|
||||
#define SX1262X_RXEN RADIOLIB_NC
|
||||
#ifndef SX126X_RXEN
|
||||
#define SX126X_RXEN RADIOLIB_NC
|
||||
#endif
|
||||
#ifndef SX1262X_TXEN
|
||||
#define SX1262X_TXEN RADIOLIB_NC
|
||||
#ifndef SX126X_TXEN
|
||||
#define SX126X_TXEN RADIOLIB_NC
|
||||
#endif
|
||||
setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
|
||||
#endif
|
||||
|
||||
@@ -50,14 +50,14 @@ class CustomSX1276 : public SX1276 {
|
||||
setCurrentLimit(SX127X_CURRENT_LIMIT);
|
||||
#endif
|
||||
|
||||
#if defined(SX176X_RXEN) || defined(SX176X_TXEN)
|
||||
#ifndef SX176X_RXEN
|
||||
#define SX176X_RXEN RADIOLIB_NC
|
||||
#if defined(SX127X_RXEN) || defined(SX127X_TXEN)
|
||||
#ifndef SX127X_RXEN
|
||||
#define SX127X_RXEN RADIOLIB_NC
|
||||
#endif
|
||||
#ifndef SX176X_TXEN
|
||||
#define SX176X_TXEN RADIOLIB_NC
|
||||
#ifndef SX127X_TXEN
|
||||
#define SX127X_TXEN RADIOLIB_NC
|
||||
#endif
|
||||
setRfSwitchPins(SX176X_RXEN, SX176X_TXEN);
|
||||
setRfSwitchPins(SX127X_RXEN, SX127X_TXEN);
|
||||
#endif
|
||||
|
||||
setCRC(1);
|
||||
|
||||
@@ -889,11 +889,11 @@ void EnvironmentSensorManager::stop_gps() {
|
||||
void EnvironmentSensorManager::loop() {
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
static long next_gps_update = 0;
|
||||
static unsigned long next_gps_update = 0;
|
||||
if (gps_active) {
|
||||
_location->loop();
|
||||
}
|
||||
if (millis() > next_gps_update) {
|
||||
if ((long)(millis() - next_gps_update) > 0) {
|
||||
|
||||
if(gps_active){
|
||||
#ifdef RAK_WISBLOCK_GPS
|
||||
|
||||
@@ -42,14 +42,14 @@ class MicroNMEALocationProvider : public LocationProvider {
|
||||
int8_t _claims = 0;
|
||||
int _pin_reset;
|
||||
int _pin_en;
|
||||
long next_check = 0;
|
||||
unsigned long next_check = 0;
|
||||
long time_valid = 0;
|
||||
unsigned long _last_time_sync = 0;
|
||||
static const unsigned long TIME_SYNC_INTERVAL = 1800000; // Re-sync every 30 minutes
|
||||
|
||||
public :
|
||||
MicroNMEALocationProvider(Stream& ser, mesh::RTCClock* clock = NULL, int pin_reset = GPS_RESET, int pin_en = GPS_EN,RefCountedDigitalPin* peripher_power=NULL) :
|
||||
_gps_serial(&ser), nmea(_nmeaBuffer, sizeof(_nmeaBuffer)), _pin_reset(pin_reset), _pin_en(pin_en), _clock(clock), _peripher_power(peripher_power) {
|
||||
nmea(_nmeaBuffer, sizeof(_nmeaBuffer)), _clock(clock), _gps_serial(&ser), _peripher_power(peripher_power), _pin_reset(pin_reset), _pin_en(pin_en) {
|
||||
if (_pin_reset != -1) {
|
||||
pinMode(_pin_reset, OUTPUT);
|
||||
digitalWrite(_pin_reset, GPS_RESET_FORCE);
|
||||
@@ -62,9 +62,7 @@ public :
|
||||
|
||||
void claim() {
|
||||
_claims++;
|
||||
if (_claims > 0) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
}
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
}
|
||||
|
||||
void release() {
|
||||
@@ -143,7 +141,7 @@ public :
|
||||
|
||||
if (!isValid()) time_valid = 0;
|
||||
|
||||
if (millis() > next_check) {
|
||||
if ((long)(millis() - next_check) > 0) {
|
||||
next_check = millis() + 1000;
|
||||
// Re-enable time sync periodically when GPS has valid fix
|
||||
if (!_time_sync_needed && _clock != NULL && (millis() - _last_time_sync) > TIME_SYNC_INTERVAL) {
|
||||
|
||||
@@ -1,12 +1,409 @@
|
||||
#include "ST7735Display.h"
|
||||
|
||||
#ifndef DISPLAY_ROTATION
|
||||
#define DISPLAY_ROTATION 2
|
||||
//#include <Fonts/GFXFF/FreeSans9pt7b.h>
|
||||
|
||||
// Optimised ST7735 display driver, derived from Adafruit_ST7735 library.
|
||||
|
||||
#define ST_CMD_DELAY 0x80 // special signifier for command lists
|
||||
|
||||
#define ST77XX_NOP 0x00
|
||||
#define ST77XX_SWRESET 0x01
|
||||
#define ST77XX_RDDID 0x04
|
||||
#define ST77XX_RDDST 0x09
|
||||
|
||||
#define ST77XX_SLPIN 0x10
|
||||
#define ST77XX_SLPOUT 0x11
|
||||
#define ST77XX_PTLON 0x12
|
||||
#define ST77XX_NORON 0x13
|
||||
|
||||
#define ST77XX_INVOFF 0x20
|
||||
#define ST77XX_INVON 0x21
|
||||
#define ST77XX_DISPOFF 0x28
|
||||
#define ST77XX_DISPON 0x29
|
||||
#define ST77XX_CASET 0x2A
|
||||
#define ST77XX_RASET 0x2B
|
||||
#define ST77XX_RAMWR 0x2C
|
||||
#define ST77XX_RAMRD 0x2E
|
||||
|
||||
#define ST77XX_PTLAR 0x30
|
||||
#define ST77XX_TEOFF 0x34
|
||||
#define ST77XX_TEON 0x35
|
||||
#define ST77XX_MADCTL 0x36
|
||||
#define ST77XX_COLMOD 0x3A
|
||||
|
||||
#define ST77XX_MADCTL_MY 0x80
|
||||
#define ST77XX_MADCTL_MX 0x40
|
||||
#define ST77XX_MADCTL_MV 0x20
|
||||
#define ST77XX_MADCTL_ML 0x10
|
||||
#define ST77XX_MADCTL_RGB 0x00
|
||||
|
||||
#define ST77XX_RDID1 0xDA
|
||||
#define ST77XX_RDID2 0xDB
|
||||
#define ST77XX_RDID3 0xDC
|
||||
#define ST77XX_RDID4 0xDD
|
||||
|
||||
// Some ready-made 16-bit ('565') color settings:
|
||||
#define ST77XX_BLACK 0x0000
|
||||
#define ST77XX_WHITE 0xFFFF
|
||||
#define ST77XX_RED 0xF800
|
||||
#define ST77XX_GREEN 0x07E0
|
||||
#define ST77XX_BLUE 0x001F
|
||||
#define ST77XX_CYAN 0x07FF
|
||||
#define ST77XX_MAGENTA 0xF81F
|
||||
#define ST77XX_YELLOW 0xFFE0
|
||||
#define ST77XX_ORANGE 0xFC00
|
||||
|
||||
|
||||
// some flags for initR() :(
|
||||
#define INITR_GREENTAB 0x00
|
||||
#define INITR_REDTAB 0x01
|
||||
#define INITR_BLACKTAB 0x02
|
||||
#define INITR_18GREENTAB INITR_GREENTAB
|
||||
#define INITR_18REDTAB INITR_REDTAB
|
||||
#define INITR_18BLACKTAB INITR_BLACKTAB
|
||||
#define INITR_144GREENTAB 0x01
|
||||
#define INITR_MINI160x80 0x04
|
||||
#define INITR_HALLOWING 0x05
|
||||
#define INITR_MINI160x80_PLUGIN 0x06
|
||||
|
||||
// Some register settings
|
||||
#define ST7735_MADCTL_BGR 0x08
|
||||
#define ST7735_MADCTL_MH 0x04
|
||||
|
||||
#define ST7735_FRMCTR1 0xB1
|
||||
#define ST7735_FRMCTR2 0xB2
|
||||
#define ST7735_FRMCTR3 0xB3
|
||||
#define ST7735_INVCTR 0xB4
|
||||
#define ST7735_DISSET5 0xB6
|
||||
|
||||
#define ST7735_PWCTR1 0xC0
|
||||
#define ST7735_PWCTR2 0xC1
|
||||
#define ST7735_PWCTR3 0xC2
|
||||
#define ST7735_PWCTR4 0xC3
|
||||
#define ST7735_PWCTR5 0xC4
|
||||
#define ST7735_VMCTR1 0xC5
|
||||
|
||||
#define ST7735_PWCTR6 0xFC
|
||||
|
||||
#define ST7735_GMCTRP1 0xE0
|
||||
#define ST7735_GMCTRN1 0xE1
|
||||
|
||||
// Some ready-made 16-bit ('565') color settings:
|
||||
#define ST7735_BLACK ST77XX_BLACK
|
||||
#define ST7735_WHITE ST77XX_WHITE
|
||||
#define ST7735_RED ST77XX_RED
|
||||
#define ST7735_GREEN ST77XX_GREEN
|
||||
#define ST7735_BLUE ST77XX_BLUE
|
||||
#define ST7735_CYAN ST77XX_CYAN
|
||||
#define ST7735_MAGENTA ST77XX_MAGENTA
|
||||
#define ST7735_YELLOW ST77XX_YELLOW
|
||||
#define ST7735_ORANGE ST77XX_ORANGE
|
||||
|
||||
static TFT_eSPI lcd = TFT_eSPI(160, 80);
|
||||
static uint32_t curr_color;
|
||||
|
||||
#if defined(HELTEC_LORA_V3) || defined(HELTEC_TRACKER_V2)
|
||||
static SPIClass tft_spi(HSPI);
|
||||
#define _spi (&tft_spi)
|
||||
#else
|
||||
#define _spi (&SPI1)
|
||||
#endif
|
||||
|
||||
SPISettings _spiSettings = SPISettings(40000000, MSBFIRST, SPI_MODE0);
|
||||
|
||||
// clang-format off
|
||||
static const uint8_t PROGMEM
|
||||
Bcmd[] = { // Init commands for 7735B screens
|
||||
18, // 18 commands in list:
|
||||
ST77XX_SWRESET, ST_CMD_DELAY, // 1: Software reset, no args, w/delay
|
||||
50, // 50 ms delay
|
||||
ST77XX_SLPOUT, ST_CMD_DELAY, // 2: Out of sleep mode, no args, w/delay
|
||||
255, // 255 = max (500 ms) delay
|
||||
ST77XX_COLMOD, 1+ST_CMD_DELAY, // 3: Set color mode, 1 arg + delay:
|
||||
0x05, // 16-bit color
|
||||
10, // 10 ms delay
|
||||
ST7735_FRMCTR1, 3+ST_CMD_DELAY, // 4: Frame rate control, 3 args + delay:
|
||||
0x00, // fastest refresh
|
||||
0x06, // 6 lines front porch
|
||||
0x03, // 3 lines back porch
|
||||
10, // 10 ms delay
|
||||
ST77XX_MADCTL, 1, // 5: Mem access ctl (directions), 1 arg:
|
||||
0x08, // Row/col addr, bottom-top refresh
|
||||
ST7735_DISSET5, 2, // 6: Display settings #5, 2 args:
|
||||
0x15, // 1 clk cycle nonoverlap, 2 cycle gate
|
||||
// rise, 3 cycle osc equalize
|
||||
0x02, // Fix on VTL
|
||||
ST7735_INVCTR, 1, // 7: Display inversion control, 1 arg:
|
||||
0x0, // Line inversion
|
||||
ST7735_PWCTR1, 2+ST_CMD_DELAY, // 8: Power control, 2 args + delay:
|
||||
0x02, // GVDD = 4.7V
|
||||
0x70, // 1.0uA
|
||||
10, // 10 ms delay
|
||||
ST7735_PWCTR2, 1, // 9: Power control, 1 arg, no delay:
|
||||
0x05, // VGH = 14.7V, VGL = -7.35V
|
||||
ST7735_PWCTR3, 2, // 10: Power control, 2 args, no delay:
|
||||
0x01, // Opamp current small
|
||||
0x02, // Boost frequency
|
||||
ST7735_VMCTR1, 2+ST_CMD_DELAY, // 11: Power control, 2 args + delay:
|
||||
0x3C, // VCOMH = 4V
|
||||
0x38, // VCOML = -1.1V
|
||||
10, // 10 ms delay
|
||||
ST7735_PWCTR6, 2, // 12: Power control, 2 args, no delay:
|
||||
0x11, 0x15,
|
||||
ST7735_GMCTRP1,16, // 13: Gamma Adjustments (pos. polarity), 16 args + delay:
|
||||
0x09, 0x16, 0x09, 0x20, // (Not entirely necessary, but provides
|
||||
0x21, 0x1B, 0x13, 0x19, // accurate colors)
|
||||
0x17, 0x15, 0x1E, 0x2B,
|
||||
0x04, 0x05, 0x02, 0x0E,
|
||||
ST7735_GMCTRN1,16+ST_CMD_DELAY, // 14: Gamma Adjustments (neg. polarity), 16 args + delay:
|
||||
0x0B, 0x14, 0x08, 0x1E, // (Not entirely necessary, but provides
|
||||
0x22, 0x1D, 0x18, 0x1E, // accurate colors)
|
||||
0x1B, 0x1A, 0x24, 0x2B,
|
||||
0x06, 0x06, 0x02, 0x0F,
|
||||
10, // 10 ms delay
|
||||
ST77XX_CASET, 4, // 15: Column addr set, 4 args, no delay:
|
||||
0x00, 0x02, // XSTART = 2
|
||||
0x00, 0x81, // XEND = 129
|
||||
ST77XX_RASET, 4, // 16: Row addr set, 4 args, no delay:
|
||||
0x00, 0x02, // XSTART = 1
|
||||
0x00, 0x81, // XEND = 160
|
||||
ST77XX_NORON, ST_CMD_DELAY, // 17: Normal display on, no args, w/delay
|
||||
10, // 10 ms delay
|
||||
ST77XX_DISPON, ST_CMD_DELAY, // 18: Main screen turn on, no args, delay
|
||||
255 }, // 255 = max (500 ms) delay
|
||||
|
||||
Rcmd1[] = { // 7735R init, part 1 (red or green tab)
|
||||
14, // 14 commands in list:
|
||||
/*ST77XX_SWRESET, ST_CMD_DELAY, // 1: Software reset, 0 args, w/delay
|
||||
150, */ // 150 ms delay
|
||||
ST77XX_SLPOUT, ST_CMD_DELAY, // 2: Out of sleep mode, 0 args, w/delay
|
||||
120, // 120 ms delay
|
||||
ST7735_FRMCTR1, 3, // 3: Framerate ctrl - normal mode, 3 arg:
|
||||
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
|
||||
ST7735_FRMCTR2, 3, // 4: Framerate ctrl - idle mode, 3 args:
|
||||
0x01, 0x2C, 0x2D, // Rate = fosc/(1x2+40) * (LINE+2C+2D)
|
||||
ST7735_FRMCTR3, 6, // 5: Framerate - partial mode, 6 args:
|
||||
0x01, 0x2C, 0x2D, // Dot inversion mode
|
||||
0x01, 0x2C, 0x2D, // Line inversion mode
|
||||
ST7735_INVCTR, 1, // 6: Display inversion ctrl, 1 arg:
|
||||
0x07, // No inversion
|
||||
ST7735_PWCTR1, 3, // 7: Power control, 3 args, no delay:
|
||||
0xA2,
|
||||
0x02, // -4.6V
|
||||
0x84, // AUTO mode
|
||||
ST7735_PWCTR2, 1, // 8: Power control, 1 arg, no delay:
|
||||
0xC5, // VGH25=2.4C VGSEL=-10 VGH=3 * AVDD
|
||||
ST7735_PWCTR3, 2, // 9: Power control, 2 args, no delay:
|
||||
0x0A, // Opamp current small
|
||||
0x00, // Boost frequency
|
||||
ST7735_PWCTR4, 2, // 10: Power control, 2 args, no delay:
|
||||
0x8A, // BCLK/2,
|
||||
0x2A, // opamp current small & medium low
|
||||
ST7735_PWCTR5, 2, // 11: Power control, 2 args, no delay:
|
||||
0x8A, 0xEE,
|
||||
ST7735_VMCTR1, 1, // 12: Power control, 1 arg, no delay:
|
||||
0x0E,
|
||||
ST77XX_INVOFF, 0, // 13: Don't invert display, no args
|
||||
ST77XX_MADCTL, 1, // 14: Mem access ctl (directions), 1 arg:
|
||||
0xC8, // row/col addr, bottom-top refresh
|
||||
ST77XX_COLMOD, 1, // 15: set color mode, 1 arg, no delay:
|
||||
0x05 }, // 16-bit color
|
||||
|
||||
Rcmd2green[] = { // 7735R init, part 2 (green tab only)
|
||||
2, // 2 commands in list:
|
||||
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
|
||||
0x00, 0x02, // XSTART = 0
|
||||
0x00, 0x7F+0x02, // XEND = 127
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x01, // XSTART = 0
|
||||
0x00, 0x9F+0x01 }, // XEND = 159
|
||||
|
||||
Rcmd2red[] = { // 7735R init, part 2 (red tab only)
|
||||
2, // 2 commands in list:
|
||||
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x7F, // XEND = 127
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x9F }, // XEND = 159
|
||||
|
||||
Rcmd2green144[] = { // 7735R init, part 2 (green 1.44 tab)
|
||||
2, // 2 commands in list:
|
||||
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x7F, // XEND = 127
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x7F }, // XEND = 127
|
||||
|
||||
Rcmd2green160x80[] = { // 7735R init, part 2 (mini 160x80)
|
||||
2, // 2 commands in list:
|
||||
ST77XX_CASET, 4, // 1: Column addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x4F, // XEND = 79
|
||||
ST77XX_RASET, 4, // 2: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x9F }, // XEND = 159
|
||||
|
||||
Rcmd2green160x80plugin[] = { // 7735R init, part 2 (mini 160x80 with plugin FPC)
|
||||
3, // 3 commands in list:
|
||||
ST77XX_INVON, 0, // 1: Display is inverted
|
||||
ST77XX_CASET, 4, // 2: Column addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x4F, // XEND = 79
|
||||
ST77XX_RASET, 4, // 3: Row addr set, 4 args, no delay:
|
||||
0x00, 0x00, // XSTART = 0
|
||||
0x00, 0x9F }, // XEND = 159
|
||||
|
||||
Rcmd2invert[] = { // Tracker V1, part 2
|
||||
1, // 1 command in list:
|
||||
ST77XX_INVON, 0 }, // 1: Display is inverted
|
||||
|
||||
Rcmd3[] = { // 7735R init, part 3 (red or green tab)
|
||||
2, // 2 commands in list:
|
||||
ST7735_GMCTRP1, 16 , // 1: Gamma Adjustments (pos. polarity), 16 args + delay:
|
||||
0x02, 0x1c, 0x07, 0x12, // (Not entirely necessary, but provides
|
||||
0x37, 0x32, 0x29, 0x2d, // accurate colors)
|
||||
0x29, 0x25, 0x2B, 0x39,
|
||||
0x00, 0x01, 0x03, 0x10,
|
||||
ST7735_GMCTRN1, 16 , // 2: Gamma Adjustments (neg. polarity), 16 args + delay:
|
||||
0x03, 0x1d, 0x07, 0x06, // (Not entirely necessary, but provides
|
||||
0x2E, 0x2C, 0x29, 0x2D, // accurate colors)
|
||||
0x2E, 0x2E, 0x37, 0x3F,
|
||||
0x00, 0x00, 0x02, 0x10 }; // 100 ms delay
|
||||
|
||||
static int16_t _xstart = 0; ///< Internal framebuffer X offset
|
||||
static int16_t _ystart = 0; ///< Internal framebuffer Y offset
|
||||
static uint8_t _colstart = 0; ///< Some displays need this changed to offset
|
||||
static uint8_t _rowstart = 0; ///< Some displays need this changed to offset
|
||||
static uint8_t rotation = 0;
|
||||
static int16_t _width = 0; ///< Display width as modified by current rotation
|
||||
static int16_t _height = 0; ///< Display height as modified by current rotation
|
||||
|
||||
static void set_CS(uint8_t level) {
|
||||
//if (_cs != (uint8_t) -1) {
|
||||
digitalWrite(PIN_TFT_CS, level);
|
||||
//}
|
||||
}
|
||||
static void sendCommand(uint8_t com) {
|
||||
set_CS(HIGH);
|
||||
digitalWrite(PIN_TFT_DC, LOW);
|
||||
set_CS(LOW);
|
||||
_spi->beginTransaction(_spiSettings);
|
||||
_spi->transfer(com);
|
||||
_spi->endTransaction();
|
||||
set_CS(HIGH);
|
||||
digitalWrite(PIN_TFT_DC, HIGH);
|
||||
}
|
||||
|
||||
static void WriteData(uint8_t data) {
|
||||
digitalWrite(PIN_TFT_CS, LOW);
|
||||
_spi->beginTransaction(_spiSettings);
|
||||
_spi->transfer(data);
|
||||
_spi->endTransaction();
|
||||
digitalWrite(PIN_TFT_CS, HIGH);
|
||||
}
|
||||
static void SPI_WRITE32(uint32_t l) {
|
||||
_spi->transfer(l >> 24);
|
||||
_spi->transfer(l >> 16);
|
||||
_spi->transfer(l >> 8);
|
||||
_spi->transfer(l);
|
||||
}
|
||||
static void writeCommand(uint8_t cmd) {
|
||||
digitalWrite(PIN_TFT_DC, LOW);
|
||||
_spi->transfer(cmd);
|
||||
digitalWrite(PIN_TFT_DC, HIGH);
|
||||
}
|
||||
|
||||
static void displayInit(const uint8_t *addr) {
|
||||
uint8_t numCommands, cmd, numArgs;
|
||||
uint16_t ms;
|
||||
|
||||
numCommands = pgm_read_byte(addr++); // Number of commands to follow
|
||||
while (numCommands--) { // For each command...
|
||||
cmd = pgm_read_byte(addr++); // Read command
|
||||
numArgs = pgm_read_byte(addr++); // Number of args to follow
|
||||
ms = numArgs & ST_CMD_DELAY; // If hibit set, delay follows args
|
||||
numArgs &= ~ST_CMD_DELAY; // Mask out delay bit
|
||||
sendCommand(cmd);
|
||||
for (int k = 0; k < numArgs; k++) {
|
||||
WriteData(addr[k]);
|
||||
}
|
||||
addr += numArgs;
|
||||
|
||||
if (ms) {
|
||||
ms = pgm_read_byte(addr++); // Read post-command delay time (ms)
|
||||
if (ms == 255)
|
||||
ms = 500; // If 255, delay for 500 ms
|
||||
delay(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void setRotation(uint8_t m) {
|
||||
uint8_t madctl = 0;
|
||||
|
||||
rotation = m & 3; // can't be higher than 3
|
||||
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MY | ST7735_MADCTL_BGR;
|
||||
|
||||
_height = 160;
|
||||
_width = 80;
|
||||
_xstart = _colstart;
|
||||
_ystart = _rowstart;
|
||||
break;
|
||||
case 1:
|
||||
madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
|
||||
|
||||
_width = 160;
|
||||
_height = 80;
|
||||
_ystart = _colstart;
|
||||
_xstart = _rowstart;
|
||||
break;
|
||||
case 2:
|
||||
madctl = ST7735_MADCTL_BGR;
|
||||
|
||||
_height = 160;
|
||||
_width = 80;
|
||||
_xstart = _colstart;
|
||||
_ystart = _rowstart;
|
||||
break;
|
||||
case 3:
|
||||
madctl = ST77XX_MADCTL_MX | ST77XX_MADCTL_MV | ST7735_MADCTL_BGR;
|
||||
|
||||
_width = 160;
|
||||
_height = 80;
|
||||
_ystart = _colstart;
|
||||
_xstart = _rowstart;
|
||||
break;
|
||||
}
|
||||
|
||||
sendCommand(ST77XX_MADCTL);
|
||||
WriteData(madctl);
|
||||
}
|
||||
|
||||
static void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
x += _xstart;
|
||||
y += _ystart;
|
||||
uint32_t xa = ((uint32_t)x << 16) | (x + w - 1);
|
||||
uint32_t ya = ((uint32_t)y << 16) | (y + h - 1);
|
||||
|
||||
writeCommand(ST77XX_CASET); // Column addr set
|
||||
SPI_WRITE32(xa);
|
||||
|
||||
writeCommand(ST77XX_RASET); // Row addr set
|
||||
SPI_WRITE32(ya);
|
||||
|
||||
writeCommand(ST77XX_RAMWR); // write to RAM
|
||||
}
|
||||
|
||||
#define SCALE_X 1.25f // 160 / 128
|
||||
#define SCALE_Y 1.25f // 80 / 64
|
||||
|
||||
static TFT_eSprite *sprite = NULL;
|
||||
|
||||
bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
return true;
|
||||
/*
|
||||
@@ -16,53 +413,110 @@ bool ST7735Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
*/
|
||||
}
|
||||
|
||||
#ifndef PIN_TFT_LEDA_CTL_ACTIVE
|
||||
#define PIN_TFT_LEDA_CTL_ACTIVE HIGH
|
||||
#endif
|
||||
|
||||
bool ST7735Display::begin() {
|
||||
if (!sprite) {
|
||||
// alloc offscreen canvas
|
||||
sprite = new TFT_eSprite(&lcd);
|
||||
if (sprite) {
|
||||
if (sprite->createSprite(160, 80)) {
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
sprite->setTextColor(curr_color = ST77XX_WHITE);
|
||||
} else {
|
||||
Serial.printf("ST7735Display: failed to alloc canvas pixels");
|
||||
}
|
||||
} else {
|
||||
Serial.printf("ST7735Display: failed to alloc canvas");
|
||||
}
|
||||
}
|
||||
|
||||
if (!_isOn) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
|
||||
delay(100); // TEMP!!
|
||||
pinMode(PIN_TFT_RST, OUTPUT);
|
||||
pinMode(PIN_TFT_CS, OUTPUT);
|
||||
pinMode(PIN_TFT_DC, OUTPUT);
|
||||
pinMode(PIN_TFT_LEDA_CTL, OUTPUT);
|
||||
#if defined(PIN_TFT_LEDA_CTL_ACTIVE)
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
|
||||
#else
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, HIGH);
|
||||
#endif
|
||||
digitalWrite(PIN_TFT_RST, HIGH);
|
||||
|
||||
#if defined(HELTEC_T1)
|
||||
display.initR(INITR_MINI160x80);
|
||||
display.setRotation(DISPLAY_ROTATION);
|
||||
#elif defined(HELTEC_TRACKER_V2) || defined(HELTEC_T096)
|
||||
display.initR(INITR_MINI160x80);
|
||||
display.setRotation(DISPLAY_ROTATION);
|
||||
uint8_t madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV |ST7735_MADCTL_BGR;//Adjust color to BGR
|
||||
display.sendCommand(ST77XX_MADCTL, &madctl, 1);
|
||||
#ifdef ESP_PLATFORM
|
||||
_spi->begin(PIN_TFT_SCL, -1 /* _miso */, PIN_TFT_SDA /* _mosi */, -1);
|
||||
#else
|
||||
display.initR(INITR_MINI160x80_PLUGIN);
|
||||
display.setRotation(DISPLAY_ROTATION);
|
||||
_spi->begin();
|
||||
#endif
|
||||
display.setSPISpeed(40000000);
|
||||
display.fillScreen(ST77XX_BLACK);
|
||||
display.setTextColor(ST77XX_WHITE);
|
||||
display.setTextSize(2);
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
_spi->setClockDivider(SPI_CLOCK_DIV2);
|
||||
|
||||
_height = 80;
|
||||
_width = 160;
|
||||
#if defined(HELTEC_LORA_V3) // Tracker v1
|
||||
_colstart = 26;
|
||||
_rowstart = 1;
|
||||
#else
|
||||
_colstart = 24;
|
||||
_rowstart = 0;
|
||||
#endif
|
||||
|
||||
_resetAndInit();
|
||||
|
||||
sendCommand(ST77XX_DISPON);
|
||||
|
||||
_isOn = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ST7735Display::_resetAndInit() {
|
||||
// Pulse Reset low for 10ms
|
||||
digitalWrite(PIN_TFT_RST, HIGH);
|
||||
delay(2);
|
||||
digitalWrite(PIN_TFT_RST, LOW);
|
||||
delay(10);
|
||||
digitalWrite(PIN_TFT_RST, HIGH);
|
||||
delay(2);
|
||||
|
||||
// run init commands
|
||||
displayInit(Rcmd1);
|
||||
#if defined(HELTEC_TRACKER_V2) || defined(HELTEC_T096)
|
||||
displayInit(Rcmd2green160x80);
|
||||
//uint8_t madctl = ST77XX_MADCTL_MY | ST77XX_MADCTL_MV |ST7735_MADCTL_BGR;//Adjust color to BGR
|
||||
//display.sendCommand(ST77XX_MADCTL, &madctl, 1);
|
||||
#elif defined(HELTEC_LORA_V3) // Tracker v1
|
||||
displayInit(Rcmd2invert); // invert RGB
|
||||
#endif
|
||||
displayInit(Rcmd3);
|
||||
setRotation(DISPLAY_ROTATION);
|
||||
|
||||
// clear the buffer before display on
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
endFrame();
|
||||
|
||||
// turn on backlight
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
|
||||
|
||||
}
|
||||
|
||||
void ST7735Display::turnOn() {
|
||||
ST7735Display::begin();
|
||||
if (!_isOn) {
|
||||
if (_peripher_power) _peripher_power->claim();
|
||||
_resetAndInit();
|
||||
sendCommand(ST77XX_DISPON);
|
||||
|
||||
// Now turn on the backlight
|
||||
// digitalWrite(PIN_TFT_LEDA_CTL, PIN_TFT_LEDA_CTL_ACTIVE);
|
||||
_isOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ST7735Display::turnOff() {
|
||||
if (_isOn) {
|
||||
digitalWrite(PIN_TFT_RST, LOW);
|
||||
#if defined(PIN_TFT_LEDA_CTL_ACTIVE)
|
||||
sendCommand(ST77XX_DISPOFF);
|
||||
|
||||
//digitalWrite(PIN_TFT_RST, LOW);
|
||||
// Now turn off the backlight
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, !PIN_TFT_LEDA_CTL_ACTIVE);
|
||||
#else
|
||||
digitalWrite(PIN_TFT_LEDA_CTL, LOW);
|
||||
#endif
|
||||
_isOn = false;
|
||||
|
||||
if (_peripher_power) _peripher_power->release();
|
||||
@@ -70,78 +524,90 @@ void ST7735Display::turnOff() {
|
||||
}
|
||||
|
||||
void ST7735Display::clear() {
|
||||
//Serial.println("DBG: display.Clear");
|
||||
display.fillScreen(ST77XX_BLACK);
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
}
|
||||
|
||||
void ST7735Display::startFrame(Color bkg) {
|
||||
display.fillScreen(0x00);
|
||||
display.setTextColor(ST77XX_WHITE);
|
||||
display.setTextSize(1); // This one affects size of Please wait... message
|
||||
display.cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
sprite->fillScreen(ST77XX_BLACK);
|
||||
sprite->setTextColor(curr_color = ST77XX_WHITE);
|
||||
sprite->setFreeFont();
|
||||
sprite->setTextSize(1); // This one affects size of Please wait... message
|
||||
//sprite->cp437(true); // Use full 256 char 'Code Page 437' font
|
||||
}
|
||||
|
||||
void ST7735Display::setTextSize(int sz) {
|
||||
display.setTextSize(sz);
|
||||
sprite->setTextSize(sz);
|
||||
}
|
||||
|
||||
void ST7735Display::setColor(Color c) {
|
||||
switch (c) {
|
||||
case DisplayDriver::DARK :
|
||||
_color = ST77XX_BLACK;
|
||||
curr_color = ST77XX_BLACK;
|
||||
break;
|
||||
case DisplayDriver::LIGHT :
|
||||
_color = ST77XX_WHITE;
|
||||
curr_color = ST77XX_WHITE;
|
||||
break;
|
||||
case DisplayDriver::RED :
|
||||
_color = ST77XX_RED;
|
||||
curr_color = ST77XX_RED;
|
||||
break;
|
||||
case DisplayDriver::GREEN :
|
||||
_color = ST77XX_GREEN;
|
||||
curr_color = ST77XX_GREEN;
|
||||
break;
|
||||
case DisplayDriver::BLUE :
|
||||
_color = ST77XX_BLUE;
|
||||
curr_color = ST77XX_BLUE;
|
||||
break;
|
||||
case DisplayDriver::YELLOW :
|
||||
_color = ST77XX_YELLOW;
|
||||
curr_color = ST77XX_YELLOW;
|
||||
break;
|
||||
case DisplayDriver::ORANGE :
|
||||
_color = ST77XX_ORANGE;
|
||||
curr_color = ST77XX_ORANGE;
|
||||
break;
|
||||
default:
|
||||
_color = ST77XX_WHITE;
|
||||
curr_color = ST77XX_WHITE;
|
||||
break;
|
||||
}
|
||||
display.setTextColor(_color);
|
||||
sprite->setTextColor(curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::setCursor(int x, int y) {
|
||||
display.setCursor(x*SCALE_X, y*SCALE_Y);
|
||||
sprite->setCursor(x*SCALE_X, y*SCALE_Y);
|
||||
}
|
||||
|
||||
void ST7735Display::print(const char* str) {
|
||||
display.print(str);
|
||||
sprite->print(str);
|
||||
}
|
||||
|
||||
void ST7735Display::fillRect(int x, int y, int w, int h) {
|
||||
display.fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
|
||||
sprite->fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::drawRect(int x, int y, int w, int h) {
|
||||
display.drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _color);
|
||||
sprite->drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
display.drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, _color);
|
||||
sprite->drawBitmap(x*SCALE_X, y*SCALE_Y, bits, w, h, curr_color);
|
||||
}
|
||||
|
||||
uint16_t ST7735Display::getTextWidth(const char* str) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
return w / SCALE_X;
|
||||
return sprite->textWidth(str) / SCALE_X;
|
||||
}
|
||||
|
||||
void ST7735Display::endFrame() {
|
||||
// display.display();
|
||||
// blit the canvas buffer to LCD
|
||||
set_CS(LOW);
|
||||
_spi->beginTransaction(_spiSettings);
|
||||
uint16_t x, y;
|
||||
uint16_t* pixels = (uint16_t *) ((TFT_eSprite *) sprite)->getPointer();
|
||||
for (y = 0; y < 80; y++, pixels += 160) {
|
||||
setAddrWindow(0, y, 160, 1);
|
||||
#ifdef ESP_PLATFORM
|
||||
_spi->transferBytes((uint8_t *)pixels, NULL, 2 * 160);
|
||||
#else
|
||||
_spi->transfer(pixels, NULL, 2 * 160);
|
||||
#endif
|
||||
}
|
||||
|
||||
_spi->endTransaction();
|
||||
set_CS(HIGH);
|
||||
}
|
||||
|
||||
@@ -3,28 +3,25 @@
|
||||
#include "DisplayDriver.h"
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_ST7735.h>
|
||||
#include "TFT_eSPI.h"
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
|
||||
class ST7735Display : public DisplayDriver {
|
||||
Adafruit_ST7735 display;
|
||||
bool _isOn;
|
||||
uint16_t _color;
|
||||
RefCountedDigitalPin* _peripher_power;
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
#ifdef USE_PIN_TFT
|
||||
ST7735Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
|
||||
display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST),
|
||||
// display(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_SDA, PIN_TFT_SCL, PIN_TFT_RST),
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
}
|
||||
#else
|
||||
ST7735Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
|
||||
display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),
|
||||
// display(&SPI1, PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RST),
|
||||
_peripher_power(peripher_power)
|
||||
{
|
||||
_isOn = false;
|
||||
@@ -46,4 +43,7 @@ public:
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
|
||||
uint16_t getTextWidth(const char* str) override;
|
||||
void endFrame() override;
|
||||
|
||||
protected:
|
||||
void _resetAndInit();
|
||||
};
|
||||
|
||||
@@ -18,6 +18,14 @@
|
||||
#define SCALE_Y 2.109375f // 135 / 64
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_SCALE_X
|
||||
#define SCALE_X DISPLAY_SCALE_X
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_SCALE_Y
|
||||
#define SCALE_Y DISPLAY_SCALE_Y
|
||||
#endif
|
||||
|
||||
bool ST7789Display::begin() {
|
||||
if(!_isOn) {
|
||||
pinMode(PIN_TFT_VDD_CTL, OUTPUT);
|
||||
@@ -32,6 +40,9 @@ bool ST7789Display::begin() {
|
||||
|
||||
display.init();
|
||||
display.landscapeScreen();
|
||||
#ifdef DISPLAY_FLIP_VERTICALLY
|
||||
display.flipScreenVertically();
|
||||
#endif
|
||||
display.displayOn();
|
||||
setCursor(0,0);
|
||||
|
||||
@@ -49,6 +60,9 @@ void ST7789Display::turnOn() {
|
||||
// Re-initialize the display
|
||||
display.init();
|
||||
display.displayOn();
|
||||
#ifdef DISPLAY_FLIP_VERTICALLY
|
||||
display.flipScreenVertically();
|
||||
#endif
|
||||
delay(20);
|
||||
|
||||
// Now turn on the backlight
|
||||
|
||||
@@ -14,8 +14,10 @@ class ST7789Display : public DisplayDriver {
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
public:
|
||||
#ifdef HELTEC_VISION_MASTER_T190
|
||||
#if defined(HELTEC_VISION_MASTER_T190)
|
||||
ST7789Display() : DisplayDriver(128, 64), display(&SPI, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 320, 170,PIN_TFT_SDA,-1,PIN_TFT_SCL) {_isOn = false;}
|
||||
#elif defined(THINKNODE_M9)
|
||||
ST7789Display() : DisplayDriver(128, 64), display(&SPI, ST7789_RESET, ST7789_RS, ST7789_CS, GEOMETRY_RAWMODE, 320, 240, ST7789_SDA, ST7789_MISO, ST7789_SCK) {_isOn = false;}
|
||||
#else
|
||||
ST7789Display() : DisplayDriver(128, 64), display(&SPI1, PIN_TFT_RST, PIN_TFT_DC, PIN_TFT_CS, GEOMETRY_RAWMODE, 240, 135) {_isOn = false;}
|
||||
#endif
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
@@ -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 */
|
||||
@@ -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/>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, HIGH);
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
Executable
+64
@@ -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 */
|
||||
Executable
+160
@@ -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/>
|
||||
@@ -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
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "variant.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
void initVariant() {
|
||||
|
||||
}
|
||||
Executable
+114
@@ -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
|
||||
Reference in New Issue
Block a user