Clean up code
This commit is contained in:
parent
9cca07d4db
commit
92fe576c49
|
@ -9,12 +9,19 @@ 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
|
||||||
TEMP_COLOR = [64, 0, 0]
|
|
||||||
CPU_COLOR = [0, 16, 32]
|
BLACK = [00, 00, 00]
|
||||||
NETWORK_COLOR = [64, 16, 0]
|
RED = [64, 00, 00]
|
||||||
MAX_TEMP = 80
|
BLUE = [00, 16, 32]
|
||||||
|
ORANGE = [64, 16, 00]
|
||||||
|
PINK = [64, 00, 16]
|
||||||
|
|
||||||
|
TEMP_COLOR = RED
|
||||||
|
CPU_COLOR = BLUE
|
||||||
|
NETWORK_COLOR = ORANGE
|
||||||
|
|
||||||
MIN_TEMP = 40
|
MIN_TEMP = 40
|
||||||
BLACK = [0, 0, 0]
|
MAX_TEMP = 80
|
||||||
|
|
||||||
|
|
||||||
class SystemStatus:
|
class SystemStatus:
|
||||||
|
@ -23,6 +30,7 @@ class SystemStatus:
|
||||||
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.tempStartColumn = 0
|
self.tempStartColumn = 0
|
||||||
self.tempEndColumn = int(self.width / 2)
|
self.tempEndColumn = int(self.width / 2)
|
||||||
self.cpuStartColumn = int(self.width / 2)
|
self.cpuStartColumn = int(self.width / 2)
|
||||||
|
@ -30,6 +38,20 @@ class SystemStatus:
|
||||||
self.networkStartColumn = self.width - 1
|
self.networkStartColumn = self.width - 1
|
||||||
self.networkEndColumn = self.width
|
self.networkEndColumn = self.width
|
||||||
|
|
||||||
|
self.clear()
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
self.hat.set_all(0, 0, 0)
|
||||||
|
self.hat.show()
|
||||||
|
|
||||||
|
def terminate(self):
|
||||||
|
for _ in range(3):
|
||||||
|
self.clear()
|
||||||
|
sleep(0.25)
|
||||||
|
self.hat.set_all(128, 0, 0)
|
||||||
|
self.hat.show()
|
||||||
|
sleep(0.25)
|
||||||
|
|
||||||
def display(self):
|
def display(self):
|
||||||
self.displayTemp()
|
self.displayTemp()
|
||||||
self.displayCpu()
|
self.displayCpu()
|
||||||
|
@ -83,24 +105,11 @@ class SystemStatus:
|
||||||
|
|
||||||
return min(self.height, len(remoteConnections))
|
return min(self.height, len(remoteConnections))
|
||||||
|
|
||||||
def exit(self):
|
|
||||||
self.hat.set_all(0, 0, 0)
|
|
||||||
self.hat.show()
|
|
||||||
|
|
||||||
def terminate(self):
|
|
||||||
for _ in range(3):
|
|
||||||
self.hat.set_all(0, 0, 0)
|
|
||||||
self.hat.show()
|
|
||||||
sleep(0.25)
|
|
||||||
self.hat.set_all(255, 127, 0)
|
|
||||||
self.hat.show()
|
|
||||||
sleep(0.25)
|
|
||||||
|
|
||||||
|
|
||||||
def cleanExit(systemStatus, button):
|
def cleanExit(systemStatus, button):
|
||||||
def exit(signum, frame):
|
def exit(signum, frame):
|
||||||
button.close()
|
button.close()
|
||||||
systemStatus.exit()
|
systemStatus.clear()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
return exit
|
return exit
|
||||||
|
|
Loading…
Reference in New Issue