Fix RF95 optional pins and CannedMessage initialization (#11913)

* Fix RF95 optional pins and CannedMessage initialization

* style: clang-format CannedMessageModule else branch

---------

Co-authored-by: Tom <116762865+NomDeTom@users.noreply.github.com>
Co-authored-by: caveman99 <tgoettgens@gmail.com>
Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
authored and GitHub committed 2026-10-18 23:38:28 +00:00
1 parent 72edb49e1f
commit 31bcb2ae0a
2 files changed
+20 -13

No files matched your search

+8 -8
View File
@@ -91,7 +91,7 @@ RF95Interface::RF95Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIO
/** Some boards require GPIO control of tx vs rx paths */
void RF95Interface::setTransmitEnable(bool txon)
{
#ifdef RF95_TXEN
#if defined(RF95_TXEN) && (RF95_TXEN != RADIOLIB_NC)
digitalWrite(RF95_TXEN, txon ? 1 : 0);
#elif ARCH_PORTDUINO
if (portduino_config.lora_txen_pin.pin != RADIOLIB_NC) {
@@ -99,7 +99,7 @@ void RF95Interface::setTransmitEnable(bool txon)
}
#endif
#ifdef RF95_RXEN
#if defined(RF95_RXEN) && (RF95_RXEN != RADIOLIB_NC)
digitalWrite(RF95_RXEN, txon ? 0 : 1);
#elif ARCH_PORTDUINO
if (portduino_config.lora_rxen_pin.pin != RADIOLIB_NC) {
@@ -113,7 +113,7 @@ void RF95Interface::setTransmitEnable(bool txon)
/// \return true if initialisation succeeded.
bool RF95Interface::init()
{
#ifdef RF95_POWER_EN
#if defined(RF95_POWER_EN) && (RF95_POWER_EN != RADIOLIB_NC)
pinMode(RF95_POWER_EN, OUTPUT);
digitalWrite(RF95_POWER_EN, HIGH);
#endif
@@ -153,17 +153,17 @@ bool RF95Interface::init()
#define RF95_RXEN (23) // If defined, this pin should be set high prior to receive (controls an external analog switch)
*/
#ifdef RF95_TXEN
#if defined(RF95_TXEN) && (RF95_TXEN != RADIOLIB_NC)
pinMode(RF95_TXEN, OUTPUT);
digitalWrite(RF95_TXEN, 0);
#endif
#ifdef RF95_FAN_EN
#if defined(RF95_FAN_EN) && (RF95_FAN_EN != RADIOLIB_NC)
pinMode(RF95_FAN_EN, OUTPUT);
digitalWrite(RF95_FAN_EN, 1);
#endif
#ifdef RF95_RXEN
#if defined(RF95_RXEN) && (RF95_RXEN != RADIOLIB_NC)
pinMode(RF95_RXEN, OUTPUT);
digitalWrite(RF95_RXEN, 1);
#endif
@@ -420,11 +420,11 @@ bool RF95Interface::sleep()
(void)trySetStandby(); // First cancel any active receiving/sending - going to sleep, a failure must not crash
lora->sleep();
#ifdef RF95_POWER_EN
#if defined(RF95_POWER_EN) && (RF95_POWER_EN != RADIOLIB_NC)
digitalWrite(RF95_POWER_EN, LOW);
#endif
#ifdef RF95_FAN_EN
#if defined(RF95_FAN_EN) && (RF95_FAN_EN != RADIOLIB_NC)
digitalWrite(RF95_FAN_EN, 0);
#endif
+12 -5
View File
@@ -74,6 +74,10 @@ CannedMessageModule::CannedMessageModule()
LOG_INFO("CannedMessage: none configured, disabled");
this->updateState(CANNED_MESSAGE_RUN_STATE_DISABLED);
disable();
} else if (!inputBroker) {
LOG_INFO("CannedMessage: no InputBroker, disabled");
this->updateState(CANNED_MESSAGE_RUN_STATE_DISABLED);
disable();
} else {
LOG_INFO("CannedMessageModule is enabled");
moduleConfig.canned_message.enabled = true;
@@ -544,12 +548,15 @@ int CannedMessageModule::handleInputEvent(const InputEvent *event)
void CannedMessageModule::updateState(cannedMessageModuleRunState newState, bool shouldRequestFocus)
{
runState = newState;
if (runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
inputBroker->menuMode =
false; // Allow any key input to be sent to the message composer instead of being interpreted as menu navigation
} else {
inputBroker->menuMode = true; // Re-enable menu navigation for destination selection
if (inputBroker) {
if (runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) {
inputBroker->menuMode =
false; // Allow any key input to be sent to the message composer instead of being interpreted as menu navigation
} else {
inputBroker->menuMode = true; // Re-enable menu navigation for destination selection
}
}
if (shouldRequestFocus) {
requestFocus();
}