diff --git a/devtimer.py b/devtimer.py index 113d0bf..c157181 100755 --- a/devtimer.py +++ b/devtimer.py @@ -47,6 +47,7 @@ BEEP = 15 # Beep interval CALIBRATION_OFFSET = 0.003 # Compensate for program overhead in master loop +MINUS = 16 # Index of minus segment table lookup ##### @@ -121,9 +122,17 @@ d3 = display_time.digit_to_segment[sec % 10] display_time.set_segments([d0, 0x80 + d1, d2, d3]) +# Display current temperature +# Negative temps are 2 digits, positive temps are 3 digits + def show_temp(display_temp, temp): - hun = display_time.digit_to_segment[temp // 100] + if temp < 0: # The leading digit is a minus sign + hun = display_time.digit_to_segment[MINUS] + temp = abs(temp) + else: + 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] diff --git a/tm1637.py b/tm1637.py index dec9ba6..46aace5 100644 --- a/tm1637.py +++ b/tm1637.py @@ -37,7 +37,8 @@ 0b0111001, # C 0b1011110, # d 0b1111001, # E - 0b1110001 # F + 0b1110001, # F + 0b1000000, # Minus Sign ] def __init__(self, clk, dio, brightness):