fix display dimming based on profile switch setting at boot and timer start
1 parent 5bb8e1f commit 2b63f0bf0e734fbbe365f3042b75590d4afa941d
@tundra tundra authored on 19 May 2018
Showing 1 changed file
View
13
devtimer.py
 
global OUTOFRANGE
 
minus = hun = ten = one = 0 # Tells display to show nothing
temp_led.brightness=DEFAULT_BRIGHTNESS - DIM_BY
 
if temp < 0: # The leading digit is a minus sign
minus = temp_led.digit_to_segment[MINUS]
temp = abs(temp)
# we want realtime.
 
def read_profile_switch():
 
global CURRENT_PROFILE, DIM_BY
global CURRENT_PROFILE, DIM_BY, temp_led, time_led
 
if not wiringpi.digitalRead(PROFILE_SW_FILM):
CURRENT_PROFILE = FILM
 
DIM_BY = 0
if CURRENT_PROFILE == FILM:
DIM_BY = 2
 
temp_led.brightness=DEFAULT_BRIGHTNESS - DIM_BY
time_led.brightness=DEFAULT_BRIGHTNESS - DIM_BY
 
 
if DEBUG:
print("Selected Profile: %s" % CURRENT_PROFILE)
wiringpi.pinMode(FOOTSW, wiringpi.GPIO.PUD_UP)
wiringpi.pinMode(PROFILE_SW_FILM, wiringpi.GPIO.PUD_UP)
wiringpi.pinMode(PROFILE_SW_PAPER, wiringpi.GPIO.PUD_UP)
 
# Get initial profile in case we need to dim
 
read_profile_switch()
 
time_led = TM1637(TIME_CLK, TIME_DIO, DEFAULT_BRIGHTNESS - DIM_BY)
temp_led = TM1637(TEMP_CLK, TEMP_DIO, DEFAULT_BRIGHTNESS - DIM_BY)
 
# Get initial profile in case we need to dim
 
read_profile_switch()
 
# Get segment pattern for "F" - only need to do this once, not on every update
FARENHEIGHT = temp_led.digit_to_segment[0x0f]