|
@@ -3,35 +3,31 @@ tested on uiflow for stickc v1.8.1
|
|
|
"""
|
|
|
|
|
|
|
|
|
+import json
|
|
|
+
|
|
|
import m5ui
|
|
|
import machine
|
|
|
import micropython
|
|
|
+import utils
|
|
|
from m5stack import axp, btnA, lcd
|
|
|
|
|
|
FONT = lcd.FONT_DejaVu40
|
|
|
DEFAULT_FONT_COLOR = lcd.WHITE
|
|
|
-
|
|
|
-print("battery:", axp.getBatVoltage(), "V")
|
|
|
+ALARM_TIME_PATH = "alarm.json"
|
|
|
+SCREEN_WIDTH, SCREEN_HEIGHT = lcd.winsize()
|
|
|
|
|
|
m5ui.setScreenColor(0x000000)
|
|
|
-screen_width, screen_height = lcd.winsize()
|
|
|
-
|
|
|
-clock_text_box = m5ui.M5TextBox(
|
|
|
- screen_width - 1, 0, "HH:MM", FONT, DEFAULT_FONT_COLOR, rotate=90
|
|
|
-)
|
|
|
-alarm_hour_text_box = m5ui.M5TextBox(
|
|
|
- screen_width // 2, 0, "00", FONT, DEFAULT_FONT_COLOR, rotate=90
|
|
|
-)
|
|
|
-m5ui.M5TextBox(screen_width // 2, 53, ":", FONT, DEFAULT_FONT_COLOR, rotate=90)
|
|
|
-alarm_minute_text_box = m5ui.M5TextBox(
|
|
|
- screen_width // 2, 66, "00", FONT, DEFAULT_FONT_COLOR, rotate=90
|
|
|
-)
|
|
|
+
|
|
|
+print("battery:", axp.getBatVoltage(), "V")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rtc = machine.RTC()
|
|
|
-
|
|
|
+
|
|
|
+clock_text_box = m5ui.M5TextBox(
|
|
|
+ SCREEN_WIDTH - 1, 0, "HH:MM", FONT, DEFAULT_FONT_COLOR, rotate=90
|
|
|
+)
|
|
|
clock_update_timer = machine.Timer(0)
|
|
|
clock_update_timer.init(
|
|
|
period=10000,
|
|
@@ -41,6 +37,28 @@ clock_update_timer.init(
|
|
|
),
|
|
|
)
|
|
|
|
|
|
+if not utils.exists(ALARM_TIME_PATH):
|
|
|
+ with open(ALARM_TIME_PATH, "w") as alarm_time_file:
|
|
|
+ json.dump({"hour": 0, "minute": 0}, alarm_time_file)
|
|
|
+with open(ALARM_TIME_PATH, "r") as alarm_time_file:
|
|
|
+ alarm_time = json.load(alarm_time_file)
|
|
|
+alarm_hour_text_box = m5ui.M5TextBox(
|
|
|
+ SCREEN_WIDTH // 2,
|
|
|
+ 0,
|
|
|
+ "{:02d}".format(alarm_time["hour"]),
|
|
|
+ FONT,
|
|
|
+ DEFAULT_FONT_COLOR,
|
|
|
+ rotate=90,
|
|
|
+)
|
|
|
+m5ui.M5TextBox(SCREEN_WIDTH // 2, 53, ":", FONT, DEFAULT_FONT_COLOR, rotate=90)
|
|
|
+alarm_minute_text_box = m5ui.M5TextBox(
|
|
|
+ SCREEN_WIDTH // 2,
|
|
|
+ 66,
|
|
|
+ "{:02d}".format(alarm_time["minute"]),
|
|
|
+ FONT,
|
|
|
+ DEFAULT_FONT_COLOR,
|
|
|
+ rotate=90,
|
|
|
+)
|
|
|
menu_position = 0
|
|
|
|
|
|
|