forked from mathoudebine/turing-smart-screen-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
62 lines (47 loc) · 1.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python3
# A simple Python manager for "Turing Smart Screen" 3.5" IPS USB-C display
# https://github.com/mathoudebine/turing-smart-screen-python
import os
import signal
import sys
import library.scheduler as scheduler
from library import config
from library.static_display import StaticDisplay
CONFIG_DATA = config.CONFIG_DATA
stop = False
if __name__ == "__main__":
def sighandler(signum, frame):
global stop
stop = True
try:
# Set the signal handlers, to send a complete frame to the LCD before exit
signal.signal(signal.SIGINT, sighandler)
signal.signal(signal.SIGTERM, sighandler)
is_posix = os.name == 'posix'
if is_posix:
signal.signal(signal.SIGQUIT, sighandler)
# Initialize the display
StaticDisplay.initialize_display()
# Create all static images
StaticDisplay.display_static_images()
# Overlay Static Text
# StaticDisplay.display_static_text()
# Run our jobs that update data
import library.stats as stats
# while True:
# stats.CPU.percentage()
scheduler.CPUPercentage()
scheduler.CPUFrequency()
scheduler.CPULoad()
scheduler.GPUStats()
scheduler.MemoryStats()
scheduler.DiskStats()
scheduler.QueueHandler()
except KeyboardInterrupt:
print('Keyboard interrupt received from user')
# Close communication with the screen
config.lcd_comm.close()
try:
sys.exit(0)
except:
os._exit(0)