瀏覽代碼

show time on lcd (no updates yet)

Fabian Peter Hammerle 2 年之前
當前提交
f15ea9ff58
共有 1 個文件被更改,包括 23 次插入0 次删除
  1. 23 0
      vibrating_alarm_m5stickc.py

+ 23 - 0
vibrating_alarm_m5stickc.py

@@ -0,0 +1,23 @@
+"""
+tested on uiflow for stickc v1.8.1
+"""
+
+# pylint: disable=import-error
+import m5ui
+import machine
+from m5stack import lcd, axp
+
+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(
+    screen_width - 1, 0, "HH:MM", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=90
+)
+
+# > [contradictory to] official micropython documentation,
+# > 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]))