Clean up shutdown display
This commit is contained in:
parent
92fe576c49
commit
eb12d4444a
|
@ -9,12 +9,13 @@ from time import sleep
|
||||||
from unicornhatmini import UnicornHATMini, BUTTON_A
|
from unicornhatmini import UnicornHATMini, BUTTON_A
|
||||||
|
|
||||||
POWER_BUTTON_HOLD_TIME_IN_SECONDS = 1
|
POWER_BUTTON_HOLD_TIME_IN_SECONDS = 1
|
||||||
|
DISPLAY_UPDATE_IN_SECONDS = 2
|
||||||
|
|
||||||
BLACK = [00, 00, 00]
|
BLACK = [0, 0, 0 ]
|
||||||
RED = [64, 00, 00]
|
RED = [64, 0, 0 ]
|
||||||
BLUE = [00, 16, 32]
|
BLUE = [0, 16, 32]
|
||||||
ORANGE = [64, 16, 00]
|
ORANGE = [64, 16, 0 ]
|
||||||
PINK = [64, 00, 16]
|
PINK = [64, 0, 16]
|
||||||
|
|
||||||
TEMP_COLOR = RED
|
TEMP_COLOR = RED
|
||||||
CPU_COLOR = BLUE
|
CPU_COLOR = BLUE
|
||||||
|
@ -25,11 +26,13 @@ MAX_TEMP = 80
|
||||||
|
|
||||||
|
|
||||||
class SystemStatus:
|
class SystemStatus:
|
||||||
|
|
||||||
def __init__(self, hat):
|
def __init__(self, hat):
|
||||||
self.hat = hat
|
self.hat = hat
|
||||||
self.hat.set_brightness(0.1)
|
self.hat.set_brightness(0.1)
|
||||||
self.hat.set_rotation(270)
|
self.hat.set_rotation(270)
|
||||||
self.width, self.height = self.hat.get_shape()
|
self.width, self.height = self.hat.get_shape()
|
||||||
|
self.isRunning = True
|
||||||
|
|
||||||
self.tempStartColumn = 0
|
self.tempStartColumn = 0
|
||||||
self.tempEndColumn = int(self.width / 2)
|
self.tempEndColumn = int(self.width / 2)
|
||||||
|
@ -40,23 +43,30 @@ class SystemStatus:
|
||||||
|
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
def clear(self):
|
|
||||||
self.hat.set_all(0, 0, 0)
|
|
||||||
self.hat.show()
|
|
||||||
|
|
||||||
def terminate(self):
|
def terminate(self):
|
||||||
|
self.stop()
|
||||||
|
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
self.clear()
|
|
||||||
sleep(0.25)
|
sleep(0.25)
|
||||||
self.hat.set_all(128, 0, 0)
|
self.hat.set_all(*RED)
|
||||||
self.hat.show()
|
self.hat.show()
|
||||||
sleep(0.25)
|
sleep(0.25)
|
||||||
|
self.clear()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.isRunning = False
|
||||||
|
self.clear()
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self.hat.set_all(*BLACK)
|
||||||
|
self.hat.show()
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
self.displayTemp()
|
if self.isRunning:
|
||||||
self.displayCpu()
|
self.displayTemp()
|
||||||
self.displayNetwork()
|
self.displayCpu()
|
||||||
self.hat.show()
|
self.displayNetwork()
|
||||||
|
self.hat.show()
|
||||||
|
|
||||||
def displayTemp(self):
|
def displayTemp(self):
|
||||||
self.displayField(
|
self.displayField(
|
||||||
|
@ -109,7 +119,7 @@ class SystemStatus:
|
||||||
def cleanExit(systemStatus, button):
|
def cleanExit(systemStatus, button):
|
||||||
def exit(signum, frame):
|
def exit(signum, frame):
|
||||||
button.close()
|
button.close()
|
||||||
systemStatus.clear()
|
systemStatus.stop()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
return exit
|
return exit
|
||||||
|
@ -132,7 +142,7 @@ def main():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
systemStatus.display()
|
systemStatus.display()
|
||||||
sleep(2)
|
sleep(DISPLAY_UPDATE_IN_SECONDS)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue