Canned messages: allow GPIO0 with "scan and select" input (#5838)
Some checks are pending
Daily Packaging / package-ppa (jammy) (push) Waiting to run
Daily Packaging / package-ppa (noble) (push) Waiting to run
Daily Packaging / package-ppa (oracular) (push) Waiting to run
Daily Packaging / package-ppa (plucky) (push) Waiting to run
Daily Packaging / package-obs (push) Waiting to run
Daily Packaging / hook-copr (push) Waiting to run
CI / setup (check) (push) Waiting to run
CI / setup (esp32) (push) Waiting to run
CI / setup (esp32c3) (push) Waiting to run
CI / setup (esp32c6) (push) Waiting to run
CI / setup (esp32s3) (push) Waiting to run
CI / setup (nrf52840) (push) Waiting to run
CI / setup (rp2040) (push) Waiting to run
CI / setup (stm32) (push) Waiting to run
CI / check (push) Blocked by required conditions
CI / build-esp32 (push) Blocked by required conditions
CI / build-esp32-s3 (push) Blocked by required conditions
CI / build-esp32-c3 (push) Blocked by required conditions
CI / build-esp32-c6 (push) Blocked by required conditions
CI / build-nrf52 (push) Blocked by required conditions
CI / build-rpi2040 (push) Blocked by required conditions
CI / build-stm32 (push) Blocked by required conditions
CI / package-raspbian (push) Waiting to run
CI / package-raspbian-armv7l (push) Waiting to run
CI / package-native (push) Waiting to run
CI / build-debian-src (push) Waiting to run
CI / test-native (push) Waiting to run
CI / build-docker (push) Waiting to run
CI / after-checks (push) Blocked by required conditions
CI / gather-artifacts (esp32) (push) Blocked by required conditions
CI / gather-artifacts (esp32c3) (push) Blocked by required conditions
CI / gather-artifacts (esp32c6) (push) Blocked by required conditions
CI / gather-artifacts (esp32s3) (push) Blocked by required conditions
CI / gather-artifacts (nrf52840) (push) Blocked by required conditions
CI / gather-artifacts (rp2040) (push) Blocked by required conditions
CI / gather-artifacts (stm32) (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
CI / release-firmware (esp32) (push) Blocked by required conditions
CI / release-firmware (esp32c3) (push) Blocked by required conditions
CI / release-firmware (esp32c6) (push) Blocked by required conditions
CI / release-firmware (esp32s3) (push) Blocked by required conditions
CI / release-firmware (nrf52840) (push) Blocked by required conditions
CI / release-firmware (rp2040) (push) Blocked by required conditions
CI / release-firmware (stm32) (push) Blocked by required conditions
Flawfinder Scan / Flawfinder (push) Waiting to run

* Allow GPIO0; check for conflict with user button

* Guard for no BUTTON_PIN; handle portduino

* Portduino settings: attempt two
We don't really need to #include radio code here just to check if the pin is RADIOLIB_NC. We're only interested if scanAndSelect pin matches user button pin, but they won't match if user button is RADIOLIB_NC.

* Portduino attempt 3: glue
This commit is contained in:
todd-herbert 2025-01-17 01:38:22 +13:00 committed by GitHub
parent 262f1d25a2
commit a48df91737
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,9 @@
#include "ScanAndSelect.h" #include "ScanAndSelect.h"
#include "modules/CannedMessageModule.h" #include "modules/CannedMessageModule.h"
#include <Throttle.h> #include <Throttle.h>
#ifdef ARCH_PORTDUINO // Only to check for pin conflict with user button
#include "platform/portduino/PortduinoGlue.h"
#endif
// Config // Config
static const char name[] = "scanAndSelect"; // should match "allow input source" string static const char name[] = "scanAndSelect"; // should match "allow input source" string
@ -30,7 +33,9 @@ bool ScanAndSelectInput::init()
if (strcasecmp(moduleConfig.canned_message.allow_input_source, name) != 0) if (strcasecmp(moduleConfig.canned_message.allow_input_source, name) != 0)
return false; return false;
// Use any available inputbroker pin as the button // Determine which pin to use for the single scan-and-select button
// User can specify this by setting any of the inputbroker pins
// If all values are zero, we'll assume the user *does* want GPIO0
if (moduleConfig.canned_message.inputbroker_pin_press) if (moduleConfig.canned_message.inputbroker_pin_press)
pin = moduleConfig.canned_message.inputbroker_pin_press; pin = moduleConfig.canned_message.inputbroker_pin_press;
else if (moduleConfig.canned_message.inputbroker_pin_a) else if (moduleConfig.canned_message.inputbroker_pin_a)
@ -38,7 +43,25 @@ bool ScanAndSelectInput::init()
else if (moduleConfig.canned_message.inputbroker_pin_b) else if (moduleConfig.canned_message.inputbroker_pin_b)
pin = moduleConfig.canned_message.inputbroker_pin_b; pin = moduleConfig.canned_message.inputbroker_pin_b;
else else
return false; // Short circuit: no button found pin = 0; // GPIO 0 then
// Short circuit: if selected pin conficts with the user button
#if defined(ARCH_PORTDUINO)
int pinUserButton = 0;
if (settingsMap.count(user) != 0) {
pinUserButton = settingsMap[user];
}
#elif defined(USERPREFS_BUTTON_PIN)
int pinUserButton = config.device.button_gpio ? config.device.button_gpio : USERPREFS_BUTTON_PIN;
#elif defined(BUTTON_PIN)
int pinUserButton = config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN;
#else
int pinUserButton = config.device.button_gpio;
#endif
if (pin == pinUserButton) {
LOG_ERROR("ScanAndSelect conflict with user button");
return false;
}
// Set-up the button // Set-up the button
pinMode(pin, INPUT_PULLUP); pinMode(pin, INPUT_PULLUP);