diff --git a/examples/companion_radio/main.cpp b/examples/companion_radio/main.cpp index d93276e4..3c561aba 100644 --- a/examples/companion_radio/main.cpp +++ b/examples/companion_radio/main.cpp @@ -68,22 +68,14 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) +#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) #include #include static ESP32Board board; -#elif defined(LILYGO_T3) - #include +#elif defined(LILYGO_TLORA) + #include #include - static ESP32Board board; -#elif defined(LILYGO_T3S3) - #include - #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 - #include - #else - #include - #endif - static LilyGoT3S3Board board; + static LilyGoTLoraBoard board; #elif defined(RAK_4631) #include #include @@ -1120,7 +1112,7 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); -#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +#elif defined(LILYGO_TLORA) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) @@ -1141,24 +1133,19 @@ void setup() { Serial.begin(115200); board.begin(); +#ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif + #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif - -#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); -#else // SX126X module - #ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; - #else - float tcxo = 1.6f; - #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); -#endif - if (status != RADIOLIB_ERR_NONE) { Serial.print("ERROR: radio init failed: "); Serial.println(status); @@ -1167,14 +1154,12 @@ void setup() { radio.setCRC(0); -#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings - #ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); - #endif +#ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); +#endif - #ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); - #endif +#ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 1d197749..3eb16d26 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -72,22 +72,14 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) +#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) #include #include static ESP32Board board; -#elif defined(LILYGO_T3) - #include + #elif defined(LILYGO_TLORA) + #include #include - static ESP32Board board; -#elif defined(LILYGO_T3S3) - #include - #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 - #include - #else - #include - #endif - static LilyGoT3S3Board board; + static LilyGoTLoraBoard board; #elif defined(RAK_4631) #include #include @@ -616,7 +608,7 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); -#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +#elif defined(LILYGO_TLORA) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) @@ -653,24 +645,18 @@ void setup() { #endif rtc_clock.begin(Wire); +#ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif - -#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); -#else // SX126X module - #ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; - #else - float tcxo = 1.6f; - #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); -#endif - if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); @@ -680,14 +666,12 @@ void setup() { radio.setCRC(0); -#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings - #ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); - #endif +#ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); +#endif - #ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); - #endif +#ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_room_server/main.cpp b/examples/simple_room_server/main.cpp index 93870af9..84f1f552 100644 --- a/examples/simple_room_server/main.cpp +++ b/examples/simple_room_server/main.cpp @@ -76,22 +76,14 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) +#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) #include #include static ESP32Board board; -#elif defined(LILYGO_T3) - #include +#elif defined(LILYGO_TLORA) + #include #include - static ESP32Board board; -#elif defined(LILYGO_T3S3) - #include - #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 - #include - #else - #include - #endif - static LilyGoT3S3Board board; + static LilyGoTLoraBoard board; #elif defined(RAK_4631) #include #include @@ -671,7 +663,7 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); -#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +#elif defined(LILYGO_TLORA) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) @@ -708,24 +700,19 @@ void setup() { #endif rtc_clock.begin(Wire); +#ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif + #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif - -#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); -#else // SX126X module - #ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; - #else - float tcxo = 1.6f; - #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); -#endif - if (status != RADIOLIB_ERR_NONE) { delay(5000); Serial.print("ERROR: radio init failed: "); @@ -735,14 +722,12 @@ void setup() { radio.setCRC(0); -#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings - #ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); - #endif +#ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); +#endif - #ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); - #endif +#ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/examples/simple_secure_chat/main.cpp b/examples/simple_secure_chat/main.cpp index fb7fd986..3e280047 100644 --- a/examples/simple_secure_chat/main.cpp +++ b/examples/simple_secure_chat/main.cpp @@ -62,22 +62,14 @@ #include #include static XiaoC3Board board; -#elif defined(SEEED_XIAO_S3) +#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3) #include #include static ESP32Board board; -#elif defined(LILYGO_T3) - #include +#elif defined(LILYGO_TLORA) + #include #include - static ESP32Board board; -#elif defined(LILYGO_T3S3) - #include - #if defined(P_LORA_DIO_0) // If P_LORA_DIO_0 is defined, we're using SX1276 - #include - #else - #include - #endif - static LilyGoT3S3Board board; + static LilyGoTLoraBoard board; #elif defined(RAK_4631) #include #include @@ -553,7 +545,7 @@ public: #if defined(NRF52_PLATFORM) RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI); -#elif defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 +#elif defined(LILYGO_TLORA) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi); #elif defined(P_LORA_SCLK) @@ -574,24 +566,19 @@ void setup() { Serial.begin(115200); board.begin(); +#ifdef SX126X_DIO3_TCXO_VOLTAGE + float tcxo = SX126X_DIO3_TCXO_VOLTAGE; +#else + float tcxo = 1.6f; +#endif + #if defined(NRF52_PLATFORM) SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI); SPI.begin(); #elif defined(P_LORA_SCLK) spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI); #endif - -#if defined(LILYGO_T3) || defined(HELTEC_LORA_V2) // ESP32 with SX1276 - int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX127X_SYNC_WORD, LORA_TX_POWER); -#else // SX126X module - #ifdef SX126X_DIO3_TCXO_VOLTAGE - float tcxo = SX126X_DIO3_TCXO_VOLTAGE; - #else - float tcxo = 1.6f; - #endif int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo); -#endif - if (status != RADIOLIB_ERR_NONE) { Serial.print("ERROR: radio init failed: "); Serial.println(status); @@ -600,14 +587,12 @@ void setup() { radio.setCRC(0); -#if !defined(LILYGO_T3) && !defined(HELTEC_LORA_V2) // SX126X specific settings - #ifdef SX126X_CURRENT_LIMIT - radio.setCurrentLimit(SX126X_CURRENT_LIMIT); - #endif +#ifdef SX126X_CURRENT_LIMIT + radio.setCurrentLimit(SX126X_CURRENT_LIMIT); +#endif - #ifdef SX126X_DIO2_AS_RF_SWITCH - radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); - #endif +#ifdef SX126X_DIO2_AS_RF_SWITCH + radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); #endif fast_rng.begin(radio.random(0x7FFFFFFF)); diff --git a/platformio.ini b/platformio.ini index bdbdcab9..d5b6bce4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -320,16 +320,16 @@ lib_deps = densaugeo/base64 @ ~1.4.0 ; ============= -[LilyGo_T3_sx1276] +[LilyGo_TLora_V2_1_1_6] extends = esp32_base -board = ttgo-lora32-v1 ; TTGO/LilyGo T3 V1 ESP32 with SX1276 +board = ttgo-lora32-v1 ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276 build_unflags = -Os build_type = release ; Set build type to release board_build.partitions = min_spiffs.csv ; get around 4mb flash limit build_flags = ${esp32_base.build_flags} -Os -ffunction-sections -fdata-sections ; Optimize for size - -D LILYGO_T3 + -D LILYGO_TLORA ; LILYGO T-LoRa V2.1-1.6 ESP32 with SX1276 -D P_LORA_DIO_0=26 ; SX1276 DIO0 interrupt pin -D P_LORA_DIO_1=33 ; SX1276 DIO1 interrupt pin -D P_LORA_NSS=18 ; Chip select - SS pin @@ -367,13 +367,13 @@ build_flags = ${esp32_base.build_flags} -D LORA_TX_POWER=22 -; === LilyGo T3 with SX1276 environments === -[env:LilyGo_T3_sx1276_Repeater] -extends = LilyGo_T3_sx1276 -build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_repeater/main.cpp> +; === LILYGO T-LoRa V2.1-1.6 with SX1276 environments === +[env:LilyGo_TLora_V2_1_1_6_Repeater] +extends = LilyGo_TLora_V2_1_1_6 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_repeater/main.cpp> build_flags = - ${LilyGo_T3_sx1276.build_flags} - -D ADVERT_NAME="\"T3-1276 Repeater\"" + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D ADVERT_NAME="\"TLora-V2.1-1.6 Repeater\"" -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 -D ADMIN_PASSWORD="\"password\"" @@ -381,38 +381,38 @@ build_flags = ; -D MESH_DEBUG=1 ; -D CORE_DEBUG_LEVEL=3 -[env:LilyGo_T3_sx1276_terminal_chat] -extends = LilyGo_T3_sx1276 +[env:LilyGo_TLora_V2_1_1_6_terminal_chat] +extends = LilyGo_TLora_V2_1_1_6 build_flags = - ${LilyGo_T3_sx1276.build_flags} + ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_secure_chat/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_secure_chat/main.cpp> lib_deps = - ${LilyGo_T3_sx1276.lib_deps} + ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:LilyGo_T3_sx1276_companion_radio_usb] -extends = LilyGo_T3_sx1276 +[env:LilyGo_TLora_V2_1_1_6_companion_radio_usb] +extends = LilyGo_TLora_V2_1_1_6 build_flags = - ${LilyGo_T3_sx1276.build_flags} + ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 ; -D ENABLE_PRIVATE_KEY_IMPORT=1 ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; NOTE: DO NOT ENABLE --> -D MESH_PACKET_LOGGING=1 ; NOTE: DO NOT ENABLE --> -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/companion_radio/main.cpp> lib_deps = - ${LilyGo_T3_sx1276.lib_deps} + ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:LilyGo_T3_sx1276_companion_radio_ble] -extends = LilyGo_T3_sx1276 +[env:LilyGo_TLora_V2_1_1_6_companion_radio_ble] +extends = LilyGo_TLora_V2_1_1_6 build_flags = - ${LilyGo_T3_sx1276.build_flags} + ${LilyGo_TLora_V2_1_1_6.build_flags} -D MAX_CONTACTS=100 -D MAX_GROUP_CHANNELS=1 -D BLE_PIN_CODE=123456 @@ -421,17 +421,17 @@ build_flags = ; -D ENABLE_PRIVATE_KEY_EXPORT=1 ; -D MESH_PACKET_LOGGING=1 ; -D MESH_DEBUG=1 -build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} + +<../examples/companion_radio/main.cpp> +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} + +<../examples/companion_radio/main.cpp> lib_deps = - ${LilyGo_T3_sx1276.lib_deps} + ${LilyGo_TLora_V2_1_1_6.lib_deps} densaugeo/base64 @ ~1.4.0 -[env:LilyGo_T3_sx1276_room_server] -extends = LilyGo_T3_sx1276 -build_src_filter = ${LilyGo_T3_sx1276.build_src_filter} +<../examples/simple_room_server/main.cpp> +[env:LilyGo_TLora_V2_1_1_6_room_server] +extends = LilyGo_TLora_V2_1_1_6 +build_src_filter = ${LilyGo_TLora_V2_1_1_6.build_src_filter} +<../examples/simple_room_server/main.cpp> build_flags = - ${LilyGo_T3_sx1276.build_flags} - -D ADVERT_NAME="\"T3-1276 Room\"" + ${LilyGo_TLora_V2_1_1_6.build_flags} + -D ADVERT_NAME="\"TLora-V2.1-1.6 Room\"" -D ADVERT_LAT=-37.0 -D ADVERT_LON=145.0 -D ADMIN_PASSWORD="\"password\"" diff --git a/src/helpers/LilyGoT3S3Board.h b/src/helpers/LilyGoT3S3Board.h deleted file mode 100644 index f7287d21..00000000 --- a/src/helpers/LilyGoT3S3Board.h +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once - -#include -#include "ESP32Board.h" -#include - -// LoRa radio module pins for LilyGo T3S3 -// These need to be defined here for the SX1276 version -#if defined(RADIO_CLASS) && defined(CustomSX1276) - // SX1276 pin definitions specific to LilyGo T3S3 - #define P_LORA_DIO_0 34 // DIO0 interrupt pin (SX1276 uses DIO0) - #define P_LORA_DIO_1 33 // DIO1 interrupt pin - #define P_LORA_NSS 7 // Chip select - #define P_LORA_RESET 8 // Reset pin - #define P_LORA_SCLK 5 // SPI clock - #define P_LORA_MISO 3 // SPI MISO - #define P_LORA_MOSI 6 // SPI MOSI -#endif - -// Base class for LilyGo T-series boards -class LilyGoTBoard : public ESP32Board { -public: - void begin() { - ESP32Board::begin(); - - esp_reset_reason_t reason = esp_reset_reason(); - if (reason == ESP_RST_DEEPSLEEP) { - long wakeup_source = esp_sleep_get_ext1_wakeup_status(); - if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep) - 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 enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) { - esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); - - // Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep - 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); - - if (pin_wake_btn < 0) { - esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet - } else { - esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn - } - - if (secs > 0) { - esp_sleep_enable_timer_wakeup(secs * 1000000); - } - - // Finally set ESP32 into sleep - esp_deep_sleep_start(); // CPU halts here and never returns! - } - - uint16_t getBattMilliVolts() override { - analogReadResolution(12); - - uint32_t raw = 0; - for (int i = 0; i < 8; i++) { - raw += analogReadMilliVolts(PIN_VBAT_READ); - } - raw = raw / 8; - - return (2 * raw); - } -}; - -// Standard ESP32 version (for T3 board) -class LilyGoT3Board : public LilyGoTBoard { -public: - const char* getManufacturerName() const override { - return "LilyGo T3"; - } -}; - -// For S3 variant -class LilyGoT3S3Board : public LilyGoTBoard { -public: - const char* getManufacturerName() const override { - return "LilyGo T3S3"; - } -}; \ No newline at end of file diff --git a/src/helpers/LilyGoTLoraBoard.h b/src/helpers/LilyGoTLoraBoard.h new file mode 100644 index 00000000..c595740f --- /dev/null +++ b/src/helpers/LilyGoTLoraBoard.h @@ -0,0 +1,24 @@ +#pragma once + +#include +#include "ESP32Board.h" + +// LILYGO T-LoRa V2.1-1.6 board with SX1276 +class LilyGoTLoraBoard : public ESP32Board { +public: + const char* getManufacturerName() const override { + return "LILYGO T-LoRa V2.1-1.6"; + } + + uint16_t getBattMilliVolts() override { + analogReadResolution(12); + + uint32_t raw = 0; + for (int i = 0; i < 8; i++) { + raw += analogReadMilliVolts(PIN_VBAT_READ); + } + raw = raw / 8; + + return (2 * raw); + } +}; \ No newline at end of file