from machine import Pin, I2C
import utime as time
from ds1307 import DS1307
from l2c_lcd import I2cLcd

i2c = I2C(id=0,scl=Pin(1),sda=Pin(0),freq=100000)
lcd = I2cLcd(i2c, 0x27, 2, 16)

i2c_rtc = I2C(0, scl = Pin(1), sda = Pin(0),freq = 400000)
rtc = DS1307(i2c_rtc,0x68)

while True:
    (Y,M,D,day,hr,m,s,p1) = rtc.datetime()
    if s < 10:
        s = "0" + str(s)
    if m < 10:
        m = "0" + str(m)
    if hr < 10:
        hr = "0" + str(hr)
    if D < 10:
        D = "0" + str(D)
    if D < 10:
        M = "0" + str(M)
    tim = str(hr) + ":" + str(m) + ":" + str(s)
    print(tim)
    lcd.move_to(0,1)
    lcd.putstr(tim)
    time.sleep(1)

# from machine import Pin, I2C
# import utime as time
# from ds1307 import DS1307
# from l2c_lcd import I2cLcd

# i2c = I2C(id=0, scl=Pin(1), sda=Pin(0), freq=100000)
# lcd = I2cLcd(i2c, 0x27, 2, 16)

# i2c_rtc = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000)
# rtc = DS1307(i2c_rtc, 0x68)

# display_string = ""
# max_length = 16

# while True:
#     if len(display_string) < max_length:
#         display_string += hex(len(display_string))[2:].upper()
#         lcd.move_to(0, 0)
#         lcd.putstr(display_string)
#         time.sleep(0.2)  # wait 1 second before adding the next symbol
    
#     if len(display_string) == max_length:
#         for i in range(max_length):
#             lcd.move_to(0, 0)
#             lcd.putstr(" " * (i + 1) + display_string[i:])  # clear one symbol at a time
#             time.sleep(1)  # wait 1 second before clearing the next symbol
#         display_string = ""

# from machine import Pin, I2C
# import utime as time
# from ds1307 import DS1307
# from l2c_lcd import I2cLcd

# i2c = I2C(id=0, scl=Pin(1), sda=Pin(0), freq=100000)
# lcd = I2cLcd(i2c, 0x27, 2, 16)

# i2c_rtc = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000)
# rtc = DS1307(i2c_rtc, 0x68)

# name = "Korzhova Dasha"
# max_length = 16

# lcd.move_to(0, 0)
# lcd.putstr(name)

# time.sleep(3)

# for i in range(max_length - len(name) + 1):
#     lcd.move_to(0, 0)
#     lcd.putstr(" " * max_length)
#     lcd.move_to(i, 0)  
#     lcd.putstr(name)  
#     time.sleep(0.5)  

# lcd.clear()
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT
GND5VSDASCLSQWRTCDS1307+