#real time clock
import time
from machine import Pin,RTC,SoftI2C
from ds import DS1307
from aa import SSD1306_I2C
i2c=SoftI2C(sda=Pin(5),scl=Pin(4))
rtc=DS1307(i2c)#使用类ds307,命名
oled=SoftI2C(sda=Pin(12),scl=Pin(14))
dis_play=SSD1306_I2C(128,64,oled)
def rtc_fun():
#print(rtc.datetime())
return rtc.datetime()#获取当前时间,年月日时分秒
while True:
time_c=rtc_fun()
dis_play.text("current time is",0,0)
dis_play.text(str(time_c[4:7]),0,25)
dis_play.show()
time.sleep(3)
dis_play.fill(0)
time.sleep(1)
#time.sleep(0.1)