# Authored by Jonathan Scott James the great On WOKWI
t=9999999999999;t=3600*24*22-9 # python sets the precision level when you first assign the number according to what will fit in the value you assign it to.
def tickjsj():
global t
t=t+1
machine.Timer().init(period=1000, callback=lambda t:tickjsj())
nn=9999999999999;m=nn;x=nn;d=nn;s=nn;nn=nn-9999999999999;b2b=0;d=12;k=0;b=0;kk=0;bb=0;cycles=0;sevenSeg="1111110011000011011011111001011001110110111011111111000011111111111011";
tt=" "
machine.Pin(1, machine.Pin.OUT) #clk pin
machine.Pin(2, machine.Pin.OUT) #data pin
machine.Pin(3, machine.Pin.OUT) #latch pin
machine.Pin(27, machine.Pin.IN) # key 1 k2k<b2b key in pin
machine.Pin(28, machine.Pin.IN) # key 1 k<b key in pin
while 1:
s=str(int(((t/60)-(t//60))*60));m=str(int((t/3600-t//3600)*60));h=str(int((t/(86400)-t//(86400))*24));d=str(t//(86400));w=(t//(86400)) # Extrapolate seconds hours minutes and days from raw uptime seconds
tt=("00"+h)[-2:]+("00"+m)[-2:]+("00"+s)[-2:]+("00"+d)[-2:]+"77" # compile the output buffer
for nn in range(7,-1,-1): #digit 0-7 total of 8 not including the decimal point must start at zero because the first character in a string is position number 0 in python or mpython
machine.Pin(1).value(1) # high dummy clock pulse for 8th bit unassigned
machine.Pin(1).value(0) # low dummy clock pulse for 8th bit unassigned
for n in range(6,-1,-1): #segment 0-6 total of 7 not including the decimal point must start at zero because the first character in a string is position number 0 in python or mpython
machine.Pin(2).value(int(sevenSeg[int(tt[nn])*7+n])) # set the data pin to the data bit value
machine.Pin(1).value(1)# clock high transition the data into the shifter
machine.Pin(1).value(0)# clock high transition the data into the shifter
machine.Pin(3).value(0) # low latched the data into the display
machine.Pin(3).value(1) # high latched the data into the display