Skip to content

Commit 10b9476

Browse files
author
Ebag333
committed
Large refactor, makes code fully functional. See PR for details.
1 parent 4278f69 commit 10b9476

10 files changed

+893
-217
lines changed

config.yaml

+230
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
---
2+
config:
3+
# Configuration values to set up basic communication
4+
# Set your COM port e.g. COM3 for Windows, /dev/ttyACM0 for Linux...
5+
# COM_PORT: "/dev/ttyACM0"
6+
COM_PORT: "COM3"
7+
display:
8+
# Display size
9+
DISPLAY_WIDTH: 320
10+
DISPLAY_HEIGHT: 480
11+
12+
# Display Brightness
13+
# Set this as the desired %, 0 being completely dark and 100 being max brightness
14+
BRIGHTNESS: 10
15+
static_images:
16+
# Specify what static images we want to show on the display
17+
# You can create additional records here, the name of the entry must be unique and contain at a minimum the PATH.
18+
# Images are drawn in the order they are listed below, the top image will be drawn first (so places images back to front)
19+
# IMAGE_NAME:
20+
# PATH:
21+
# X:
22+
# Y:
23+
# WIDTH:
24+
# HEIGHT:
25+
BACKGROUND:
26+
# PATH: res/backgrounds/600px_solid_Black.png
27+
PATH: res/themes/Terminal_theme_background.png
28+
X: 0
29+
Y: 0
30+
WIDTH: 320
31+
HEIGHT: 480
32+
static_text:
33+
# Specify what static text we want to show on the display
34+
# You can create additional records here, the name of the entry must be unique and contain at a minimum the PATH.
35+
# Text are drawn in the order they are listed below, the top text will be drawn first (so places text back to front)
36+
# IMAGE_NAME:
37+
# TEXT:
38+
# X:
39+
# Y:
40+
# FONT:
41+
# FONT_SIZE:
42+
# FONT_COLOR: 0, 0, 0
43+
# BACKGROUND_COLOR=255, 255, 255
44+
# BACKGROUND_IMAGE
45+
BASICTEXT:
46+
TEXT: Basic text
47+
X: 50
48+
Y: 100
49+
CUSTOMITALICTEXTSOLIDBACKGROUND:
50+
TEXT: Custom italic text
51+
X: 5
52+
Y: 150
53+
FONT: roboto/Roboto-Italic.ttf
54+
FONT_SIZE: 30
55+
FONT_COLOR: 0, 0, 255
56+
BACKGROUND_COLOR: 255, 255, 0
57+
CUSTOMTEXTTRANSPARENTBACKGROUND:
58+
TEXT: Transparent bold text
59+
X: 5
60+
Y: 300
61+
FONT: geforce/GeForce-Bold.ttf
62+
FONT_SIZE: 30
63+
FONT_COLOR: 255, 255, 255
64+
BACKGROUND_IMAGE: res/example.png
65+
TEXTOVERFLOWS:
66+
TEXT: Text overflow!
67+
X: 5
68+
Y: 430
69+
FONT: roboto/Roboto-Bold.ttf
70+
FONT_SIZE: 60
71+
FONT_COLOR: 255, 255, 255
72+
BACKGROUND_IMAGE: res/example.png
73+
STATS:
74+
CPU:
75+
PERCENTAGE:
76+
# In seconds. Longer intervals cause this to refresh more slowly.
77+
# Setting to lower values will display near real time data,
78+
# but may cause significant CPU usage or the display not to update properly
79+
INTERVAL: 1
80+
TEXT:
81+
SHOW: False
82+
X: 100
83+
Y: 20
84+
FONT: roboto/Roboto-Bold.ttf
85+
FONT_SIZE: 20
86+
FONT_COLOR: 255, 255, 255
87+
# BACKGROUND_COLOR: 0, 0, 0
88+
BACKGROUND_IMAGE: res/backgrounds/600px_solid_Black.png
89+
GRAPH:
90+
SHOW: True
91+
X: 115
92+
Y: 71
93+
WIDTH: 178
94+
HEIGHT: 13
95+
MIN_VALUE: 0
96+
MAX_VALUE: 100
97+
BAR_COLOR: 255, 0, 0
98+
BAR_OUTLINE: False
99+
BACKGROUND_COLOR: 0, 0, 0
100+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
101+
FREQUENCY:
102+
# In seconds. Longer intervals cause this to refresh more slowly.
103+
# Setting to lower values will display near real time data,
104+
# but may cause significant CPU usage or the display not to update properly
105+
INTERVAL: 5
106+
TEXT:
107+
SHOW: True
108+
X: 100
109+
Y: 87
110+
FONT: roboto/Roboto-Bold.ttf
111+
FONT_SIZE: 13
112+
FONT_COLOR: 200, 200, 200
113+
BACKGROUND_COLOR: 50, 50, 50
114+
LOAD:
115+
# In seconds. Longer intervals cause this to refresh more slowly.
116+
# Setting to lower values will display near real time data,
117+
# but may cause significant CPU usage or the display not to update properly
118+
INTERVAL: 5
119+
ONE:
120+
TEXT:
121+
SHOW: True
122+
X: 110
123+
Y: 106
124+
FONT: roboto/Roboto-Bold.ttf
125+
FONT_SIZE: 13
126+
FONT_COLOR: 200, 200, 200
127+
BACKGROUND_COLOR: 50, 50, 50
128+
FIVE:
129+
TEXT:
130+
SHOW: TRUE
131+
X: 183
132+
Y: 106
133+
FONT: roboto/Roboto-Bold.ttf
134+
FONT_SIZE: 13
135+
FONT_COLOR: 200, 200, 200
136+
BACKGROUND_COLOR: 50, 50, 50
137+
FIFTEEN:
138+
TEXT:
139+
SHOW: TRUE
140+
X: 265
141+
Y: 106
142+
FONT: roboto/Roboto-Bold.ttf
143+
FONT_SIZE: 13
144+
FONT_COLOR: 200, 200, 200
145+
BACKGROUND_COLOR: 50, 50, 50
146+
GPU:
147+
# In seconds. Longer intervals cause this to refresh more slowly.
148+
# Setting to lower values will display near real time data,
149+
# but may cause significant CPU usage or the display not to update properly
150+
INTERVAL: 1
151+
PERCENTAGE:
152+
GRAPH:
153+
SHOW: True
154+
X: 115
155+
Y: 197
156+
WIDTH: 178
157+
HEIGHT: 13
158+
MIN_VALUE: 0
159+
MAX_VALUE: 100
160+
BAR_COLOR: 255, 0, 0
161+
BAR_OUTLINE: False
162+
BACKGROUND_COLOR: 0, 0, 0
163+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
164+
MEMORY:
165+
GRAPH:
166+
SHOW: True
167+
X: 115
168+
Y: 215
169+
WIDTH: 178
170+
HEIGHT: 13
171+
MIN_VALUE: 0
172+
MAX_VALUE: 100
173+
BAR_COLOR: 255, 0, 0
174+
BAR_OUTLINE: False
175+
BACKGROUND_COLOR: 0, 0, 0
176+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
177+
TEMPERATURE:
178+
TEXT:
179+
SHOW: TRUE
180+
X: 115
181+
Y: 231
182+
FONT: roboto/Roboto-Bold.ttf
183+
FONT_SIZE: 13
184+
FONT_COLOR: 200, 200, 200
185+
BACKGROUND_COLOR: 50, 50, 50
186+
MEMORY:
187+
# In seconds. Longer intervals cause this to refresh more slowly.
188+
# Setting to lower values will display near real time data,
189+
# but may cause significant CPU usage or the display not to update properly
190+
INTERVAL: 5
191+
SWAP:
192+
GRAPH:
193+
SHOW: True
194+
X: 115
195+
Y: 285
196+
WIDTH: 178
197+
HEIGHT: 13
198+
MIN_VALUE: 0
199+
MAX_VALUE: 100
200+
BAR_COLOR: 255, 0, 0
201+
BAR_OUTLINE: False
202+
BACKGROUND_COLOR: 0, 0, 0
203+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
204+
VIRTUAL:
205+
GRAPH:
206+
SHOW: True
207+
X: 115
208+
Y: 303
209+
WIDTH: 178
210+
HEIGHT: 13
211+
MIN_VALUE: 0
212+
MAX_VALUE: 100
213+
BAR_COLOR: 255, 0, 0
214+
BAR_OUTLINE: False
215+
BACKGROUND_COLOR: 0, 0, 0
216+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png
217+
DISK:
218+
INTERVAL: 10
219+
GRAPH:
220+
SHOW: True
221+
X: 115
222+
Y: 357
223+
WIDTH: 178
224+
HEIGHT: 13
225+
MIN_VALUE: 0
226+
MAX_VALUE: 100
227+
BAR_COLOR: 255, 0, 0
228+
BAR_OUTLINE: False
229+
BACKGROUND_COLOR: 0, 0, 0
230+
# BACKGROUND_IMAGE: res/progressbars/320px-Green_Progress_bar_100.png

library/config.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import logging
2+
3+
import yaml
4+
import os
5+
import sys
6+
import serial
7+
import queue
8+
9+
10+
def load_yaml(configfile):
11+
if not os.path.exists(configfile):
12+
logging.critical("No YAML file found")
13+
exit()
14+
15+
with open(configfile, "r") as stream:
16+
try:
17+
yamlconfig = yaml.safe_load(stream)
18+
except yaml.YAMLError:
19+
logging.critical("Failed loading YAML configuration file")
20+
exit()
21+
22+
return yamlconfig
23+
24+
25+
PATH = sys.path[0]
26+
CONFIG_DATA = load_yaml("config.yaml")
27+
lcd_comm = serial.Serial(CONFIG_DATA["config"]["COM_PORT"], 115200, timeout=1, rtscts=1)
28+
update_queue = queue.Queue()

0 commit comments

Comments
 (0)