diff --git a/devtimer.py b/devtimer.py index f7cabb1..db88f27 100755 --- a/devtimer.py +++ b/devtimer.py @@ -41,6 +41,7 @@ BEEP = 30 # Beep interval CALIBRATION_OFFSET = 0.003 # Compensate for program overhead in master loop +DEBOUNCE_TIME = 1.5 # In seconds MINUS = 16 # Index of minus segment table lookup TEMP_SENTINEL = 999 # Briefly appears at start, if it stays, temp measurement isn't working @@ -247,25 +248,15 @@ def footsw_pressed(): global RUNNING - # Ignore interrupts during debounce window - - 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: + if time() - footsw_pressed.lastISR >= DEBOUNCE_TIME: - footsw_pressed.debouncing = False + RUNNING = not RUNNING footsw_pressed.lastISR = time() - else: - - footsw_pressed.debouncing = True + if DEBUG: + print("Running State: %s" % RUNNING) # Check to see if footswitch got pressed @@ -274,7 +265,6 @@ # We store last interrupt service time as a callback global for debounce - footsw_pressed.debouncing = False footsw_pressed.lastISR = 0 # Setup the callback @@ -284,7 +274,7 @@ # Run the thread forever waiting for footswitch presses while True: - sleep(1000) + sleep(10000) # Update the display with elapsed time