From a0cc3bab4be311a3fd1a27c040a832cee6fef9fc Mon Sep 17 00:00:00 2001 From: Rococo88 Date: Thu, 7 May 2026 12:24:06 +0200 Subject: [PATCH 01/17] Refactor WiFi auto-reconnect to use non-blocking polling --- examples/companion_radio/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index 80e9da347..4395c5b38 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -105,6 +105,12 @@ void halt() { while (1) ; } +/* WIFI RECONNECT TRACKERS */ +#if defined(ESP32) && defined(WIFI_SSID) + bool wifi_needs_reconnect = false; + unsigned long last_wifi_reconnect_attempt = 0; +#endif + void setup() { Serial.begin(115200); @@ -195,6 +201,18 @@ void setup() { #ifdef WIFI_SSID board.setInhibitSleep(true); // prevent sleep when WiFi is active + WiFi.setAutoReconnect(true); + + WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){ + if (event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED) { + WIFI_DEBUG_PRINTLN("WiFi disconnected. Flagging for reconnect..."); + wifi_needs_reconnect = true; + } else if (event == ARDUINO_EVENT_WIFI_STA_GOT_IP) { + WIFI_DEBUG_PRINTLN("WiFi connected successfully!"); + wifi_needs_reconnect = false; + } + }); + WiFi.begin(WIFI_SSID, WIFI_PWD); serial_interface.begin(TCP_PORT); #elif defined(BLE_PIN_CODE) @@ -229,4 +247,14 @@ void loop() { ui_task.loop(); #endif rtc_clock.tick(); + +#if defined(ESP32) && defined(WIFI_SSID) + // Safely attempt to reconnect every 10 seconds if flagged + if (wifi_needs_reconnect && (millis() - last_wifi_reconnect_attempt > 10000)) { + WIFI_DEBUG_PRINTLN("Attempting manual WiFi reconnect..."); + WiFi.disconnect(); + WiFi.reconnect(); + last_wifi_reconnect_attempt = millis(); + } +#endif } From b612ba49f294171625852d60723fd4de75da5803 Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 8 May 2026 00:40:33 +1000 Subject: [PATCH 02/17] reduce dram0_0 usage by lowering OFFLINE_QUEUE_SIZE some older ESP32 boards were pushing the limits of the dram segment causing the linker to fail, especially for ble and wifi firmwares. lowering OFFLINE_QUEUE_SIZE reduces dram usage --- variants/heltec_v2/platformio.ini | 6 +++--- variants/lilygo_tbeam_SX1262/platformio.ini | 2 +- variants/lilygo_tbeam_SX1276/platformio.ini | 2 +- variants/lilygo_tlora_v2_1/platformio.ini | 6 +++--- variants/meshadventurer/platformio.ini | 14 ++++++++------ 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/variants/heltec_v2/platformio.ini b/variants/heltec_v2/platformio.ini index c103dd8d5..e5beec235 100644 --- a/variants/heltec_v2/platformio.ini +++ b/variants/heltec_v2/platformio.ini @@ -159,7 +159,7 @@ build_flags = -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} @@ -178,12 +178,12 @@ build_flags = ${Heltec_lora32_v2.build_flags} -I examples/companion_radio/ui-new -D DISPLAY_CLASS=SSD1306Display - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D WIFI_DEBUG_LOGGING=1 -D WIFI_SSID='"myssid"' -D WIFI_PWD='"mypwd"' - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 build_src_filter = ${Heltec_lora32_v2.build_src_filter} diff --git a/variants/lilygo_tbeam_SX1262/platformio.ini b/variants/lilygo_tbeam_SX1262/platformio.ini index 77b39304a..3099f3ab9 100644 --- a/variants/lilygo_tbeam_SX1262/platformio.ini +++ b/variants/lilygo_tbeam_SX1262/platformio.ini @@ -42,7 +42,7 @@ build_flags = -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 ; -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 diff --git a/variants/lilygo_tbeam_SX1276/platformio.ini b/variants/lilygo_tbeam_SX1276/platformio.ini index 6853a232b..f15762322 100644 --- a/variants/lilygo_tbeam_SX1276/platformio.ini +++ b/variants/lilygo_tbeam_SX1276/platformio.ini @@ -41,7 +41,7 @@ build_flags = -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 ; -D BLE_DEBUG_LOGGING=1 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 ; -D RADIOLIB_DEBUG_BASIC=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 diff --git a/variants/lilygo_tlora_v2_1/platformio.ini b/variants/lilygo_tlora_v2_1/platformio.ini index f710d0700..367316686 100644 --- a/variants/lilygo_tlora_v2_1/platformio.ini +++ b/variants/lilygo_tlora_v2_1/platformio.ini @@ -95,7 +95,7 @@ build_flags = -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D BLE_PIN_CODE=123456 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 ; -D BLE_DEBUG_LOGGING=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -131,12 +131,12 @@ extends = LilyGo_TLora_V2_1_1_6 build_flags = ${LilyGo_TLora_V2_1_1_6.build_flags} -I examples/companion_radio/ui-new - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=8 -D WIFI_SSID='"ssid"' -D WIFI_PWD='"password"' -D WIFI_DEBUG_LOGGING=1 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + + diff --git a/variants/meshadventurer/platformio.ini b/variants/meshadventurer/platformio.ini index 2006a1801..f85be2388 100644 --- a/variants/meshadventurer/platformio.ini +++ b/variants/meshadventurer/platformio.ini @@ -183,8 +183,9 @@ build_flags = -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=40 + -D OFFLINE_QUEUE_SIZE=128 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 lib_deps = @@ -203,11 +204,11 @@ build_flags = -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=40 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 -D MESH_PACKET_LOGGING=1 -D MESH_DEBUG=1 lib_deps = @@ -262,7 +263,8 @@ build_flags = -D RADIO_CLASS=CustomSX1268 -D WRAPPER_CLASS=CustomSX1268Wrapper -D LORA_TX_POWER=22 - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 + -D OFFLINE_QUEUE_SIZE=128 -D MAX_GROUP_CHANNELS=40 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 @@ -282,11 +284,11 @@ build_flags = -D RADIO_CLASS=CustomSX1268 -D WRAPPER_CLASS=CustomSX1268Wrapper -D LORA_TX_POWER=22 - -D MAX_CONTACTS=100 + -D MAX_CONTACTS=160 -D MAX_GROUP_CHANNELS=40 -D BLE_PIN_CODE=123456 -D BLE_DEBUG_LOGGING=1 - -D OFFLINE_QUEUE_SIZE=256 + -D OFFLINE_QUEUE_SIZE=128 -D MESH_PACKET_LOGGING=1 -D MESH_DEBUG=1 lib_deps = From 5a6fd4c16aef4e236802204c22c211ac387d4666 Mon Sep 17 00:00:00 2001 From: jirogit Date: Fri, 8 May 2026 00:20:02 -0700 Subject: [PATCH 03/17] feat(techo-lite): add USB companion radio target for non-shell variant --- variants/lilygo_techo_lite/platformio.ini | 43 +++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/variants/lilygo_techo_lite/platformio.ini b/variants/lilygo_techo_lite/platformio.ini index d3408f95a..359b380ed 100644 --- a/variants/lilygo_techo_lite/platformio.ini +++ b/variants/lilygo_techo_lite/platformio.ini @@ -141,6 +141,49 @@ lib_deps = ${LilyGo_T-Echo-Lite.lib_deps} densaugeo/base64 @ ~1.4.0 +[env:LilyGo_T-Echo-Lite_non_shell_companion_radio_usb] +extends = LilyGo_T-Echo-Lite +upload_protocol = nrfutil +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 712704 +build_flags = + ${nrf52_base.build_flags} + -I variants/lilygo_techo_lite + -I src/helpers/nrf52 + -I lib/nrf52/s140_nrf52_6.1.1_API/include + -I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52 + -I src/helpers/ui + -I examples/companion_radio/ui-new + -D LILYGO_TECHO + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_POWER_EN=30 + -D SX126X_CURRENT_LIMIT=140 + -D SX126X_RX_BOOSTED_GAIN=1 + -D P_LORA_TX_LED=LED_GREEN + -D DISABLE_DIAGNOSTIC_OUTPUT + -D ENV_INCLUDE_GPS=1 + -D GPS_BAUD_RATE=9600 + -D PIN_GPS_EN=GPS_EN + -D AUTO_OFF_MILLIS=0 + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D UI_RECENT_LIST_SIZE=9 + -D AUTO_SHUTDOWN_MILLIVOLTS=3300 + ; -D MESH_PACKET_LOGGING=1 + ; -D MESH_DEBUG=1 +build_src_filter = ${nrf52_base.build_src_filter} + + + + + + + + + +<../variants/lilygo_techo_lite> + +<../examples/companion_radio/*.cpp> +lib_deps = + ${LilyGo_T-Echo-Lite.lib_deps} + densaugeo/base64 @ ~1.4.0 + [env:LilyGo_T-Echo-Lite_kiss_modem] extends = LilyGo_T-Echo-Lite build_src_filter = ${LilyGo_T-Echo-Lite.build_src_filter} From 77bd994a618047227038d0ec93fa74629437ad9f Mon Sep 17 00:00:00 2001 From: entr0p1 <1475255+entr0p1@users.noreply.github.com> Date: Sat, 9 May 2026 14:26:55 +1000 Subject: [PATCH 04/17] T-Echo Lite LoRa radio fixes - Set TCXO voltage to 1.8 (not defined previously, falls back to default) - Set correct variable name for SX1262 RX/TX pins - Fix SX1262 RX pin number --- variants/lilygo_techo_lite/platformio.ini | 2 ++ variants/lilygo_techo_lite/variant.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/variants/lilygo_techo_lite/platformio.ini b/variants/lilygo_techo_lite/platformio.ini index d3408f95a..ddfb1cdd8 100644 --- a/variants/lilygo_techo_lite/platformio.ini +++ b/variants/lilygo_techo_lite/platformio.ini @@ -12,6 +12,7 @@ build_flags = ${nrf52_base.build_flags} -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_POWER_EN=30 + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D P_LORA_TX_LED=LED_GREEN @@ -115,6 +116,7 @@ build_flags = -D WRAPPER_CLASS=CustomSX1262Wrapper -D LORA_TX_POWER=22 -D SX126X_POWER_EN=30 + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 -D P_LORA_TX_LED=LED_GREEN diff --git a/variants/lilygo_techo_lite/variant.h b/variants/lilygo_techo_lite/variant.h index 072021651..702ab3349 100644 --- a/variants/lilygo_techo_lite/variant.h +++ b/variants/lilygo_techo_lite/variant.h @@ -107,8 +107,8 @@ #define SX126X_DIO1 _PINNUM(1, 8) #define SX126X_BUSY _PINNUM(0, 14) #define SX126X_RESET _PINNUM(0, 7) -#define SX126X_RF_VC1 _PINNUM(0, 27) -#define SX126X_RF_VC2 _PINNUM(0, 33) +#define SX126X_RXEN _PINNUM(1, 1) +#define SX126X_TXEN _PINNUM(0, 27) #define P_LORA_DIO_1 SX126X_DIO1 #define P_LORA_NSS LORA_CS From 75fb07fc2c9d87238c1a2c88142d7e1e64415979 Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 9 May 2026 13:34:07 -0700 Subject: [PATCH 05/17] Add support for Station G3 and its software configurable LNA and PA1 --- boards/station-g3-esp32.json | 43 ++++++ variants/station_g3_esp32/StationG3Board.h | 114 +++++++++++++++ variants/station_g3_esp32/platformio.ini | 160 +++++++++++++++++++++ variants/station_g3_esp32/target.cpp | 46 ++++++ variants/station_g3_esp32/target.h | 27 ++++ 5 files changed, 390 insertions(+) create mode 100644 boards/station-g3-esp32.json create mode 100644 variants/station_g3_esp32/StationG3Board.h create mode 100644 variants/station_g3_esp32/platformio.ini create mode 100644 variants/station_g3_esp32/target.cpp create mode 100644 variants/station_g3_esp32/target.h diff --git a/boards/station-g3-esp32.json b/boards/station-g3-esp32.json new file mode 100644 index 000000000..abfe5eced --- /dev/null +++ b/boards/station-g3-esp32.json @@ -0,0 +1,43 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x303A", "0x1001"]], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "Station G3 ESP32", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://wiki.bqvoy.com/en/devkits/station-g3", + "vendor": "BQ Consulting" +} diff --git a/variants/station_g3_esp32/StationG3Board.h b/variants/station_g3_esp32/StationG3Board.h new file mode 100644 index 000000000..dc440d95f --- /dev/null +++ b/variants/station_g3_esp32/StationG3Board.h @@ -0,0 +1,114 @@ +#pragma once + +#include +#include +#include + +#ifndef P_PRIMARY_LNA_EN_ACTIVE +#define P_PRIMARY_LNA_EN_ACTIVE LOW +#endif + +#ifndef P_PA1_EN_ACTIVE +#define P_PA1_EN_ACTIVE HIGH +#endif + +class StationG3Board : public ESP32Board { + void setPAModeHigh(bool enabled) { +#ifdef P_PA1_EN + // Station G3 PA PL1 mode: LOW/open is PA low, HIGH/short is PA high. + digitalWrite(P_PA1_EN, enabled ? P_PA1_EN_ACTIVE : !P_PA1_EN_ACTIVE); +#endif + } + + void setPrimaryLNAControl(bool enabled) { +#ifdef P_PRIMARY_LNA_EN + // Station G3 primary LNA mode is active-low: LOW/open is LNA on, HIGH/short is LNA off. + digitalWrite(P_PRIMARY_LNA_EN, enabled ? P_PRIMARY_LNA_EN_ACTIVE : !P_PRIMARY_LNA_EN_ACTIVE); +#endif + } + +public: + void begin() { + ESP32Board::begin(); + +#ifdef P_PA1_EN + rtc_gpio_hold_dis((gpio_num_t)P_PA1_EN); + pinMode(P_PA1_EN, OUTPUT); + setPAModeHigh(false); +#endif + +#ifdef P_PRIMARY_LNA_EN + rtc_gpio_hold_dis((gpio_num_t)P_PRIMARY_LNA_EN); + pinMode(P_PRIMARY_LNA_EN, OUTPUT); + setPrimaryLNAControl(true); +#endif + + esp_reset_reason_t reason = esp_reset_reason(); + if (reason == ESP_RST_DEEPSLEEP) { + uint64_t wakeup_source = esp_sleep_get_ext1_wakeup_status(); + if (wakeup_source & (1ULL << P_LORA_DIO_1)) { + startup_reason = BD_STARTUP_RX_PACKET; + } + + rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS); + rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1); + } + } + + void setPrimaryLNAEnable(bool enabled) { + setPrimaryLNAControl(enabled); + } + + void setPrimaryPAHighPower(bool enabled) { + setPAModeHigh(enabled); + } + + void onBeforeTransmit() override { + ESP32Board::onBeforeTransmit(); + setPrimaryLNAControl(false); + } + + void onAfterTransmit() override { + ESP32Board::onAfterTransmit(); + setPrimaryLNAControl(true); + } + + void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) { + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); + + rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY); + rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1); + + rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS); + +#ifdef P_PA1_EN + setPAModeHigh(false); + rtc_gpio_hold_en((gpio_num_t)P_PA1_EN); +#endif + +#ifdef P_PRIMARY_LNA_EN + setPrimaryLNAControl(true); + rtc_gpio_hold_en((gpio_num_t)P_PRIMARY_LNA_EN); +#endif + + if (pin_wake_btn < 0) { + esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); + } else { + esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1) | (1ULL << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); + } + + if (secs > 0) { + esp_sleep_enable_timer_wakeup(secs * 1000000); + } + + esp_deep_sleep_start(); + } + + uint16_t getBattMilliVolts() override { + return 0; + } + + const char* getManufacturerName() const override { + return "Station G3 ESP32"; + } +}; diff --git a/variants/station_g3_esp32/platformio.ini b/variants/station_g3_esp32/platformio.ini new file mode 100644 index 000000000..b29388ef7 --- /dev/null +++ b/variants/station_g3_esp32/platformio.ini @@ -0,0 +1,160 @@ +[Station_G3_ESP32] +extends = esp32_base +board = station-g3-esp32 +build_flags = + ${esp32_base.build_flags} + ${sensor_base.build_flags} + -I variants/station_g3_esp32 + -I src/helpers/ui + -D STATION_G3_ESP32 + -D USE_SX1262 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D P_LORA_DIO_1=48 + -D P_LORA_NSS=11 + -D P_LORA_RESET=21 + -D P_LORA_BUSY=47 + -D P_LORA_SCLK=12 + -D P_LORA_MISO=14 + -D P_LORA_MOSI=13 + -D P_PA1_EN=9 ; PA PL1 Mode: LOW/open is PA low, HIGH/short is PA high. + -D P_PA1_EN_ACTIVE=HIGH + -D P_PRIMARY_LNA_EN=10 ; Primary Slot LNA Mode: LOW/open is LNA on, HIGH/short is LNA off. + -D P_PRIMARY_LNA_EN_ACTIVE=LOW + -D LORA_TX_POWER=7 ; configured as 7dbm, because the final output will be ~27dbm (~0.5w) if the PA is enabled. + -D MAX_LORA_TX_POWER=22 +; -D P_LORA_TX_LED=35 + -D PIN_BOARD_SDA=5 + -D PIN_BOARD_SCL=6 + -D PIN_USER_BTN=38 + -D PIN_GPS_RX=15 + -D PIN_GPS_TX=7 + -D SX126X_DIO2_AS_RF_SWITCH=true + -D SX126X_DIO3_TCXO_VOLTAGE=1.8 + -D SX126X_CURRENT_LIMIT=140 + -D SX126X_RX_BOOSTED_GAIN=0 + -D DISPLAY_CLASS=SH1106Display +build_src_filter = ${esp32_base.build_src_filter} + +<../variants/station_g3_esp32> + + + + + + +lib_deps = + ${esp32_base.lib_deps} + ${sensor_base.lib_deps} + adafruit/Adafruit SH110X @ ~2.1.13 + adafruit/Adafruit GFX Library @ ^1.12.1 + +[env:Station_G3_ESP32_repeater] +extends = Station_G3_ESP32 +build_flags = + ${Station_G3_ESP32.build_flags} + -D ADVERT_NAME='"Station G3 ESP32 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 = ${Station_G3_ESP32.build_src_filter} + +<../examples/simple_repeater> +lib_deps = + ${Station_G3_ESP32.lib_deps} + ${esp32_ota.lib_deps} + +[env:Station_G3_ESP32_logging_repeater] +extends = Station_G3_ESP32 +build_flags = + ${Station_G3_ESP32.build_flags} + -D ADVERT_NAME='"Station G3 ESP32 Logging 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 = ${Station_G3_ESP32.build_src_filter} + +<../examples/simple_repeater> +lib_deps = + ${Station_G3_ESP32.lib_deps} + ${esp32_ota.lib_deps} + +[env:Station_G3_ESP32_room_server] +extends = Station_G3_ESP32 +build_src_filter = ${Station_G3_ESP32.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Station_G3_ESP32.build_flags} + -D ADVERT_NAME='"Station G3 ESP32 Room"' + -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 = + ${Station_G3_ESP32.lib_deps} + ${esp32_ota.lib_deps} + +[env:Station_G3_ESP32_companion_radio_usb] +extends = Station_G3_ESP32 +build_flags = + ${Station_G3_ESP32.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 +; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 +; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 +build_src_filter = ${Station_G3_ESP32.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Station_G3_ESP32.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:Station_G3_ESP32_companion_radio_ble] +extends = Station_G3_ESP32 +build_flags = + ${Station_G3_ESP32.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=123456 + -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Station_G3_ESP32.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Station_G3_ESP32.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:Station_G3_ESP32_companion_radio_wifi] +extends = Station_G3_ESP32 +build_flags = + ${Station_G3_ESP32.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 +; -D MESH_DEBUG=1 +build_src_filter = ${Station_G3_ESP32.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Station_G3_ESP32.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:Station_G3_ESP32_kiss_modem] +extends = Station_G3_ESP32 +build_src_filter = ${Station_G3_ESP32.build_src_filter} + +<../examples/kiss_modem/> diff --git a/variants/station_g3_esp32/target.cpp b/variants/station_g3_esp32/target.cpp new file mode 100644 index 000000000..d3de074ba --- /dev/null +++ b/variants/station_g3_esp32/target.cpp @@ -0,0 +1,46 @@ +#include +#include "target.h" + +StationG3Board 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); + +#if ENV_INCLUDE_GPS + #include + MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock); + EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); +#else + EnvironmentSensorManager sensors; +#endif + +#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); + +#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 +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); +} diff --git a/variants/station_g3_esp32/target.h b/variants/station_g3_esp32/target.h new file mode 100644 index 000000000..b67349dcb --- /dev/null +++ b/variants/station_g3_esp32/target.h @@ -0,0 +1,27 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include + +#ifdef DISPLAY_CLASS + #include + #include +#endif + +extern StationG3Board 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(); From e7e97ec438c64b3ebb6ba35bb250cbada9637992 Mon Sep 17 00:00:00 2001 From: taco Date: Sun, 10 May 2026 20:28:45 +1000 Subject: [PATCH 06/17] add option to disable DS3231 probe --- src/helpers/AutoDiscoverRTCClock.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/helpers/AutoDiscoverRTCClock.cpp b/src/helpers/AutoDiscoverRTCClock.cpp index 49a72893d..a310539bc 100644 --- a/src/helpers/AutoDiscoverRTCClock.cpp +++ b/src/helpers/AutoDiscoverRTCClock.cpp @@ -27,9 +27,11 @@ bool AutoDiscoverRTCClock::i2c_probe(TwoWire& wire, uint8_t addr) { } void AutoDiscoverRTCClock::begin(TwoWire& wire) { + #if !defined(DISABLE_DS3231_PROBE) if (i2c_probe(wire, DS3231_ADDRESS)) { ds3231_success = rtc_3231.begin(&wire); } + #endif if (i2c_probe(wire, RV3028_ADDRESS)) { rtc_rv3028.initI2C(wire); From 716ba8ee5e14b37ed53cd7eb4e6721c483e80fdc Mon Sep 17 00:00:00 2001 From: taco Date: Mon, 11 May 2026 11:37:56 +1000 Subject: [PATCH 07/17] pin CustomLFS to version 0.2.2 CustomLFS 0.2.2 adds support for the flash chip in LilyGo T-Echo Card and T-Echo Lite --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index b079cec93..c390c318f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -92,7 +92,7 @@ build_flags = ${arduino_base.build_flags} -D EXTRAFS=1 lib_deps = ${arduino_base.lib_deps} - https://github.com/oltaco/CustomLFS#0.2.1 + https://github.com/oltaco/CustomLFS#0.2.2 ; ----------------- RP2040 --------------------- [rp2040_base] From 6d3b71eed9f96999cdc29303971487640693b47e Mon Sep 17 00:00:00 2001 From: Quency-D Date: Mon, 11 May 2026 15:11:07 +0800 Subject: [PATCH 08/17] add heltec-mesh-node-t1 --- boards/heltec_t1.json | 61 +++++++++++ src/helpers/ui/ST7735Display.cpp | 5 +- src/helpers/ui/buzzer.cpp | 1 + variants/heltec_t1/T1Board.cpp | 135 ++++++++++++++++++++++++ variants/heltec_t1/T1Board.h | 26 +++++ variants/heltec_t1/platformio.ini | 108 +++++++++++++++++++ variants/heltec_t1/target.cpp | 48 +++++++++ variants/heltec_t1/target.h | 30 ++++++ variants/heltec_t1/variant.cpp | 15 +++ variants/heltec_t1/variant.h | 169 ++++++++++++++++++++++++++++++ 10 files changed, 597 insertions(+), 1 deletion(-) create mode 100644 boards/heltec_t1.json create mode 100644 variants/heltec_t1/T1Board.cpp create mode 100644 variants/heltec_t1/T1Board.h create mode 100644 variants/heltec_t1/platformio.ini create mode 100644 variants/heltec_t1/target.cpp create mode 100644 variants/heltec_t1/target.h create mode 100644 variants/heltec_t1/variant.cpp create mode 100644 variants/heltec_t1/variant.h diff --git a/boards/heltec_t1.json b/boards/heltec_t1.json new file mode 100644 index 000000000..53bfc79a4 --- /dev/null +++ b/boards/heltec_t1.json @@ -0,0 +1,61 @@ +{ + "build": { + "arduino": { + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + ["0x239A","0x8029"], + ["0x239A","0x0029"], + ["0x239A","0x002A"], + ["0x239A","0x802A"] + ], + "usb_product": "HT-n5262T1", + "mcu": "nrf52840", + "variant": "heltec_t1", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52.cfg" + }, + "frameworks": [ + "arduino" + ], + "name": "Heltec Mesh Node T1 Board", + "upload": { + "maximum_ram_size": 235520, + "maximum_size": 815104, + "speed": 115200, + "protocol": "nrfutil", + "protocols": [ + "jlink", + "nrfjprog", + "nrfutil", + "stlink" + ], + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true + }, + "url": "https://heltec.org/", + "vendor": "Heltec" +} diff --git a/src/helpers/ui/ST7735Display.cpp b/src/helpers/ui/ST7735Display.cpp index 3eb4521cc..a6087dd81 100644 --- a/src/helpers/ui/ST7735Display.cpp +++ b/src/helpers/ui/ST7735Display.cpp @@ -28,7 +28,10 @@ bool ST7735Display::begin() { #endif digitalWrite(PIN_TFT_RST, HIGH); -#if defined(HELTEC_TRACKER_V2) || defined(HELTEC_T096) +#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 diff --git a/src/helpers/ui/buzzer.cpp b/src/helpers/ui/buzzer.cpp index eb9b695b8..dde59f5d4 100644 --- a/src/helpers/ui/buzzer.cpp +++ b/src/helpers/ui/buzzer.cpp @@ -1,3 +1,4 @@ +#include "Arduino.h" #ifdef PIN_BUZZER #include "buzzer.h" diff --git a/variants/heltec_t1/T1Board.cpp b/variants/heltec_t1/T1Board.cpp new file mode 100644 index 000000000..490f86787 --- /dev/null +++ b/variants/heltec_t1/T1Board.cpp @@ -0,0 +1,135 @@ +#include "T1Board.h" + +#include +#include + +#ifdef NRF52_POWER_MANAGEMENT +const PowerMgtConfig power_config = { + .lpcomp_ain_channel = PWRMGT_LPCOMP_AIN, + .lpcomp_refsel = PWRMGT_LPCOMP_REFSEL, + .voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK +}; + +void T1Board::initiateShutdown(uint8_t reason) { + variant_shutdown(); + + bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE || + reason == SHUTDOWN_REASON_BOOT_PROTECT); + pinMode(PIN_BAT_CTL, OUTPUT); + digitalWrite(PIN_BAT_CTL, enable_lpcomp ? ADC_CTRL_ENABLED : !ADC_CTRL_ENABLED); + + if (enable_lpcomp) { + configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel); + } + + enterSystemOff(reason); +} +#endif + +void T1Board::begin() { + NRF52Board::begin(); + +#ifdef NRF52_POWER_MANAGEMENT + checkBootVoltage(&power_config); +#endif + +#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL) + Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL); +#endif + Wire.begin(); + + pinMode(P_LORA_TX_LED, OUTPUT); + digitalWrite(P_LORA_TX_LED, !LED_STATE_ON); + + pinMode(PIN_GPS_EN, OUTPUT); + digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE); + + pinMode(PIN_SENSOR_EN, OUTPUT); + digitalWrite(PIN_SENSOR_EN, PIN_SENSOR_EN_ACTIVE); + + pinMode(PIN_BUZZER, OUTPUT); + digitalWrite(PIN_BUZZER, LOW); + pinMode(PIN_BUZZER_VOLTAGE_MULTIPLIER_1, OUTPUT); + pinMode(PIN_BUZZER_VOLTAGE_MULTIPLIER_2, OUTPUT); + digitalWrite(PIN_BUZZER_VOLTAGE_MULTIPLIER_1, HIGH); + digitalWrite(PIN_BUZZER_VOLTAGE_MULTIPLIER_2, HIGH); + + periph_power.begin(); + delay(1); +} + +void T1Board::onBeforeTransmit() { + digitalWrite(P_LORA_TX_LED, LED_STATE_ON); +} + +void T1Board::onAfterTransmit() { + digitalWrite(P_LORA_TX_LED, !LED_STATE_ON); +} + +uint16_t T1Board::getBattMilliVolts() { + analogReadResolution(12); + analogReference(VBAT_AR_INTERNAL); + pinMode(PIN_VBAT_READ, INPUT); + pinMode(PIN_BAT_CTL, OUTPUT); + digitalWrite(PIN_BAT_CTL, ADC_CTRL_ENABLED); + + delay(10); + int adcvalue = analogRead(PIN_VBAT_READ); + digitalWrite(PIN_BAT_CTL, !ADC_CTRL_ENABLED); + + return (uint16_t)((float)adcvalue * MV_LSB * ADC_MULTIPLIER); +} + +void T1Board::variant_shutdown() { + nrf_gpio_cfg_default(PIN_TFT_CS); + nrf_gpio_cfg_default(PIN_TFT_DC); + nrf_gpio_cfg_default(PIN_TFT_SDA); + nrf_gpio_cfg_default(PIN_TFT_SCL); + nrf_gpio_cfg_default(PIN_TFT_RST); + nrf_gpio_cfg_default(PIN_TFT_LEDA_CTL); + nrf_gpio_cfg_default(PIN_TFT_VDD_CTL); + + nrf_gpio_cfg_default(PIN_WIRE_SDA); + nrf_gpio_cfg_default(PIN_WIRE_SCL); + + nrf_gpio_cfg_default(LORA_CS); + nrf_gpio_cfg_default(SX126X_DIO1); + nrf_gpio_cfg_default(SX126X_BUSY); + nrf_gpio_cfg_default(SX126X_RESET); + nrf_gpio_cfg_default(PIN_SPI_MISO); + nrf_gpio_cfg_default(PIN_SPI_MOSI); + nrf_gpio_cfg_default(PIN_SPI_SCK); + + nrf_gpio_cfg_default(PIN_SPI1_MOSI); + nrf_gpio_cfg_default(PIN_SPI1_SCK); + + nrf_gpio_cfg_default(PIN_GPS_RESET); + nrf_gpio_cfg_default(PIN_GPS_EN); + nrf_gpio_cfg_default(PIN_GPS_PPS); + nrf_gpio_cfg_default(PIN_GPS_RX); + nrf_gpio_cfg_default(PIN_GPS_TX); + + nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_1); + nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_2); + + pinMode(PIN_BUZZER, OUTPUT); + digitalWrite(PIN_BUZZER, LOW); + + pinMode(PIN_SENSOR_EN, OUTPUT); + digitalWrite(PIN_SENSOR_EN, !PIN_SENSOR_EN_ACTIVE); + + pinMode(PIN_LED1, OUTPUT); + digitalWrite(PIN_LED1, !LED_STATE_ON); + + pinMode(PIN_BAT_CTL, OUTPUT); + digitalWrite(PIN_BAT_CTL, !ADC_CTRL_ENABLED); +} + +void T1Board::powerOff() { + variant_shutdown(); + sd_power_system_off(); +} + +const char* T1Board::getManufacturerName() const { + return "Heltec T1"; +} diff --git a/variants/heltec_t1/T1Board.h b/variants/heltec_t1/T1Board.h new file mode 100644 index 000000000..9b46fd11a --- /dev/null +++ b/variants/heltec_t1/T1Board.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include +#include +#include + +class T1Board : public NRF52BoardDCDC { +protected: +#ifdef NRF52_POWER_MANAGEMENT + void initiateShutdown(uint8_t reason) override; +#endif + void variant_shutdown(); + +public: + RefCountedDigitalPin periph_power; + + T1Board() : periph_power(PIN_TFT_VDD_CTL, PIN_TFT_VDD_CTL_ACTIVE), NRF52Board("T1_OTA") {} + + void begin(); + void onBeforeTransmit() override; + void onAfterTransmit() override; + uint16_t getBattMilliVolts() override; + const char* getManufacturerName() const override; + void powerOff() override; +}; diff --git a/variants/heltec_t1/platformio.ini b/variants/heltec_t1/platformio.ini new file mode 100644 index 000000000..d5c3caf18 --- /dev/null +++ b/variants/heltec_t1/platformio.ini @@ -0,0 +1,108 @@ +[Heltec_t1] +extends = nrf52_base +board = heltec_t1 +board_build.ldscript = boards/nrf52840_s140_v6.ld +build_flags = ${nrf52_base.build_flags} + ${sensor_base.build_flags} + -I lib/nrf52/s140_nrf52_6.1.1_API/include + -I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52 + -I variants/heltec_t1 + -I src/helpers/ui + -D HELTEC_T1 + -D NRF52_POWER_MANAGEMENT + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D DISPLAY_CLASS=ST7735Display +build_src_filter = ${nrf52_base.build_src_filter} + + + + + +<../variants/heltec_t1> + + + + +lib_deps = + ${nrf52_base.lib_deps} + ${sensor_base.lib_deps} + adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0 +debug_tool = jlink +upload_protocol = nrfutil + +[env:Heltec_t1_repeater] +extends = Heltec_t1 +build_src_filter = ${Heltec_t1.build_src_filter} + +<../examples/simple_repeater> + +build_flags = + ${Heltec_t1.build_flags} + -D ADVERT_NAME='"Heltec_t1 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 + +[env:Heltec_t1_room_server] +extends = Heltec_t1 +build_src_filter = ${Heltec_t1.build_src_filter} + +<../examples/simple_room_server> +build_flags = + ${Heltec_t1.build_flags} + -D ADVERT_NAME='"Heltec_t1 Room"' + -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 + +[env:Heltec_t1_companion_radio_ble] +extends = Heltec_t1 +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 712704 +build_flags = + ${Heltec_t1.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D BLE_PIN_CODE=123456 + -D ENV_INCLUDE_GPS=1 +; -D BLE_DEBUG_LOGGING=1 + -D OFFLINE_QUEUE_SIZE=256 + ; -D MESH_PACKET_LOGGING=1 + ; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_t1.build_src_filter} + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Heltec_t1.lib_deps} + densaugeo/base64 @ ~1.4.0 + end2endzone/NonBlockingRTTTL@^1.3.0 + +[env:Heltec_t1_companion_radio_usb] +extends = Heltec_t1 +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +board_upload.maximum_size = 712704 +build_flags = + ${Heltec_t1.build_flags} + -I examples/companion_radio/ui-new + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +build_src_filter = ${Heltec_t1.build_src_filter} + + + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${Heltec_t1.lib_deps} + densaugeo/base64 @ ~1.4.0 + end2endzone/NonBlockingRTTTL@^1.3.0 + +[env:Heltec_t1_kiss_modem] +extends = Heltec_t1 +build_src_filter = ${Heltec_t1.build_src_filter} + +<../examples/kiss_modem/> diff --git a/variants/heltec_t1/target.cpp b/variants/heltec_t1/target.cpp new file mode 100644 index 000000000..af771582d --- /dev/null +++ b/variants/heltec_t1/target.cpp @@ -0,0 +1,48 @@ +#include "target.h" + +#include +#include + +#ifdef ENV_INCLUDE_GPS +#include +#endif + +T1Board board; + +#if defined(P_LORA_SCLK) +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); + +VolatileRTCClock fallback_clock; +AutoDiscoverRTCClock rtc_clock(fallback_clock); + +#if ENV_INCLUDE_GPS +MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock, GPS_RESET, GPS_EN, &board.periph_power); +EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); +#else +EnvironmentSensorManager sensors; +#endif + +#ifdef DISPLAY_CLASS +DISPLAY_CLASS display(&board.periph_power); +MomentaryButton user_btn(PIN_USER_BTN, 1000, true); +#endif + +bool radio_init() { + rtc_clock.begin(Wire); + +#if defined(P_LORA_SCLK) + return radio.std_init(&SPI); +#else + return radio.std_init(); +#endif +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); +} diff --git a/variants/heltec_t1/target.h b/variants/heltec_t1/target.h new file mode 100644 index 000000000..ffd9434fa --- /dev/null +++ b/variants/heltec_t1/target.h @@ -0,0 +1,30 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include +#include + +#ifdef DISPLAY_CLASS +#include +#include +#else +#include "helpers/ui/NullDisplayDriver.h" +#endif + +extern T1Board 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(); diff --git a/variants/heltec_t1/variant.cpp b/variants/heltec_t1/variant.cpp new file mode 100644 index 000000000..2bca56a1f --- /dev/null +++ b/variants/heltec_t1/variant.cpp @@ -0,0 +1,15 @@ +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + 0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 +}; + +void initVariant() +{ + pinMode(PIN_USER_BTN, INPUT); +} diff --git a/variants/heltec_t1/variant.h b/variants/heltec_t1/variant.h new file mode 100644 index 000000000..7ee218161 --- /dev/null +++ b/variants/heltec_t1/variant.h @@ -0,0 +1,169 @@ +/* + * Heltec Mesh Node T1 nRF52840 variant. + */ + +#pragma once + +#include "WVariant.h" + +#define USE_LFXO +#define VARIANT_MCK (64000000ul) + +//////////////////////////////////////////////////////////////////////////////// +// Number of pins + +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (1) +#define NUM_ANALOG_OUTPUTS (0) + +//////////////////////////////////////////////////////////////////////////////// +// Display + +#define ST7735_CS (0 + 12) +#define ST7735_RS (0 + 22) +#define ST7735_SDA (0 + 24) +#define ST7735_SCK (32 + 0) +#define ST7735_RESET (0 + 20) +#define ST7735_MISO (-1) +#define ST7735_BUSY (-1) +#define ST7735_BL (0 + 15) +#define VTFT_CTRL (0 + 13) + +#define PIN_TFT_CS ST7735_CS +#define PIN_TFT_DC ST7735_RS +#define PIN_TFT_SDA ST7735_SDA +#define PIN_TFT_SCL ST7735_SCK +#define PIN_TFT_RST ST7735_RESET +#define PIN_TFT_LEDA_CTL ST7735_BL +#define PIN_TFT_LEDA_CTL_ACTIVE LOW +#define PIN_TFT_VDD_CTL VTFT_CTRL +#define PIN_TFT_VDD_CTL_ACTIVE LOW +#define DISPLAY_ROTATION 3 + +//////////////////////////////////////////////////////////////////////////////// +// Builtin LEDs + +#define PIN_LED1 (0 + 16) +#define LED_BUILTIN PIN_LED1 +#define PIN_LED LED_BUILTIN +#define LED_RED (-1) +#define LED_BLUE (-1) +#define LED_GREEN (-1) +#define LED_PIN LED_BUILTIN +#define LED_STATE_ON LOW + +//////////////////////////////////////////////////////////////////////////////// +// Builtin buttons + +#define PIN_BUTTON1 (32 + 10) +#define PIN_BUTTON2 (0 + 14) +#define BUTTON_PIN PIN_BUTTON1 +#define BUTTON_PIN2 PIN_BUTTON2 +#define PIN_USER_BTN BUTTON_PIN + +//////////////////////////////////////////////////////////////////////////////// +// UART + +// No longer populated on PCB. +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +//////////////////////////////////////////////////////////////////////////////// +// I2C + +#define WIRE_INTERFACES_COUNT (1) + +#define PIN_WIRE_SDA (32 + 3) +#define PIN_WIRE_SCL (0 + 10) + +#define PIN_SENSOR_EN (32 + 6) +#define PIN_SENSOR_EN_ACTIVE LOW + +//////////////////////////////////////////////////////////////////////////////// +// LoRa + +#define USE_SX1262 +#define SX126X_CS (32 + 11) +#define LORA_CS SX126X_CS +#define SX126X_DIO1 (0 + 31) +#define SX126X_BUSY (0 + 29) +#define SX126X_RESET (0 + 2) +#define SX126X_DIO2_AS_RF_SWITCH true +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#define SX126X_CURRENT_LIMIT 140 +#define SX126X_RX_BOOSTED_GAIN 1 + +#define P_LORA_DIO_1 SX126X_DIO1 +#define P_LORA_NSS LORA_CS +#define P_LORA_RESET SX126X_RESET +#define P_LORA_BUSY SX126X_BUSY +#define P_LORA_TX_LED PIN_LED1 + +//////////////////////////////////////////////////////////////////////////////// +// SPI + +#define SPI_INTERFACES_COUNT (2) + +#define PIN_SPI_MISO (0 + 3) +#define PIN_SPI_MOSI (32 + 14) +#define PIN_SPI_SCK (32 + 13) +#define PIN_SPI_NSS LORA_CS + +#define PIN_SPI1_MISO ST7735_MISO +#define PIN_SPI1_MOSI ST7735_SDA +#define PIN_SPI1_SCK ST7735_SCK + +#define P_LORA_SCLK PIN_SPI_SCK +#define P_LORA_MISO PIN_SPI_MISO +#define P_LORA_MOSI PIN_SPI_MOSI + +//////////////////////////////////////////////////////////////////////////////// +// GPS + +#define GPS_UC6580 +#define GPS_BAUD_RATE 115200 +#define PIN_GPS_RESET (0 + 26) +#define GPS_RESET PIN_GPS_RESET +#define GPS_RESET_MODE LOW +#define PIN_GPS_RESET_ACTIVE LOW +#define PIN_GPS_EN (0 + 4) +#define GPS_EN PIN_GPS_EN +#define GPS_EN_ACTIVE LOW +#define PIN_GPS_EN_ACTIVE LOW +#define PIN_GPS_PPS (32 + 9) +#define GPS_TX_PIN (0 + 8) +#define GPS_RX_PIN (0 + 7) +#define PIN_GPS_TX GPS_TX_PIN +#define PIN_GPS_RX GPS_RX_PIN + +#define PIN_SERIAL1_RX GPS_RX_PIN +#define PIN_SERIAL1_TX GPS_TX_PIN + +//////////////////////////////////////////////////////////////////////////////// +// Buzzer + +#define PIN_BUZZER (0 + 9) +#define PIN_BUZZER_VOLTAGE_MULTIPLIER_1 (32 + 2) +#define PIN_BUZZER_VOLTAGE_MULTIPLIER_2 (32 + 5) + +//////////////////////////////////////////////////////////////////////////////// +// Battery + +#define ADC_CTRL (0 + 11) +#define PIN_BAT_CTL ADC_CTRL +#define ADC_CTRL_ENABLED HIGH +#define BATTERY_PIN (0 + 5) +#define PIN_VBAT_READ BATTERY_PIN +#define ADC_RESOLUTION (14) + +#define AREF_VOLTAGE (3.0) +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER (4.916F) +#define MV_LSB (3000.0F / 4096.0F) + +#define PWRMGT_VOLTAGE_BOOTLOCK 3100 +#define PWRMGT_LPCOMP_AIN 3 +#define PWRMGT_LPCOMP_REFSEL 1 + +#define HAS_RTC 0 From 242c45f4a330a3be63baa02ac60b9f75ae0c5c9d Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 11 May 2026 22:04:11 +1200 Subject: [PATCH 09/17] initial support for lilygo t impulse plus --- boards/lilygo_t_impulse_plus_nrf52840.json | 64 +++++ .../TImpulsePlusBoard.cpp | 39 +++ .../lilygo_t_impulse_plus/TImpulsePlusBoard.h | 53 +++++ variants/lilygo_t_impulse_plus/platformio.ini | 73 ++++++ variants/lilygo_t_impulse_plus/target.cpp | 37 +++ variants/lilygo_t_impulse_plus/target.h | 27 +++ variants/lilygo_t_impulse_plus/variant.cpp | 43 ++++ variants/lilygo_t_impulse_plus/variant.h | 224 ++++++++++++++++++ 8 files changed, 560 insertions(+) create mode 100644 boards/lilygo_t_impulse_plus_nrf52840.json create mode 100644 variants/lilygo_t_impulse_plus/TImpulsePlusBoard.cpp create mode 100644 variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h create mode 100644 variants/lilygo_t_impulse_plus/platformio.ini create mode 100644 variants/lilygo_t_impulse_plus/target.cpp create mode 100644 variants/lilygo_t_impulse_plus/target.h create mode 100644 variants/lilygo_t_impulse_plus/variant.cpp create mode 100644 variants/lilygo_t_impulse_plus/variant.h diff --git a/boards/lilygo_t_impulse_plus_nrf52840.json b/boards/lilygo_t_impulse_plus_nrf52840.json new file mode 100644 index 000000000..bbe031cde --- /dev/null +++ b/boards/lilygo_t_impulse_plus_nrf52840.json @@ -0,0 +1,64 @@ +{ + "build": { + "arduino":{ + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_T_IMPULSE_PLUS -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [ + [ + "0x239A", + "0x8029" + ] + ], + "usb_product": "T-Impulse-Plus-nRF52840", + "mcu": "nrf52840", + "variant": "t_impulse_plus_nrf52840", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": [ + "bluetooth" + ], + "debug": { + "jlink_device": "nRF52840_xxAA", + "onboard_tools": [ + "jlink" + ], + "svd_path": "nrf52840.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "Lilygo T-Impulse-Plus-nRF52840", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "require_upload_port": true, + "speed": 115200, + "protocol": "nrfutil", + "protocols": [ + "jlink", + "nrfjprog", + "stlink", + "cmsis-dap", + "blackmagic" + ], + "use_1200bps_touch": true, + "wait_for_upload_port": true + }, + "url": "https://www.lilygo.cc/", + "vendor": "Lilygo" +} diff --git a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.cpp b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.cpp new file mode 100644 index 000000000..df5b7e284 --- /dev/null +++ b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include "TImpulsePlusBoard.h" + +void TImpulsePlusBoard::begin() { + NRF52BoardDCDC::begin(); + + // turn on 3.3v + pinMode(RT9080_EN, OUTPUT); + digitalWrite(RT9080_EN, HIGH); + delay(100); + + // init gps pins + pinMode(GPS_EN, OUTPUT); + digitalWrite(GPS_EN, HIGH); // gps off by default + + // configure battery measurement + pinMode(BATTERY_ADC_DATA, INPUT); + pinMode(BATTERY_MEASUREMENT_CONTROL, OUTPUT); + digitalWrite(BATTERY_MEASUREMENT_CONTROL, LOW); // turn off battery voltage measurement + + // set the analog reference to 3.0V (default = 3.6V) + analogReference(AR_INTERNAL_3_0); + + // set the resolution to 12-bit (0..4095) + analogReadResolution(12); // Can be 8, 10, 12 or 14 + + // configure user button + pinMode(TTP223_KEY, INPUT_PULLDOWN); + + #if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL) + Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL); + #endif + + Wire.begin(); + + delay(10); // give sx1262 some time to power up +} diff --git a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h new file mode 100644 index 000000000..4ed7292e7 --- /dev/null +++ b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include +#include + +class TImpulsePlusBoard : public NRF52BoardDCDC { +protected: + uint8_t btn_prev_state; + +public: + TImpulsePlusBoard() : NRF52Board("T-Impulse-Plus OTA") {} + void begin(); + +#if defined(P_LORA_TX_LED) + void onBeforeTransmit() override { + digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on + } + void onAfterTransmit() override { + digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off + } +#endif + + uint16_t getBattMilliVolts() override { + // enable battery voltage measurement + digitalWrite(BATTERY_MEASUREMENT_CONTROL, HIGH); + delay(100); + + analogReadResolution(12); + analogReference(AR_INTERNAL); + delay(10); + + // read battery voltage + int adcvalue = 0; + analogReadResolution(12); + analogReference(AR_INTERNAL); + delay(10); + adcvalue = analogRead(BATTERY_ADC_DATA); + + // disable battery voltage measurement + digitalWrite(BATTERY_MEASUREMENT_CONTROL, LOW); + + return ((adcvalue * ((3000.0 / 4096.0)))) * 2.0; + } + + const char* getManufacturerName() const override { + return "LilyGo T-Impulse-Plus"; + } + + void powerOff() override { + sd_power_system_off(); + } +}; diff --git a/variants/lilygo_t_impulse_plus/platformio.ini b/variants/lilygo_t_impulse_plus/platformio.ini new file mode 100644 index 000000000..0ed5b9a42 --- /dev/null +++ b/variants/lilygo_t_impulse_plus/platformio.ini @@ -0,0 +1,73 @@ +[LilyGo_T_Impulse_Plus] +extends = nrf52_base +board = lilygo_t_impulse_plus_nrf52840 +board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +build_flags = ${nrf52_base.build_flags} + ${sensor_base.build_flags} + -I variants/lilygo_t_impulse_plus + -D USE_SX1262 + -D RADIO_CLASS=CustomSX1262 + -D WRAPPER_CLASS=CustomSX1262Wrapper + -D LORA_TX_POWER=22 + -D SX126X_CURRENT_LIMIT=140 + -D SX126X_RX_BOOSTED_GAIN=1 + -D PIN_USER_BTN=-1 + ; -D PIN_USER_BTN=TTP223_KEY ; leave button disabled until screen implemented + ; -D USER_BTN_PRESSED=HIGH + -D PIN_WIRE_SDA=SCREEN_SDA + -D PIN_WIRE_SCL=SCREEN_SCL + -D ENV_PIN_SDA=IIC_SDA_2 ; firmware hangs without this + -D ENV_PIN_SCL=IIC_SCL_2 ; firmware hangs without this +build_src_filter = ${nrf52_base.build_src_filter} + + + +<../variants/lilygo_t_impulse_plus> + + + + +lib_deps= ${nrf52_base.lib_deps} + ${sensor_base.lib_deps} + adafruit/Adafruit SSD1306 @ ^2.5.13 + adafruit/Adafruit GFX Library @ ^1.12.1 + +[env:LilyGo_T_Impulse_Plus_repeater] +extends = LilyGo_T_Impulse_Plus +build_src_filter = ${LilyGo_T_Impulse_Plus.build_src_filter} + +<../examples/simple_repeater> +build_flags = + ${LilyGo_T_Impulse_Plus.build_flags} + -D ADVERT_NAME='"T-Impulse-Plus Repeater"' + -D ADMIN_PASSWORD='"password"' + -D MAX_NEIGHBOURS=50 +; -D MESH_PACKET_LOGGING=1 +; -D MESH_DEBUG=1 +lib_deps = ${LilyGo_T_Impulse_Plus.lib_deps} + adafruit/RTClib @ ^2.1.3 + +[env:LilyGo_T_Impulse_Plus_companion_radio_ble] +extends = LilyGo_T_Impulse_Plus +; board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld +; board_upload.maximum_size = 712704 +build_flags = + ${LilyGo_T_Impulse_Plus.build_flags} + -I src/helpers/ui + -I examples/companion_radio/ui-new + -D DISPLAY_CLASS=SSD1306Display + -D MAX_CONTACTS=350 + -D MAX_GROUP_CHANNELS=40 + -D QSPIFLASH=1 + -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 = ${LilyGo_T_Impulse_Plus.build_src_filter} + + + +<../examples/companion_radio/*.cpp> + +<../examples/companion_radio/ui-new/*.cpp> +lib_deps = + ${LilyGo_T_Impulse_Plus.lib_deps} + densaugeo/base64 @ ~1.4.0 + +[env:LilyGo_T_Impulse_Plus_kiss_modem] +extends = LilyGo_T_Impulse_Plus +build_src_filter = ${LilyGo_T_Impulse_Plus.build_src_filter} + +<../examples/kiss_modem/> diff --git a/variants/lilygo_t_impulse_plus/target.cpp b/variants/lilygo_t_impulse_plus/target.cpp new file mode 100644 index 000000000..87b3dbfed --- /dev/null +++ b/variants/lilygo_t_impulse_plus/target.cpp @@ -0,0 +1,37 @@ +#include +#include "target.h" +#include +#include + +TImpulsePlusBoard 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); + +VolatileRTCClock 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; + MomentaryButton user_btn(PIN_USER_BTN, 1000, true); +#endif + +bool radio_init() { + rtc_clock.begin(Wire); + + return radio.std_init(&SPI); +} + +mesh::LocalIdentity radio_new_identity() { + RadioNoiseListener rng(radio); + return mesh::LocalIdentity(&rng); // create new random identity +} + diff --git a/variants/lilygo_t_impulse_plus/target.h b/variants/lilygo_t_impulse_plus/target.h new file mode 100644 index 000000000..ff168fbed --- /dev/null +++ b/variants/lilygo_t_impulse_plus/target.h @@ -0,0 +1,27 @@ +#pragma once + +#define RADIOLIB_STATIC_ONLY 1 +#include +#include +#include +#include +#include +#include +#include +#ifdef DISPLAY_CLASS + #include + #include +#endif + +extern TImpulsePlusBoard 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(); + diff --git a/variants/lilygo_t_impulse_plus/variant.cpp b/variants/lilygo_t_impulse_plus/variant.cpp new file mode 100644 index 000000000..a77a7e238 --- /dev/null +++ b/variants/lilygo_t_impulse_plus/variant.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = +{ + // P0 + 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , + 8 , 9 , 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47 +}; + + +void initVariant() +{ + +} diff --git a/variants/lilygo_t_impulse_plus/variant.h b/variants/lilygo_t_impulse_plus/variant.h new file mode 100644 index 000000000..877136e93 --- /dev/null +++ b/variants/lilygo_t_impulse_plus/variant.h @@ -0,0 +1,224 @@ + /* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_T_IMPULSE_PLUS_NRF52840_ +#define _VARIANT_T_IMPULSE_PLUS_NRF52840_ + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +#define _PINNUM(port, pin) ((port) * 32 + (pin)) + +// IIC +#define IIC_SDA_1 _PINNUM(1, 8) +#define IIC_SCL_1 _PINNUM(0, 11) +#define IIC_SDA_2 _PINNUM(0, 20) +#define IIC_SCL_2 _PINNUM(0, 15) + +// TTP223 +#define TTP223_KEY _PINNUM(1, 4) + +// SSD1315 +#define SCREEN_WIDTH 128 +#define SCREEN_HEIGHT 64 +#define SCREEN_ADDRESS 0x3C +#define SCREEN_RST -1 +#define SCREEN_SDA IIC_SDA_2 +#define SCREEN_SCL IIC_SCL_2 + +// Lora S62F(SX1262) +#define SX1262_CS _PINNUM(1, 14) +#define SX1262_RST _PINNUM(0, 2) +#define SX1262_SCLK _PINNUM(0, 3) +#define SX1262_MOSI _PINNUM(0, 28) +#define SX1262_MISO _PINNUM(0, 30) +#define SX1262_BUSY _PINNUM(0, 31) +#define SX1262_INT _PINNUM(0, 29) +#define SX1262_DIO1 _PINNUM(0, 29) +#define SX1262_DIO2 _PINNUM(1, 15) +#define SX1262_RF_VC1 _PINNUM(1, 13) +#define SX1262_RF_VC2 _PINNUM(1, 7) + +#define SX126X_TXEN SX1262_RF_VC1 +#define SX126X_RXEN SX1262_RF_VC2 + +#define P_LORA_NSS SX1262_CS +#define P_LORA_DIO_1 SX1262_DIO1 +#define P_LORA_RESET SX1262_RST +#define P_LORA_BUSY SX1262_BUSY +#define P_LORA_DIO_0 RADIOLIB_NC +#define P_LORA_DIO_2 SX1262_DIO2 +#define P_LORA_SCLK SX1262_SCLK +#define P_LORA_MISO SX1262_MISO +#define P_LORA_MOSI SX1262_MOSI + +// RT9080 +#define RT9080_EN _PINNUM(0, 14) + +// GPS +#define GPS_EN _PINNUM(1, 10) +#define GPS_UART_RX _PINNUM(1, 11) +#define GPS_UART_TX _PINNUM(1, 12) +#define PIN_GPS_RX GPS_UART_TX +#define PIN_GPS_TX GPS_UART_RX +#define PIN_GPS_EN GPS_EN +#define GPS_BAUD_RATE 38400 +#define PIN_GPS_EN_ACTIVE LOW + +// Battery +#define BATTERY_MEASUREMENT_CONTROL _PINNUM(0, 25) +#define BATTERY_ADC_DATA _PINNUM(0, 5) + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (_PINNUM(0, 17)) +// #define PIN_LED2 (_PINNUM(1, 5)) +// #define PIN_LED3 (15) +// #define PIN_LED4 (16) + +#define LED_BUILTIN PIN_LED1 +// #define LED_CONN PIN_LED2 + +// #define LED_RED PIN_LED1 +#define LED_BLUE PIN_LED1 + +#define LED_STATE_ON 0 // State when LED is litted + +/* + * Buttons + */ +#define PIN_BUTTON1 _PINNUM(0, 24) +// #define PIN_BUTTON2 12 +// #define PIN_BUTTON3 24 +// #define PIN_BUTTON4 25 + +/* + * Analog pins + */ +#define PIN_A0 (3) +#define PIN_A1 (4) +#define PIN_A2 (28) +#define PIN_A3 (29) +#define PIN_A4 (30) +#define PIN_A5 (31) +#define PIN_A6 (0xff) +#define PIN_A7 (0xff) + +static const uint8_t A0 = PIN_A0 ; +static const uint8_t A1 = PIN_A1 ; +static const uint8_t A2 = PIN_A2 ; +static const uint8_t A3 = PIN_A3 ; +static const uint8_t A4 = PIN_A4 ; +static const uint8_t A5 = PIN_A5 ; +static const uint8_t A6 = PIN_A6 ; +static const uint8_t A7 = PIN_A7 ; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +#define PIN_NFC1 (9) +#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ + +// Arduino Header D0, D1 +#define PIN_SERIAL1_RX (33) // P1.01 +#define PIN_SERIAL1_TX (34) // P1.02 + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (8) +#define PIN_SERIAL2_TX (6) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (46) +#define PIN_SPI_MOSI (45) +#define PIN_SPI_SCK (47) + +static const uint8_t SS = 44 ; +static const uint8_t MOSI = PIN_SPI_MOSI ; +static const uint8_t MISO = PIN_SPI_MISO ; +static const uint8_t SCK = PIN_SPI_SCK ; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 2 + +#define PIN_WIRE_SDA (26) +#define PIN_WIRE_SCL (27) + +#define PIN_WIRE1_SDA (26) +#define PIN_WIRE1_SCL (27) + +// ZD25WQ32CEIGR SPI +#define ZD25WQ32C_CS _PINNUM(0, 12) +#define ZD25WQ32C_SCLK _PINNUM(0, 4) +#define ZD25WQ32C_MOSI _PINNUM(0, 6) +#define ZD25WQ32C_MISO _PINNUM(1, 9) +#define ZD25WQ32C_IO0 _PINNUM(0, 6) +#define ZD25WQ32C_IO1 _PINNUM(1, 9) +#define ZD25WQ32C_IO2 _PINNUM(0, 8) +#define ZD25WQ32C_IO3 _PINNUM(0, 26) + +#define PIN_QSPI_SCK ZD25WQ32C_SCLK +#define PIN_QSPI_CS ZD25WQ32C_CS +#define PIN_QSPI_IO0 ZD25WQ32C_IO0 +#define PIN_QSPI_IO1 ZD25WQ32C_IO1 +#define PIN_QSPI_IO2 ZD25WQ32C_IO2 +#define PIN_QSPI_IO3 ZD25WQ32C_IO3 + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES MX25R6435F +#define EXTERNAL_FLASH_USE_QSPI + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file From a49ee6ebe9b8215bb4aeb7ddc5c39a2c5d94127d Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 11 May 2026 22:17:53 +1200 Subject: [PATCH 10/17] fix battery voltage reading --- variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h index 4ed7292e7..3e799bd9e 100644 --- a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h +++ b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h @@ -33,7 +33,7 @@ public: // read battery voltage int adcvalue = 0; analogReadResolution(12); - analogReference(AR_INTERNAL); + analogReference(AR_INTERNAL_3_0); delay(10); adcvalue = analogRead(BATTERY_ADC_DATA); From 2fdbfbdbf6eba23122bbd274a7194bf68c5cd5f8 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 12 May 2026 01:06:22 +1200 Subject: [PATCH 11/17] turn off 3.3v rail when powering off --- variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h index 3e799bd9e..ea1782cf7 100644 --- a/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h +++ b/variants/lilygo_t_impulse_plus/TImpulsePlusBoard.h @@ -48,6 +48,12 @@ public: } void powerOff() override { + + // turn off 3.3v + digitalWrite(RT9080_EN, LOW); + + // power off system sd_power_system_off(); + } }; From b0b87fd709b286d72ba3886c38265bbd271f88ce Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 12 May 2026 10:36:19 +1200 Subject: [PATCH 12/17] fix gps pins for lilygo t impulse plus --- variants/lilygo_t_impulse_plus/variant.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/lilygo_t_impulse_plus/variant.h b/variants/lilygo_t_impulse_plus/variant.h index 877136e93..403e91957 100644 --- a/variants/lilygo_t_impulse_plus/variant.h +++ b/variants/lilygo_t_impulse_plus/variant.h @@ -88,8 +88,8 @@ extern "C" #define GPS_EN _PINNUM(1, 10) #define GPS_UART_RX _PINNUM(1, 11) #define GPS_UART_TX _PINNUM(1, 12) -#define PIN_GPS_RX GPS_UART_TX -#define PIN_GPS_TX GPS_UART_RX +#define PIN_GPS_RX GPS_UART_RX +#define PIN_GPS_TX GPS_UART_TX #define PIN_GPS_EN GPS_EN #define GPS_BAUD_RATE 38400 #define PIN_GPS_EN_ACTIVE LOW From 68363d9e4d88f85fe9313418b90ee8eeb294fd58 Mon Sep 17 00:00:00 2001 From: Rastislav Vysoky Date: Tue, 12 May 2026 15:56:28 +0200 Subject: [PATCH 13/17] revert: "feat: Enable GPS on RAK 1W kit" (#2401) reverted changes to RAK_BOARD and PIN_GPS_EN. setting `RAK_BOARD` would cause radio to stop working and end with RadioLib error -707 --- variants/rak3401/platformio.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/variants/rak3401/platformio.ini b/variants/rak3401/platformio.ini index 7de3f176b..20a8a548b 100644 --- a/variants/rak3401/platformio.ini +++ b/variants/rak3401/platformio.ini @@ -6,7 +6,6 @@ build_flags = ${nrf52_base.build_flags} ${sensor_base.build_flags} -I variants/rak3401 -D RAK_3401 - -D RAK_BOARD -D NRF52_POWER_MANAGEMENT -D RADIO_CLASS=CustomSX1262 -D WRAPPER_CLASS=CustomSX1262Wrapper @@ -65,7 +64,6 @@ build_flags = ${rak3401.build_flags} -I examples/companion_radio/ui-new -D PIN_USER_BTN_ANA=31 - -D PIN_GPS_EN=-1 -D DISPLAY_CLASS=SSD1306Display -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 @@ -86,7 +84,6 @@ build_flags = ${rak3401.build_flags} -I examples/companion_radio/ui-new -D PIN_USER_BTN_ANA=31 - -D PIN_GPS_EN=-1 -D DISPLAY_CLASS=SSD1306Display -D MAX_CONTACTS=350 -D MAX_GROUP_CHANNELS=40 From c588540b1b768f3e29aa3e9114938d1beeea145b Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Wed, 13 May 2026 13:28:56 +1000 Subject: [PATCH 14/17] * new CMD_SEND_RAW_PACKET --- examples/companion_radio/MyMesh.cpp | 14 ++++++++++++++ src/Dispatcher.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index c67bb68c9..dd6c16789 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -61,6 +61,7 @@ #define CMD_SEND_CHANNEL_DATA 62 #define CMD_SET_DEFAULT_FLOOD_SCOPE 63 #define CMD_GET_DEFAULT_FLOOD_SCOPE 64 +#define CMD_SEND_RAW_PACKET 65 // Stats sub-types for CMD_GET_STATS #define STATS_TYPE_CORE 0 @@ -1963,6 +1964,19 @@ void MyMesh::handleCmdFrame(size_t len) { memcpy(&out_frame[i], &r->upper_freq, 4); i += 4; } _serial->writeFrame(out_frame, i); + } else if (cmd_frame[0] == CMD_SEND_RAW_PACKET && len >= 4) { + auto pkt = obtainNewPacket(); + if (pkt) { + uint8_t priority = cmd_frame[1]; + if (tryParsePacket(pkt, &cmd_frame[2], len - 2)) { + sendPacket(pkt, priority, 0); + writeOKFrame(); + } else { + writeErrFrame(ERR_CODE_ILLEGAL_ARG); + } + } else { + writeErrFrame(ERR_CODE_TABLE_FULL); + } } else { writeErrFrame(ERR_CODE_UNSUPPORTED_CMD); MESH_DEBUG_PRINTLN("ERROR: unknown command: %02X", cmd_frame[0]); diff --git a/src/Dispatcher.h b/src/Dispatcher.h index 2a99d0682..dd032f130 100644 --- a/src/Dispatcher.h +++ b/src/Dispatcher.h @@ -193,8 +193,9 @@ public: bool millisHasNowPassed(unsigned long timestamp) const; unsigned long futureMillis(int millis_from_now) const; -private: bool tryParsePacket(Packet* pkt, const uint8_t* raw, int len); + +private: void checkRecv(); void checkSend(); }; From 973321d9b198c6216a2bb970150ebf71e878c140 Mon Sep 17 00:00:00 2001 From: Willem Oldemans Date: Fri, 15 May 2026 10:53:59 +0200 Subject: [PATCH 15/17] Disable BLE_PIN_CODE for E290 companion USB environment Remove the hardcoded BLE_PIN_CODE build flag from the Heltec_E290_companion_ble environment. The presence of BLE_PIN_CODE prevents the unit from operating as a USB companion. Commenting it out allows dynamic PIN generation and enables USB companion functionality. --- variants/heltec_e290/platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/heltec_e290/platformio.ini b/variants/heltec_e290/platformio.ini index 6e0eaffc4..a6f300327 100644 --- a/variants/heltec_e290/platformio.ini +++ b/variants/heltec_e290/platformio.ini @@ -66,7 +66,7 @@ build_flags = -D MAX_GROUP_CHANNELS=40 -D DISPLAY_CLASS=E290Display -D AUTO_OFF_MILLIS=0 - -D BLE_PIN_CODE=123456 ; dynamic, random PIN + #-D BLE_PIN_CODE=123456 ; dynamic, random PIN -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 build_src_filter = ${Heltec_E290_base.build_src_filter} From e1616ff29d177d7c41fa162cc85cdcf45330475a Mon Sep 17 00:00:00 2001 From: Willem Oldemans Date: Fri, 15 May 2026 13:09:59 +0200 Subject: [PATCH 16/17] Remove static BLE_PIN_CODE definition from Heltec E290_usb configuration --- variants/heltec_e290/platformio.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/variants/heltec_e290/platformio.ini b/variants/heltec_e290/platformio.ini index a6f300327..c7cd5f21e 100644 --- a/variants/heltec_e290/platformio.ini +++ b/variants/heltec_e290/platformio.ini @@ -66,7 +66,6 @@ build_flags = -D MAX_GROUP_CHANNELS=40 -D DISPLAY_CLASS=E290Display -D AUTO_OFF_MILLIS=0 - #-D BLE_PIN_CODE=123456 ; dynamic, random PIN -D BLE_DEBUG_LOGGING=1 -D OFFLINE_QUEUE_SIZE=256 build_src_filter = ${Heltec_E290_base.build_src_filter} From 79caba5bab92250e5664883c23ba2b2562f2ae7b Mon Sep 17 00:00:00 2001 From: ViezeVingertjes Date: Sat, 16 May 2026 11:32:21 +0200 Subject: [PATCH 17/17] Document HW_ERR_TX_BUSY in KISS modem protocol --- docs/kiss_modem_protocol.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/kiss_modem_protocol.md b/docs/kiss_modem_protocol.md index 8fbb57e45..e070ec4f1 100644 --- a/docs/kiss_modem_protocol.md +++ b/docs/kiss_modem_protocol.md @@ -156,6 +156,7 @@ Response codes use the high-bit convention: `response = command | 0x80`. Generic | MacFailed | `0x04` | MAC verification failed | | UnknownCmd | `0x05` | Unknown sub-command | | EncryptFailed | `0x06` | Encryption failed | +| TxBusy | `0x07` | Transmit busy | ### Unsolicited Events