diff --git a/devtimer.py b/devtimer.py index 1bf61dc..23ab8ff 100755 --- a/devtimer.py +++ b/devtimer.py @@ -35,11 +35,12 @@ TIME_CLK = 21 TIME_DIO = 20 +BEEPER = 26 # Piezo alarm device FOOTSW = 6 # GPIO port to read footswitch state # General Constants -BEEP = 30 # Beep interval +BEEP_INTERVAL = 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 @@ -237,7 +238,15 @@ # Beep at the user at fixed intervals def beep(): - print("Beep!") + + for repeat in range(10): + wiringpi.digitalWrite(BEEPER, 1) + sleep(0.02) + wiringpi.digitalWrite(BEEPER, 0) + sleep(0.02) + + if DEBUG: + print("Beep!") # Callback when footswitch is pressed @@ -307,6 +316,8 @@ # Setup the hardware wiringpi.wiringPiSetupGpio() + wiringpi.pinMode(BEEPER, wiringpi.GPIO.OUTPUT) + wiringpi.pinMode(BEEPER, wiringpi.GPIO.PUD_DOWN) wiringpi.pinMode(FOOTSW, wiringpi.GPIO.INPUT) wiringpi.pinMode(FOOTSW, wiringpi.GPIO.PUD_UP) @@ -343,8 +354,8 @@ # Beep periodically - if not elapsed_time % BEEP: - beep() + if RUNNING and not elapsed_time % BEEP_INTERVAL: + Thread(name="Beep", target=beep).start() if DEBUG: last = time()