Skip to content

Commit b07004b

Browse files
committed
Adding the ability to crop radials.
1 parent 2a25630 commit b07004b

File tree

6 files changed

+306
-6
lines changed

6 files changed

+306
-6
lines changed

library/lcd/lcd_comm.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ def DisplayRadialProgressBar(self, xc: int, yc: int, radius: int, bar_width: int
436436
font_color: Tuple[int, int, int] = (0, 0, 0),
437437
bar_color: Tuple[int, int, int] = (0, 0, 0),
438438
background_color: Tuple[int, int, int] = (255, 255, 255),
439-
background_image: str = None):
439+
background_image: str = None,
440+
custom_bbox: Tuple[int, int, int, int] = (0, 0, 0, 0),
441+
text_offset: Tuple[int, int] = (0,0)):
440442
# Generate a radial progress bar and display it
441443
# Provide the background image path to display progress bar with transparent background
442444

@@ -568,10 +570,14 @@ def DisplayRadialProgressBar(self, xc: int, yc: int, radius: int, bar_width: int
568570
font = ImageFont.truetype("./res/fonts/" + font, font_size)
569571
left, top, right, bottom = font.getbbox(text)
570572
w, h = right - left, bottom - top
571-
draw.text((radius - w / 2, radius - top - h / 2), text,
573+
draw.text((radius - w / 2 + text_offset[0], radius - top - h / 2 + text_offset[1]), text,
572574
font=font, fill=font_color)
573575

574-
self.DisplayPILImage(bar_image, xc - radius, yc - radius)
576+
if custom_bbox[0] != 0 or custom_bbox[1] != 0 or custom_bbox[2] != 0 or custom_bbox[3] != 0:
577+
bar_image = bar_image.crop(box=custom_bbox)
578+
579+
self.DisplayPILImage(bar_image, xc - radius + custom_bbox[0], yc - radius + custom_bbox[1])
580+
# self.DisplayPILImage(bar_image, xc - radius, yc - radius)
575581

576582
# Load image from the filesystem, or get from the cache if it has already been loaded previously
577583
def open_image(self, bitmap_path: str) -> Image:

library/stats.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ def display_themed_radial_bar(theme_data, value, min_size=0, unit='', custom_tex
177177
font_size=theme_data.get("FONT_SIZE", 10),
178178
font_color=theme_data.get("FONT_COLOR", (0, 0, 0)),
179179
background_color=theme_data.get("BACKGROUND_COLOR", (0, 0, 0)),
180-
background_image=get_theme_file_path(theme_data.get("BACKGROUND_IMAGE", None))
180+
background_image=get_theme_file_path(theme_data.get("BACKGROUND_IMAGE", None)),
181+
custom_bbox=theme_data.get("CUSTOM_BBOX", (0, 0, 0, 0)),
182+
text_offset=theme_data.get("TEXT_OFFSET", (0, 0))
181183
)
182184

183185

@@ -313,8 +315,8 @@ def temperature(cls):
313315
cpu_temp_line_graph_data['SHOW'] = False
314316

315317
display_themed_temperature_value(cpu_temp_text_data, temperature)
316-
display_themed_progress_bar(cpu_temp_radial_data, temperature)
317-
display_themed_temperature_radial_bar(cpu_temp_graph_data, temperature)
318+
display_themed_progress_bar(cpu_temp_graph_data, temperature)
319+
display_themed_temperature_radial_bar(cpu_temp_radial_data, temperature)
318320
display_themed_line_graph(cpu_temp_line_graph_data, cls.last_values_cpu_temperature)
319321

320322
@classmethod
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Credits for graphical resources used from freepik
2+
3+
Acknowledgements for resources :
4+
1.35 KB
Loading
7.93 KB
Loading
Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
author: "@hicwic"
2+
3+
display:
4+
# Specify the display size in inch for this theme: 3.5" (default) or 5"
5+
DISPLAY_SIZE: 3.5"
6+
7+
# Specify the display orientation for this theme: portrait or landscape (reverse orientation is managed in config.yaml)
8+
DISPLAY_ORIENTATION: landscape
9+
10+
# Backplate RGB LED color (for HW revision 'flagship' devices only), set one that match your theme dominant color
11+
DISPLAY_RGB_LED: 255, 0, 0
12+
13+
static_images:
14+
BACKGROUND:
15+
PATH: background.png
16+
X: 0
17+
Y: 0
18+
WIDTH: 480
19+
HEIGHT: 320
20+
21+
22+
23+
24+
STATS:
25+
CPU:
26+
PERCENTAGE:
27+
INTERVAL: 1
28+
RADIAL:
29+
SHOW: True
30+
X: 120
31+
Y: 100
32+
RADIUS: 80
33+
WIDTH: 15
34+
MIN_VALUE: 0
35+
MAX_VALUE: 100
36+
ANGLE_START: 100
37+
ANGLE_END: 260
38+
ANGLE_STEPS: 10
39+
ANGLE_SEP: 5
40+
CLOCKWISE: True
41+
BAR_COLOR: 0, 250, 0
42+
SHOW_TEXT: True
43+
SHOW_UNIT: True
44+
FONT: roboto/Roboto-Bold.ttf
45+
FONT_SIZE: 20
46+
FONT_COLOR: 0, 250, 0
47+
#BACKGROUND_COLOR: 200, 200, 200
48+
BACKGROUND_IMAGE: background.png
49+
CUSTOM_BBOX: [0, 0, 80, 160]
50+
TEXT_OFFSET: [-30, 0]
51+
TEMPERATURE:
52+
INTERVAL: 5
53+
RADIAL:
54+
SHOW: True
55+
X: 300
56+
Y: 180
57+
RADIUS: 80
58+
WIDTH: 15
59+
MIN_VALUE: 0
60+
MAX_VALUE: 100
61+
ANGLE_START: 100
62+
ANGLE_END: 260
63+
ANGLE_STEPS: 10
64+
ANGLE_SEP: 5
65+
CLOCKWISE: True
66+
BAR_COLOR: 0, 250, 0
67+
SHOW_TEXT: True
68+
SHOW_UNIT: True
69+
FONT: roboto/Roboto-Bold.ttf
70+
FONT_SIZE: 20
71+
FONT_COLOR: 0, 250, 0
72+
#BACKGROUND_COLOR: 200, 200, 200
73+
BACKGROUND_IMAGE: background.png
74+
CUSTOM_BBOX: [0, 0, 80, 160]
75+
TEXT_OFFSET: [-30, 0]
76+
FAN_SPEED:
77+
RADIAL:
78+
SHOW: True
79+
X: 173
80+
Y: 230
81+
RADIUS: 31
82+
WIDTH: 13
83+
MIN_VALUE: 0
84+
MAX_VALUE: 100
85+
ANGLE_START: 220
86+
ANGLE_END: 220
87+
ANGLE_STEPS: 20
88+
ANGLE_SEP: 0
89+
CLOCKWISE: True
90+
BAR_COLOR: 200, 100, 50
91+
SHOW_TEXT: True
92+
SHOW_UNIT: True
93+
FONT: roboto/Roboto-Bold.ttf
94+
FONT_SIZE: 15
95+
FONT_COLOR: 248, 177, 51
96+
#BACKGROUND_COLOR: 200, 200, 200
97+
BACKGROUND_IMAGE: background.png
98+
MEMORY:
99+
INTERVAL: 1
100+
VIRTUAL:
101+
#RADIAL:
102+
# SHOW: FALSE
103+
# X: 66
104+
# Y: 151
105+
# RADIUS: 31
106+
# WIDTH: 13
107+
# MIN_VALUE: 0
108+
# MAX_VALUE: 100
109+
# ANGLE_START: 20
110+
# ANGLE_END: 20
111+
# ANGLE_STEPS: 1
112+
# ANGLE_SEP: 25
113+
# CLOCKWISE: True
114+
# BAR_COLOR: 200, 100, 50
115+
# SHOW_TEXT: True
116+
# SHOW_UNIT: True
117+
# FONT: roboto/Roboto-Bold.ttf
118+
# FONT_SIZE: 13
119+
# FONT_COLOR: 248, 177, 51
120+
# BACKGROUND_COLOR: 0, 0, 0
121+
# BACKGROUND_IMAGE: background.png
122+
RADIAL:
123+
SHOW: True
124+
X: 87
125+
Y: 240
126+
RADIUS: 39
127+
WIDTH: 15
128+
MIN_VALUE: 0
129+
MAX_VALUE: 100
130+
ANGLE_START: 20
131+
ANGLE_END: 20
132+
ANGLE_STEPS: 1
133+
ANGLE_SEP: 25
134+
CLOCKWISE: True
135+
BAR_COLOR: 0, 0, 200
136+
SHOW_TEXT: True
137+
SHOW_UNIT: True
138+
FONT: roboto/Roboto-Bold.ttf
139+
FONT_SIZE: 13
140+
FONT_COLOR: 248, 177, 51
141+
# BACKGROUND_COLOR: 0, 0, 0
142+
BACKGROUND_IMAGE: background.png
143+
GPU:
144+
INTERVAL: 1
145+
PERCENTAGE:
146+
RADIAL:
147+
SHOW: True
148+
X: 120
149+
Y: 100
150+
RADIUS: 80
151+
WIDTH: 15
152+
MIN_VALUE: 0
153+
MAX_VALUE: 100
154+
ANGLE_START: 80
155+
ANGLE_END: 280
156+
ANGLE_STEPS: 10
157+
ANGLE_SEP: 5
158+
CLOCKWISE: False
159+
BAR_COLOR: 255, 0, 0
160+
SHOW_TEXT: True
161+
SHOW_UNIT: True
162+
FONT: roboto/Roboto-Bold.ttf
163+
FONT_SIZE: 20
164+
FONT_COLOR: 255, 0, 0
165+
# BACKGROUND_COLOR: 0, 0, 0
166+
BACKGROUND_IMAGE: background.png
167+
CUSTOM_BBOX: [80, 0, 160, 160]
168+
TEXT_OFFSET: [30, 0]
169+
MEMORY_PERCENT:
170+
GRAPH:
171+
SHOW: False
172+
X: 349
173+
Y: 48
174+
WIDTH: 102
175+
HEIGHT: 9
176+
MIN_VALUE: 0
177+
MAX_VALUE: 100
178+
BAR_COLOR: 255, 0, 0
179+
BAR_OUTLINE: False
180+
# BACKGROUND_COLOR: 0, 0, 0
181+
BACKGROUND_IMAGE: background.png
182+
TEXT:
183+
SHOW: False
184+
SHOW_UNIT: True
185+
X: 295
186+
Y: 46
187+
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
188+
FONT_SIZE: 20
189+
FONT_COLOR: 21, 176, 231
190+
#BACKGROUND_COLOR: 132, 154, 165
191+
BACKGROUND_IMAGE: background.png
192+
TEMPERATURE:
193+
RADIAL:
194+
SHOW: True
195+
X: 300
196+
Y: 180
197+
RADIUS: 80
198+
WIDTH: 15
199+
MIN_VALUE: 0
200+
MAX_VALUE: 100
201+
ANGLE_START: 80
202+
ANGLE_END: 280
203+
ANGLE_STEPS: 10
204+
ANGLE_SEP: 5
205+
CLOCKWISE: False
206+
BAR_COLOR: 255, 0, 0
207+
SHOW_TEXT: True
208+
SHOW_UNIT: True
209+
FONT: roboto/Roboto-Bold.ttf
210+
FONT_SIZE: 20
211+
FONT_COLOR: 255, 0, 0
212+
#BACKGROUND_COLOR: 200, 200, 200
213+
BACKGROUND_IMAGE: background.png
214+
CUSTOM_BBOX: [80, 0, 160, 160]
215+
TEXT_OFFSET: [30, 0]
216+
FAN_SPEED:
217+
RADIAL:
218+
SHOW: True
219+
X: 430
220+
Y: 68
221+
RADIUS: 31
222+
WIDTH: 13
223+
MIN_VALUE: 0
224+
MAX_VALUE: 100
225+
ANGLE_START: 320
226+
ANGLE_END: 320
227+
ANGLE_STEPS: 20
228+
ANGLE_SEP: 0
229+
CLOCKWISE: False
230+
BAR_COLOR: 200, 100, 50
231+
SHOW_TEXT: True
232+
SHOW_UNIT: True
233+
FONT: roboto/Roboto-Bold.ttf
234+
FONT_SIZE: 15
235+
FONT_COLOR: 248, 177, 51
236+
#BACKGROUND_COLOR: 200, 200, 200
237+
BACKGROUND_IMAGE: background.png
238+
FPS:
239+
TEXT:
240+
SHOW: False
241+
SHOW_UNIT: False
242+
X: 46
243+
Y: 279
244+
MIN_SIZE: 4
245+
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
246+
FONT_SIZE: 27
247+
FONT_COLOR: 255, 255, 255
248+
#BACKGROUND_COLOR: 100, 100, 100
249+
BACKGROUND_IMAGE: background.png
250+
LINE_GRAPH:
251+
SHOW: False
252+
X: 180
253+
Y: 220
254+
WIDTH: 133
255+
HEIGHT: 82
256+
MIN_VALUE: 0
257+
MAX_VALUE: 144
258+
HISTORY_SIZE: 100
259+
AUTOSCALE: True
260+
LINE_COLOR: 255, 255, 255
261+
AXIS: True
262+
BACKGROUND_IMAGE: background.png
263+
NET:
264+
INTERVAL: 1
265+
ETH:
266+
UPLOAD:
267+
TEXT:
268+
SHOW: False
269+
X: 344
270+
Y: 263
271+
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
272+
FONT_SIZE: 10
273+
FONT_COLOR: 255, 255, 255
274+
# BACKGROUND_COLOR: 132, 154, 165
275+
BACKGROUND_IMAGE: background.png
276+
DOWNLOAD:
277+
TEXT:
278+
SHOW: False
279+
X: 390
280+
Y: 232
281+
FONT: jetbrains-mono/JetBrainsMono-Bold.ttf
282+
FONT_SIZE: 10
283+
FONT_COLOR: 255, 255, 255
284+
# BACKGROUND_COLOR: 132, 154, 165
285+
BACKGROUND_IMAGE: background.png
286+
287+
288+

0 commit comments

Comments
 (0)