From 56360a2a0560e158074ecfd654b5d8996ebb6182 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 20 Jun 2020 16:59:20 +0200 Subject: [PATCH] Changed setRfSwitchState to directly change switch pins --- src/Module.cpp | 11 +++-------- src/Module.h | 6 ++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Module.cpp b/src/Module.cpp index af6415bb..e24e6424 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -323,18 +323,13 @@ void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) { Module::pinMode(txEn, OUTPUT); } -void Module::setRfSwitchState(bool tx) { +void Module::setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState) { // check RF switch control is enabled if(!_useRfSwitch) { return; } // set pins - if(tx) { - Module::digitalWrite(_rxEn, LOW); - Module::digitalWrite(_txEn, HIGH); - } else { - Module::digitalWrite(_rxEn, HIGH); - Module::digitalWrite(_txEn, LOW); - } + Module::digitalWrite(_rxEn, rxPinState); + Module::digitalWrite(_txEn, txPinState); } diff --git a/src/Module.h b/src/Module.h index 41e25299..2a20b926 100644 --- a/src/Module.h +++ b/src/Module.h @@ -399,9 +399,11 @@ class Module { /*! \brief Set RF switch state. - \param tx True to set RF switch to Tx, false to set switch to Rx. + \param rxPinState Pin state to set on Tx enable pin (usually high to transmit). + + \param txPinState Pin state to set on Rx enable pin (usually high to receive). */ - void setRfSwitchState(bool tx); + void setRfSwitchState(RADIOLIB_PIN_STATUS rxPinState, RADIOLIB_PIN_STATUS txPinState); #ifndef RADIOLIB_GODMODE private: