diff --git a/devtimer.py b/devtimer.py index 47abd19..66749b2 100755 --- a/devtimer.py +++ b/devtimer.py @@ -244,19 +244,15 @@ # Check to see if footswitch got pressed def monitor_footsw(): + global RUNNING while True: if not digitalRead(FOOTSW): # Button push pulls down - Thread(name="ReadFootSW", target=read_footsw).start() - sleep(.5) + sleep(.030) # Wait for debounce + if not digitalRead(FOOTSW): + RUNNING = not RUNNING -def read_footsw(): - global RUNNING - - sleep(0.10) - if not digitalRead(FOOTSW): - RUNNING = not RUNNING - print(RUNNING) + sleep(.100) # Update the display with elapsed time @@ -332,6 +328,12 @@ if DEBUG: last = time() + print("Running State: %s" % RUNNING) + + # If we're not running, don't update elapsed time + + if not RUNNING: + elapsed_time = 0 # Update the time display