Skip to content

Instantly share code, notes, and snippets.

@the6th the6th/clock.py
Last active May 22, 2018

Embed
What would you like to do?
Digital Clock on M5stack JST
# https://github.com/m5stack/M5Cloud/blob/master/examples/DigitalClock/clock.py
# The default timezone on M5stack is CST(+8,China)
# change timezone to JST(+9)
from m5stack import *
import time, _thread, machine
def clock():
rtc = machine.RTC()
print("Synchronize time from NTP server ...")
lcd.println("Synchronize time from NTP server ...")
rtc.ntp_sync(server="ntp.nict.jp", tz='JST-9')
lcd.clear()
lcd.setBrightness(200)
lcd.font(lcd.FONT_7seg, fixedwidth=True, dist=16, width=2)
while True:
d = time.strftime("%Y-%m-%d", time.localtime())
t = time.strftime("%H:%M:%S", time.localtime())
lcd.print(d, lcd.CENTER, 50, lcd.ORANGE)
lcd.print(t, lcd.CENTER, 130, lcd.ORANGE)
time.sleep(1)
_thread.start_new_thread('Clock', clock, ())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.