System Status [main]

Add power button function

=> 2a810ce1ec78fea4d2fbe7eddbcc3c638f895663

diff --git a/system-status.py b/system-status.py
index 50b17fa..6163a87 100644
--- a/system-status.py
+++ b/system-status.py
@@ -1 +1,46 @@
+from gpiozero import Button
+from signal import pause
+from subprocess import check_call
+from time import sleep
 from unicornhatmini import UnicornHATMini
+
+POWER_BUTTON_GPIO_PIN = 5
+HOLD_TIME_IN_SECONDS = 1
+
+
+class SystemStatus:
+    def __init__(self, hat):
+        self.hat = hat
+        self.hat.set_brightness(0.1)
+
+    def display(self):
+        self.hat.set(0, 0, 0, 0, 50)
+        self.hat.show()
+
+    def terminate(self):
+        self.hat.set_all(10, 0, 0)
+        self.hat.show()
+        sleep(0.25)
+        self.hat.set_all(0, 0, 0)
+        self.hat.show()
+        sleep(0.25)
+        self.hat.set_all(10, 0, 0)
+        self.hat.show()
+
+
+def poweroff(systemStatus):
+    systemStatus.terminate()
+    sleep(1)
+    check_call(['sudo', 'poweroff'])
+
+
+def main():
+    systemStatus = SystemStatus(UnicornHATMini())
+    powerButton = Button(POWER_BUTTON_GPIO_PIN, hold_time=HOLD_TIME_IN_SECONDS)
+    powerButton.when_held = poweroff(systemStatus)
+    powerButton.display()
+    pause()
+
+
+if __name__ == '__main__':
+    main()
Proxy Information
Original URL
gemini://git.cifelli.xyz/system-status/main/cdiff/2a810ce1ec78fea4d2fbe7eddbcc3c638f895663
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
457.5067 milliseconds
Gemini-to-HTML Time
0.244483 milliseconds

This content has been proxied by September (3851b).