From 8decf0ba85bb7271724d5c26e50c1413326045eb Mon Sep 17 00:00:00 2001 From: mikecarper Date: Fri, 14 Aug 2026 20:11:36 -0700 Subject: [PATCH] Restore normal T-Beam 1W RXEN startup --- src/helpers/radiolib/CustomSX1262.h | 14 ++++++-------- variants/lilygo_tbeam_1w/TBeam1WBoard.cpp | 13 +++++++++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/helpers/radiolib/CustomSX1262.h b/src/helpers/radiolib/CustomSX1262.h index d6635d65..91517ed8 100644 --- a/src/helpers/radiolib/CustomSX1262.h +++ b/src/helpers/radiolib/CustomSX1262.h @@ -173,12 +173,6 @@ class CustomSX1262 : public SX1262 { static const uint32_t pins[Module::RFSWITCH_MAX_PINS] = { SX126X_RXEN, tx_en, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, }; - static const Module::RfSwitchMode_t lna_enabled_table[] = { - { Module::MODE_IDLE, { LOW, LOW } }, - { Module::MODE_RX, { HIGH, LOW } }, - { Module::MODE_TX, { LOW, HIGH } }, - END_OF_MODE_TABLE, - }; static const Module::RfSwitchMode_t lna_disabled_table[] = { { Module::MODE_IDLE, { LOW, LOW } }, { Module::MODE_RX, { LOW, LOW } }, @@ -186,8 +180,12 @@ class CustomSX1262 : public SX1262 { END_OF_MODE_TABLE, }; - this->mod->setRfSwitchTable( - pins, enabled ? lna_enabled_table : lna_disabled_table); + if (enabled) { + // Restore RadioLib's standard RXEN/TXEN behavior exactly. + setRfSwitchPins(SX126X_RXEN, tx_en); + } else { + this->mod->setRfSwitchTable(pins, lna_disabled_table); + } return true; #else (void)enabled; diff --git a/variants/lilygo_tbeam_1w/TBeam1WBoard.cpp b/variants/lilygo_tbeam_1w/TBeam1WBoard.cpp index 69c0b1c6..f9a6b16c 100644 --- a/variants/lilygo_tbeam_1w/TBeam1WBoard.cpp +++ b/variants/lilygo_tbeam_1w/TBeam1WBoard.cpp @@ -10,10 +10,8 @@ void TBeam1WBoard::begin() { radio_powered = true; delay(10); // Allow radio to power up - // Keep the external LNA off until RadioLib deliberately enters RX. GPIO21 - // is subsequently controlled by RadioLib's target-specific RF switch table. - pinMode(SX126X_RXEN, OUTPUT); - digitalWrite(SX126X_RXEN, LOW); + // GPIO21/CTRL is initialized by RadioLib with the normal RXEN mode table. + // Do not drive it independently during board startup. // Initialize LED pinMode(LED_PIN, OUTPUT); @@ -71,6 +69,13 @@ void TBeam1WBoard::attachRadioDriver(CustomSX1262Wrapper* driver) { } bool TBeam1WBoard::setLoRaFemLnaEnabled(bool enable) { + // The normal/default ON state is already installed by radio.std_init(). + // Avoid touching GPIO21 or reconfiguring the radio during boot unless the + // saved setting actually requests a different state. + if (lna_enabled == enable) { + return radio_driver != nullptr; + } + if (radio_driver == nullptr || !radio_driver->setExternalRxLnaEnabled(enable)) { return false; }