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
|
||||
|
||||
POWER_BUTTON_HOLD_TIME_IN_SECONDS = 1
|
||||
DISPLAY_UPDATE_IN_SECONDS = 2
|
||||
|
||||
BLACK = [00, 00, 00]
|
||||
RED = [64, 00, 00]
|
||||
BLUE = [00, 16, 32]
|
||||
ORANGE = [64, 16, 00]
|
||||
PINK = [64, 00, 16]
|
||||
BLACK = [0, 0, 0 ]
|
||||
RED = [64, 0, 0 ]
|
||||
BLUE = [0, 16, 32]
|
||||
ORANGE = [64, 16, 0 ]
|
||||
PINK = [64, 0, 16]
|
||||
|
||||
TEMP_COLOR = RED
|
||||
CPU_COLOR = BLUE
|
||||
|
@ -25,11 +26,13 @@ MAX_TEMP = 80
|
|||
|
||||
|
||||
class SystemStatus:
|
||||
|
||||
def __init__(self, hat):
|
||||
self.hat = hat
|
||||
self.hat.set_brightness(0.1)
|
||||
self.hat.set_rotation(270)
|
||||
self.width, self.height = self.hat.get_shape()
|
||||
self.isRunning = True
|
||||
|
||||
self.tempStartColumn = 0
|
||||
self.tempEndColumn = int(self.width / 2)
|
||||
|
@ -40,19 +43,26 @@ class SystemStatus:
|
|||
|
||||
self.clear()
|
||||
|
||||
def clear(self):
|
||||
self.hat.set_all(0, 0, 0)
|
||||
self.hat.show()
|
||||
|
||||
def terminate(self):
|
||||
self.stop()
|
||||
|
||||
for _ in range(3):
|
||||
self.clear()
|
||||
sleep(0.25)
|
||||
self.hat.set_all(128, 0, 0)
|
||||
self.hat.set_all(*RED)
|
||||
self.hat.show()
|
||||
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):
|
||||
if self.isRunning:
|
||||
self.displayTemp()
|
||||
self.displayCpu()
|
||||
self.displayNetwork()
|
||||
|
@ -109,7 +119,7 @@ class SystemStatus:
|
|||
def cleanExit(systemStatus, button):
|
||||
def exit(signum, frame):
|
||||
button.close()
|
||||
systemStatus.clear()
|
||||
systemStatus.stop()
|
||||
sys.exit(0)
|
||||
|
||||
return exit
|
||||
|
@ -132,7 +142,7 @@ def main():
|
|||
|
||||
while True:
|
||||
systemStatus.display()
|
||||
sleep(2)
|
||||
sleep(DISPLAY_UPDATE_IN_SECONDS)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue