diff --git a/devtimer.py b/devtimer.py index d30aeba..53fe809 100755 --- a/devtimer.py +++ b/devtimer.py @@ -22,13 +22,14 @@ CLK = 21 DIO = 20 -# Compensate for program execution time in master timing loop +# General Constants -CALIBRATION_OFFSET = 0.0032 +DEBUG = True # Debugging switch -# Reference temperature in degrees F +BEEP = 15 # Beep interval +CALIBRATION_OFFSET = 0.0022 # Compensate for program overhead in master loop +NORMAL_TEMP = 68 # Reference temperature in degrees F -NORMAL_TEMP = 68 ##### # Lookup Table For Compensating Factors @@ -53,11 +54,17 @@ compensate = ( 0.000, # Normal - 0.002, # Small temperature dependency - 0.004, # Medium temperature dependency - 0.010, # Large temperature dependency + 0.010, # Small temperature dependency + 0.040, # Medium temperature dependency + 0.100, # Large temperature dependency ) +# Beep at the user at fixed intervals + +def beep(): + print("Beep!") + + # Return the current temperature in degrees F def get_temp(): @@ -86,11 +93,19 @@ elapsed_time = 0 while True: + # Beep periodically + + if elapsed_time and not elapsed_time%BEEP: + beep() + last = time() update_thread = Thread(None, show_elapsed, None, (display0, elapsed_time)) - sleep((1.000 + ((NORMAL_TEMP-get_temp()) * compensate[3])) - CALIBRATION_OFFSET) + sleep(1.000 + ((NORMAL_TEMP-get_temp()) * compensate[0]) - CALIBRATION_OFFSET) elapsed_time += 1 elapsed_time %= 6000 update_thread = Thread(None, show_elapsed, None, (display0, elapsed_time)) - print(time()-last) + + if DEBUG: + print("Inter-update Time: %s" % str(time()-last)) + update_thread.start()