Skip to content

Instantly share code, notes, and snippets.

@boochow
Created May 30, 2018 15:03
Show Gist options
  • Save boochow/d0ef98451e9ddcdac60eaf30209e8af0 to your computer and use it in GitHub Desktop.
Save boochow/d0ef98451e9ddcdac60eaf30209e8af0 to your computer and use it in GitHub Desktop.
from machine import Timer,I2C
i2c = I2C(1)
i2c.init()
d = SSD1306_I2C(128,64,i2c)
c = DS3231(i2c)
c.write([2018, 5, 30, 23, 30, 45, 3])
day = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
def update_timer(t):
d.fill(0)
date = c.read()
d.text("/".join(map(str, date[0:3])), 16, 8, 1)
d.text(day[date[6]], 100, 8, 1)
d.text(":".join(map(str, date[3:6])), 32, 24, 1)
d.text(str(c.temperature()) + '`C', 24, 48, 1)
d.show()
t = Timer(1)
t.init(mode=t.PERIODIC, period=1000000, callback=update_timer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment