import time, utime
from machine import Pin, time_pulse_us, I2C
import ssd1306
i2c=I2C(0, scl=Pin(21), sda=Pin(20))
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
oled.fill(0)
oled.show()
def rst_oled():
oled.fill(0)
oled.show()
now = time.localtime()
title = "{:02d}/{:02d}/{} {:02d}:{:02d}".format(now[2], now[1], now[0], now[3], now[4], now[5])
#title = "Home Info"
oled.text(title, center_txt(title), 2)
oled.show()
def center_txt(txt):
x = (oled_width - len(txt) * 8) // 2
return x
rst_oled()