#!/usr/bin/env python3 # devtimer.py - Temperature Controlled Photographic Darkroom Timer # Targeted for RaspberryPi # Copyright (c) 2018 TundraWare Inc. # Permission Hereby Granted For Unrestricted Personal Or Commercial Use from time import time, sleep from tm1637 import * from wiringpi import wiringPiSetupGpio wiringPiSetupGpio() BRIGHTNESS = 0x09 CLK = 21 DIO = 20 def show_elapsed(tm, elapsed): min = elapsed // 60 sec = elapsed % 60 d0 = tm.digit_to_segment[min // 10] d1 = tm.digit_to_segment[min % 10] d2 = tm.digit_to_segment[sec // 10] d3 = tm.digit_to_segment[sec % 10] tm.set_segments([d0, 0x80 + d1, d2, d3]) if __name__ == "__main__": tm = TM1637(CLK, DIO, BRIGHTNESS) start_time = int(time()) show_elapsed(tm, 0) while True: sleep(.05) show_elapsed(tm, int(time())-start_time) if int(time())-start_time == 5999: start_time = int(time())