|
@@ -12,7 +12,7 @@ print("battery:", axp.getBatVoltage(), "V")
|
|
|
m5ui.setScreenColor(0x000000) # clear screen
|
|
|
screen_width, screen_height = lcd.winsize()
|
|
|
# https://github.com/m5stack/UIFlow-Code/wiki/M5UI#textbox
|
|
|
-time_text_box = m5ui.M5TextBox(
|
|
|
+clock_text_box = m5ui.M5TextBox(
|
|
|
screen_width - 1, 0, "HH:MM", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=90
|
|
|
)
|
|
|
|
|
@@ -20,4 +20,13 @@ time_text_box = m5ui.M5TextBox(
|
|
|
# > to set RTC, use particular tuple (year , month, day, week=0, hour, minute, second, timestamp=0)
|
|
|
# https://community.m5stack.com/topic/3108/m5stack-core2-micropython-rtc-example
|
|
|
rtc = machine.RTC()
|
|
|
-time_text_box.setText("{}:{}".format(*rtc.datetime()[4:6]))
|
|
|
+
|
|
|
+clock_update_timer = machine.Timer(0)
|
|
|
+clock_update_timer.init(
|
|
|
+ period=10000, # ms
|
|
|
+ mode=machine.Timer.PERIODIC,
|
|
|
+ callback=lambda t: clock_text_box.setText("{}:{}".format(*rtc.datetime()[4:6])),
|
|
|
+)
|
|
|
+
|
|
|
+# TODO https://docs.micropython.org/en/latest/library/machine.WDT.html#machine-wdt
|
|
|
+# TODO https://docs.micropython.org/en/latest/esp8266/tutorial/powerctrl.html#deep-sleep-mode
|