diff --git a/devtimer.py b/devtimer.py index 93155f3..f7cabb1 100755 --- a/devtimer.py +++ b/devtimer.py @@ -247,14 +247,25 @@ def footsw_pressed(): global RUNNING - # Process footswitch press accounting for debounce + # Ignore interrupts during debounce window - if time() - footsw_pressed.lastISR >= 0.100: + if not footsw_pressed.debouncing: + RUNNING = not RUNNING + + if DEBUG: + print("Running State: %s" % RUNNING) + + # Mask interrupts during debounce window + + if time() - footsw_pressed.lastISR >= 0.040: + + footsw_pressed.debouncing = False footsw_pressed.lastISR = time() - if DEBUG: - print("Running State: %s" % RUNNING) + else: + + footsw_pressed.debouncing = True # Check to see if footswitch got pressed @@ -263,6 +274,7 @@ # We store last interrupt service time as a callback global for debounce + footsw_pressed.debouncing = False footsw_pressed.lastISR = 0 # Setup the callback