diff --git a/devtimer.py b/devtimer.py index b5e28b7..7ad3051 100755 --- a/devtimer.py +++ b/devtimer.py @@ -26,11 +26,17 @@ # Constants ##### -# Display +# Display Hardware Configuration -BRIGHTNESS0 = 0x0a -CLK0 = 21 -DIO0 = 20 +TIME_BRIGHT = 0x0a +TIME_CLK = 21 +TIME_DIO = 20 + +TEMP_BRIGHT = 0x0a +TEMP_CLK = 12 +TEMP_DIO = 16 + +DIMMING = 1 # How much to dim display in film mode # General Constants @@ -82,15 +88,23 @@ # Update the display with elapsed time -def show_elapsed(display0, elapsed): +def show_elapsed(display_time, elapsed): min = elapsed // 60 sec = elapsed % 60 - d0 = display0.digit_to_segment[min // 10] - d1 = display0.digit_to_segment[min % 10] - d2 = display0.digit_to_segment[sec // 10] - d3 = display0.digit_to_segment[sec % 10] - display0.set_segments([d0, 0x80 + d1, d2, d3]) + d0 = display_time.digit_to_segment[min // 10] + d1 = display_time.digit_to_segment[min % 10] + d2 = display_time.digit_to_segment[sec // 10] + d3 = display_time.digit_to_segment[sec % 10] + display_time.set_segments([d0, 0x80 + d1, d2, d3]) + +def show_temp(display_temp, temp): + + hun = display_time.digit_to_segment[temp // 100] + ten = display_time.digit_to_segment[(temp % 100) // 10] + one = display_time.digit_to_segment[(temp % 100) % 10] + F = display_time.digit_to_segment[15] + display_temp.set_segments([hun, ten, one, F]) ##### @@ -113,7 +127,15 @@ # Setup the hardware wiringPiSetupGpio() - display0 = TM1637(CLK0, DIO0, BRIGHTNESS0) + + # Dim displays in film mode + + DIM_BY=0 + if globals.CURRENT_PROFILE == globals.FILM: + DIM_BY = 2 + + display_time = TM1637(TIME_CLK, TIME_DIO, TIME_BRIGHT-DIM_BY) + display_temp = TM1637(TEMP_CLK, TEMP_DIO, TEMP_BRIGHT-DIM_BY) # Start measuring temperature @@ -136,14 +158,20 @@ if DEBUG: last = time() - # Update the display on a separate thread + # Get last known temp - display_thread = Thread(name="Timer", target=show_elapsed, args=(display0, elapsed_time)) - display_thread.start() + current_temp = globals.CURRENT_TEMP + + # Update the displays on separate threads + + update_time = Thread(name="Timer", target=show_elapsed, args=(display_time, elapsed_time)) + update_time.start() + + update_temp = Thread(name="Temp", target=show_temp, args=(display_temp, current_temp)) + update_temp.start() # For temperatures in-range, look up the compensating factor - current_temp = globals.CURRENT_TEMP if (globals.CURRENT_PROFILE == globals.REALTIME): compensation_factor = 1 # Realtime requires no compensation