button even detection
Some checks failed
Python CI / test (3.13) (push) Has been cancelled
Python CI / test (3.12) (push) Has been cancelled

This commit is contained in:
Duncan Tourolle 2025-11-23 14:37:03 +01:00
parent 0e6a8d53eb
commit 5f38e3865e

View File

@ -119,6 +119,12 @@ class GPIOButtonHandler:
# Configure each button # Configure each button
for button in self.buttons: for button in self.buttons:
try: try:
# Clean up any existing event detection on this pin
try:
GPIO.remove_event_detect(button.gpio)
except Exception:
pass # Ignore if no event detection was set
# Configure pin # Configure pin
if self.pull_up: if self.pull_up:
GPIO.setup(button.gpio, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(button.gpio, GPIO.IN, pull_up_down=GPIO.PUD_UP)