From ea72dd0f9719872fe4c6c6bbacb18ba0b343884d Mon Sep 17 00:00:00 2001 From: Piero Andreini Date: Sun, 5 Apr 2026 12:04:08 +0200 Subject: [PATCH] fix: Add #ifdef PIN_USER_BTN_ANA guard for boards without analog button - Protect MomentaryButton instantiation with #ifdef PIN_USER_BTN_ANA - Use dummy pin 0 when PIN_USER_BTN_ANA is not defined - Allows compilation on boards without analog button support - Applied to both SX1262 and SX1276 variants --- variants/lilygo_t_eth_elite_sx1262/target.cpp | 8 ++++++++ variants/lilygo_t_eth_elite_sx1276/target.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/variants/lilygo_t_eth_elite_sx1262/target.cpp b/variants/lilygo_t_eth_elite_sx1262/target.cpp index c9d9e189..c42236f3 100644 --- a/variants/lilygo_t_eth_elite_sx1262/target.cpp +++ b/variants/lilygo_t_eth_elite_sx1262/target.cpp @@ -8,8 +8,16 @@ TEthEliteBoard board; DISPLAY_CLASS display; #endif +#ifdef PIN_USER_BTN_ANA +// If the analog pin is defined, use it for both button instances MomentaryButton user_btn(PIN_USER_BTN_ANA, 1000, true); MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, true); // alias for UITask analog button support +#else +// If NOT defined, route user_btn to pin 0 +// and create analog_btn as a dummy alias to satisfy UITask requirements +MomentaryButton user_btn(0, 1000, true); +MomentaryButton analog_btn(0, 1000, true); +#endif static SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); diff --git a/variants/lilygo_t_eth_elite_sx1276/target.cpp b/variants/lilygo_t_eth_elite_sx1276/target.cpp index 03d6d38d..b0cb78be 100644 --- a/variants/lilygo_t_eth_elite_sx1276/target.cpp +++ b/variants/lilygo_t_eth_elite_sx1276/target.cpp @@ -8,8 +8,16 @@ TEthEliteBoard board; DISPLAY_CLASS display; #endif +#ifdef PIN_USER_BTN_ANA +// If the analog pin is defined, use it for both button instances MomentaryButton user_btn(PIN_USER_BTN_ANA, 1000, true); MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, true); // alias for UITask analog button support +#else +// If NOT defined, route user_btn to pin 0 +// and create analog_btn as a dummy alias to satisfy UITask requirements +MomentaryButton user_btn(0, 1000, true); +MomentaryButton analog_btn(0, 1000, true); +#endif static SPIClass spi; RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);