diff --git a/devtimer.py b/devtimer.py index 601b84b..45276ef 100755 --- a/devtimer.py +++ b/devtimer.py @@ -26,23 +26,33 @@ DEBUG = True # Debugging switch BEEP = 15 # Beep interval -CALIBRATION_OFFSET = 0.0022 # Compensate for program overhead in master loop -NORMAL_TEMP = 68 # Reference temperature in degrees F +CALIBRATION_OFFSET = 0.002 # Compensate for program overhead in master loop +# Profile Constants + +REALTIME = 0 +PAPER = 1 +FILM = 2 + + +# Globals (So shoot me ...) +# These get updated by the thereads reading the switches and thermocouple + +CURRENT_PROFILE = FILM +CURRENT_TEMP = 20 # Stored as index relative to 60F ##### # Lookup Table For Compensating Factors ##### ''' - Each paper|film-developer combo has an entry here, expressed as: + There are 3 tables in the list below. In order: - +- correction/degree + Realtime + Paper + Film - 68F is considered "normal". Temperatures below this will cause the - timer to run slower. Temperatures above it, will cause the timer to - run faster. This creates a "virtual second" that reflect time, - material, and developer selected. + Each contains entires for muliplicative corrections from 60F to 80F. WARNING: It takes about 250ms to update the display on a Pi Zero. So, if the "virtual second" falls at or below this, the @@ -53,29 +63,18 @@ ''' compensate = ( - 0.000, # Normal - 0.010, # Small temperature dependency - 0.040, # Medium temperature dependency - 0.100, # Large temperature dependency + (1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000, 1.000), + (1.724, 1.611, 1.505, 1.406, 1.313, 1.227, 1.146, 1.070, 1.000, 0.934, 0.873, 0.815, 0.762, 0.711, 0.665, 0.621, 0.580, 0.542, 0.506, 0.473, 0.442), + (1.445, 1.380, 1.318, 1.259, 1.202, 1.148, 1.096, 1.047, 1.000, 0.955, 0.912, 0.871, 0.832, 0.795, 0.759, 0.725, 0.692, 0.661, 0.631, 0.603, 0.576) ) + # Beep at the user at fixed intervals def beep(): print("Beep!") -# Get currently selected media/developer profile - -def get_profile(): - return 0 - -# Return the current temperature in degrees F - -def get_temp(): - return 72 - - # Update the display with elapsed time def show_elapsed(display0, elapsed): @@ -88,7 +87,9 @@ d3 = display0.digit_to_segment[sec % 10] display0.set_segments([d0, 0x80 + d1, d2, d3]) +##### # Program entry point +##### ''' Notice that the actual updating of the display gets run on its own @@ -119,7 +120,7 @@ last = time() update_thread = Thread(None, show_elapsed, None, (display0, elapsed_time)) - sleep(1.000 + ((NORMAL_TEMP-get_temp()) * compensate[get_profile()]) - CALIBRATION_OFFSET) + sleep(compensate[CURRENT_PROFILE][CURRENT_TEMP] - CALIBRATION_OFFSET) elapsed_time += 1 elapsed_time %= 6000 update_thread = Thread(None, show_elapsed, None, (display0, elapsed_time))