from machine import Pin, I2C
from sh1106 import SH1106_I2C
import freesans20
from machine import RTC
from time import sleep_ms
from Writer_minimal import Writer
#import ssd1306
# ESP32 Pin assignment
i2c = I2C(0, scl=Pin(22), sda=Pin(21), freq=400000)
oled = SH1106_I2C(128, 64, i2c, None, addr=0x3c)
font_writer = Writer(oled, freesans20)
#oled_width = 128
#oled_height = 64
#oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
rtc = RTC()
rtc.datetime((2024, 1, 10, 9, 00, 0, 0))
isPoint = true
while True:
t = rtc.datetime()
oled.fill(0)
oled.text('** 1.3 OLED **', 4, 0)
oled.text('Date: {}-{:02d}-{:02d}' .format(t[0],t[1],t[2]), 0,25)
if isPoint:
colon = ':'
else:
colon = ' '
oled.text('Time: {:02d}-{:02d}' .format(t[4], colon, t[5]), 0, 40)
oled.show()
sleep_ms(500)
# isPoint = not isPoint
#oled.text('ooo!', 10, 10)
#oled.show()