|
@@ -59,9 +59,13 @@ class _AlarmConfig:
|
|
|
self._minute = (self._minute + delta) % 60
|
|
|
|
|
|
@property
|
|
|
- def daytime(self) -> int:
|
|
|
+ def _daytime(self) -> int:
|
|
|
return (self._hour * 60 + self._minute) * 60
|
|
|
|
|
|
+ @property
|
|
|
+ def seconds_until_next(self) -> int:
|
|
|
+ return (self._daytime - _get_current_daytime() - 1) % (24 * 60 * 60) + 1
|
|
|
+
|
|
|
def load(self, path: str) -> None:
|
|
|
with open(path, "r") as alarm_time_file:
|
|
|
alarm_time = json.load(alarm_time_file)
|
|
@@ -126,9 +130,7 @@ class App:
|
|
|
micropython.schedule(lambda n: self._configure_alarm_timer(), None)
|
|
|
|
|
|
def _configure_alarm_timer(self) -> None:
|
|
|
- seconds_until_alarm = (
|
|
|
- self._alarm_config.daytime - _get_current_daytime() - 1
|
|
|
- ) % (24 * 60 * 60) + 1
|
|
|
+ seconds_until_alarm = self._alarm_config.seconds_until_next
|
|
|
print("alarm in ", seconds_until_alarm / 60, " min")
|
|
|
|
|
|
self._alarm_timer.init(
|