ソースを参照

refactor: rename class and variable

Fabian Peter Hammerle 3 年 前
コミット
4a667cacb8
1 ファイル変更13 行追加13 行削除
  1. 13 13
      vibrating_alarm_m5stickc.py

+ 13 - 13
vibrating_alarm_m5stickc.py

@@ -39,7 +39,7 @@ def _get_current_daytime() -> int:
     return (hour * 60 + minute) * 60 + seconds
 
 
-class _AlarmTime:
+class _AlarmConfig:
     def __init__(self):
         self._hour = 0
         self._minute = 0
@@ -83,7 +83,7 @@ class App:
         self._menu_position = 0
         self._wait_for_sleep_start_time_update = False
         self._sleep_start_time_seconds = 0.0
-        self._alarm_time = _AlarmTime()
+        self._alarm_config = _AlarmConfig()
         self._alarm_hour_text_box = None
         self._alarm_minute_text_box = None
         self._alarm_timer = None
@@ -127,7 +127,7 @@ class App:
 
     def _configure_alarm_timer(self) -> None:
         seconds_until_alarm = (
-            self._alarm_time.daytime - _get_current_daytime() - 1
+            self._alarm_config.daytime - _get_current_daytime() - 1
         ) % (24 * 60 * 60) + 1
         print("alarm in ", seconds_until_alarm / 60, " min")
         # TODO configure wake from sleep
@@ -140,24 +140,24 @@ class App:
     def _update_alarm_time(self, event_arg: None) -> None:
         # pylint: disable=unused-argument; callback
         self._alarm_hour_text_box.setText(  # type: ignore
-            "{:02d}".format(self._alarm_time.hour)
+            "{:02d}".format(self._alarm_config.hour)
         )
         self._alarm_minute_text_box.setText(  # type: ignore
-            "{:02d}".format(self._alarm_time.minute)
+            "{:02d}".format(self._alarm_config.minute)
         )
-        self._alarm_time.save(_ALARM_TIME_PATH)
+        self._alarm_config.save(_ALARM_TIME_PATH)
         self._configure_alarm_timer()
 
     def _button_b_pressed(self) -> None:
         self._reschedule_sleep(interrupt=True)
         if self._menu_position == 1:
-            self._alarm_time.shift_hour(1)
+            self._alarm_config.shift_hour(1)
         elif self._menu_position == 2:
-            self._alarm_time.shift_hour(-1)
+            self._alarm_config.shift_hour(-1)
         elif self._menu_position == 3:
-            self._alarm_time.shift_minute(1)
+            self._alarm_config.shift_minute(1)
         elif self._menu_position == 4:
-            self._alarm_time.shift_minute(-1)
+            self._alarm_config.shift_minute(-1)
         micropython.schedule(self._update_alarm_time, None)
 
     @staticmethod
@@ -182,11 +182,11 @@ class App:
 
     def _setup_alarm(self) -> None:
         if utils.exists(_ALARM_TIME_PATH):
-            self._alarm_time.load(_ALARM_TIME_PATH)
+            self._alarm_config.load(_ALARM_TIME_PATH)
         self._alarm_hour_text_box = m5ui.M5TextBox(
             _SCREEN_WIDTH // 2,
             _LEFT_PADDING,
-            "{:02d}".format(self._alarm_time.hour),
+            "{:02d}".format(self._alarm_config.hour),
             _LARGE_FONT,
             _DEFAULT_FONT_COLOR,
             rotate=90,
@@ -202,7 +202,7 @@ class App:
         self._alarm_minute_text_box = m5ui.M5TextBox(
             _SCREEN_WIDTH // 2,
             _LEFT_PADDING + 66,
-            "{:02d}".format(self._alarm_time.minute),
+            "{:02d}".format(self._alarm_config.minute),
             _LARGE_FONT,
             _DEFAULT_FONT_COLOR,
             rotate=90,