|
@@ -41,6 +41,7 @@ class App:
|
|
|
self._alarm_hour_text_box = None
|
|
|
self._alarm_minute_text_box = None
|
|
|
self._alarm_timer = None
|
|
|
+ self._battery_status_text_box = None
|
|
|
|
|
|
@property
|
|
|
def _now_time(self) -> int:
|
|
@@ -189,17 +190,33 @@ class App:
|
|
|
self._alarm_timer = machine.Timer(2)
|
|
|
self._configure_alarm_timer()
|
|
|
|
|
|
+ def _update_battery_status_info(self) -> None:
|
|
|
+ self._battery_status_text_box.setText( # type: ignore
|
|
|
+ "{:.02f}V".format(axp.getBatVoltage())
|
|
|
+ )
|
|
|
+
|
|
|
+ def _setup_battery_status_info(self) -> None:
|
|
|
+ self._battery_status_text_box = m5ui.M5TextBox(
|
|
|
+ 12,
|
|
|
+ _SCREEN_HEIGHT - 20,
|
|
|
+ "",
|
|
|
+ lcd.FONT_DejaVu18,
|
|
|
+ _DEFAULT_FONT_COLOR,
|
|
|
+ rotate=0,
|
|
|
+ )
|
|
|
+
|
|
|
def run(self) -> None:
|
|
|
m5ui.setScreenColor(0x000000) # clear screen
|
|
|
- print("battery:", axp.getBatVoltage(), "V")
|
|
|
self._setup_clock()
|
|
|
self._setup_alarm()
|
|
|
+ self._setup_battery_status_info()
|
|
|
btnA.wasPressed(self._button_a_pressed)
|
|
|
btnB.wasPressed(self._button_b_pressed)
|
|
|
# not sure whether ext0 would be better
|
|
|
esp32.wake_on_ext1([btnA.pin], esp32.WAKEUP_ALL_LOW)
|
|
|
self._reschedule_sleep(interrupt=False)
|
|
|
while True:
|
|
|
+ self._update_battery_status_info()
|
|
|
while utime.time() < self._sleep_start_time_seconds:
|
|
|
utime.sleep(1) # seconds
|
|
|
# TODO turn off display
|