Skip to content

fix: dynamically assign button pin to prevent false interrupts#10742

Open
LN4CY wants to merge 1 commit into
meshtastic:developfrom
LN4CY:fix-dynamic-button-pin
Open

fix: dynamically assign button pin to prevent false interrupts#10742
LN4CY wants to merge 1 commit into
meshtastic:developfrom
LN4CY:fix-dynamic-button-pin

Conversation

@LN4CY

@LN4CY LN4CY commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

This PR resolves the false interrupt and random wake issues caused by floating button pins on variants where the button is not physically wired (such as rak3401_1watt), while fully restoring button functionality when a GPIO is explicitly assigned via the Meshtastic configuration.

Changes Made:

  • Removed hardcoded #ifdef BUTTON_PIN guards in InputBroker.cpp, PowerFSM.cpp, sleep.cpp, and main-esp32.cpp in favor of #if HAS_BUTTON.
  • Refactored logic to dynamically resolve _btnPin using the following priority:
    1. config.device.button_gpio (if explicitly assigned at runtime)
    2. USERPREFS_BUTTON_PIN (if defined in userprefs)
    3. BUTTON_PIN (if defined in the variant header)
  • If no valid pin is resolved (evaluates to 0xFF), the firmware skips configuring the button pull-ups, skips initializing ButtonThread, and ignores digital reads during sleep, avoiding any false positives on floating pins.

?? Attestations

  • I have tested that my proposed changes behave as described.
  • I have tested that my proposed changes do not cause any obvious regressions on the following devices:
    • Heltec (Lora32) V3
    • LilyGo T-Deck
    • LilyGo T-Beam
    • RAK WisBlock 4631
    • Seeed Studio T-1000E tracker card
    • Other: RAK3401 1-Watt
    • Other: RAK WisMesh Tap

Fixes #10574

@github-actions github-actions Bot added the bugfix Pull request that fixes bugs label Jun 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚡ Try this PR in the Web Flasher

Note

Building this pull request… the flash button, badges and supported-board
list will appear here automatically once CI finishes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add user button for Rak 1 Watt radio

1 participant