Browse Source

turn off display before going to sleep

Fabian Peter Hammerle 2 years ago
parent
commit
eb3a6f17bc
1 changed files with 7 additions and 9 deletions
  1. 7 9
      vibrating_alarm_m5stickc.py

+ 7 - 9
vibrating_alarm_m5stickc.py

@@ -1,6 +1,4 @@
-"""
-tested on uiflow for stickc v1.8.1
-"""
+# tested on uiflow for stickc v1.8.1
 
 import json
 
@@ -42,12 +40,12 @@ def _get_current_daytime() -> int:
 
 
 def _sleep(duration_seconds: int) -> None:
-    # TODO turn off display
-    axp.setLcdBrightness(30)
+    # https://docs.m5stack.com/en/core/m5stickc
+    axp.setLDO2State(False)  # TFT backlight
+    axp.setLDO3State(False)  # TFT IC
     machine.lightsleep(duration_seconds * 1000)
-    # TODO turn on display
-    axp.setLcdBrightness(100)
-    print("wake reason:", machine.wake_reason())
+    axp.setLDO2State(True)  # TFT backlight
+    axp.setLDO3State(True)  # TFT IC
 
 
 def _random() -> float:  # like random.random
@@ -196,7 +194,7 @@ class App:
             _DEFAULT_FONT_COLOR,
             rotate=90,
         )
-        machine.Timer(0).init(  # TODO update in main loop
+        machine.Timer(0).init(
             period=4000,  # ms
             mode=machine.Timer.PERIODIC,
             callback=lambda t: self._clock_text_box.setText(self._format_time()),  # type: ignore