import time
import ds1307
from machine import SoftI2C, Pin
from tm1637 import TM1637


time.sleep(0.1) # Wait for USB to become ready

clock = SoftI2C(sda=Pin(0),scl=Pin(1), freq = 100000)
rtc = ds1307.DS1307(clock, 0x68)

display = TM1637(clk=Pin(17),dio=Pin(16))
set_mode = False
set_pin = Pin(15,Pin.IN)
led = Pin(28,Pin.OUT)
hour_inc = Pin(14,Pin.OUT)
hour = 0

# year = int(input("Year : "))
# month = int(input("month (Jan --> 1 , Dec --> 12): "))
# date = int(input("date : "))
# day = int(input("day (1 --> monday , 2 --> Tuesday ... 0 --> Sunday): "))
# hour = int(input("hour (24 Hour format): "))
# minute = int(input("minute : "))
# second = int(input("second : "))
# now = (year,month,date,day,hour,minute,second,0)
# rtc.datetime(now)

# print(rtc.datetime)

while True:
    if set_pin.value() == 1:
        set_mode = not set_mode
        time.sleep(0.5)
    # print(set_mode)
    if set_mode:
        hour = rtc.datetime[3]
        led.on()
        display.numbers(rtc.datetime[3],rtc.datetime[4],colon=True)
        if hour_inc.value():
            hour += 1
            
    else:
        led.off()
        display.numbers(rtc.datetime[3],rtc.datetime[4],colon=True)
        time.sleep(0.5)
        display.numbers(rtc.datetime[3],rtc.datetime[4],colon=False)
        time.sleep(0.5)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
GND5VSDASCLSQWRTCDS1307+
4-Digit Display