Code: Select all
from machine import Pin, I2C
import SSD1306
from time import sleep
from machine import RTC
i2c = I2C(-1, scl=Pin(22), sda=Pin(21), freq=10000)
oled_width = 128
oled_height = 64
oled = SSD1306.SSD1306_I2C(oled_width, oled_height, i2c)
rtc = RTC()
rtc.datetime((2021, 2, 10, 3, 11, 30, 0, 0))
isPoint = True
t = rtc.datetime()
oled.fill(0)
oled.text('{}-{:02d}-{:02d}' .format(t[0],t[1],t[2]),0, 0)
if isPoint:
colon = ':'
else:
colon = ' '
oled.text(' {:02d}{}{:02d}' .format(t[4], colon, t[5]), 80, 0)
oled.show()
isPoint = not isPoint