Skip to content

Instantly share code, notes, and snippets.

@the6th the6th/
Last active May 22, 2018

What would you like to do?
Digital Clock on M5stack JST
# 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="", tz='JST-9')
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)
_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.