Skip to content

Commit 734b0be

Browse files
committed
fix with attribute override. code format
1 parent e478640 commit 734b0be

File tree

4 files changed

+39
-32
lines changed

4 files changed

+39
-32
lines changed

displayio_gauge.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def __init__(
6969
self.xcenter = x
7070
self.ycenter = y
7171
self.radius = radius
72-
self.width = thickness
72+
self._width = thickness
7373
if thickness < 2:
74-
self.width = 2
74+
self._width = 2
7575
self._level = level
7676
tileGridWidth = 2 * self.radius + 1
7777
tileGridHeight = math.ceil(0.71 * self.radius) + self.radius + 1
@@ -118,7 +118,7 @@ def _draw_gauge(self):
118118

119119
# Inner Arc
120120
x = 0
121-
y = self.radius - self.width + 1
121+
y = self.radius - self._width + 1
122122
d = 3 - 2 * y
123123

124124
while x <= y:
@@ -176,10 +176,10 @@ def _draw_level(self):
176176
round(math.cos(math.radians(prog)) * (self.radius - 1), 0)
177177
)
178178
xe = self.radius + int(
179-
round(math.sin(math.radians(prog)) * (self.radius - self.width + 2), 0)
179+
round(math.sin(math.radians(prog)) * (self.radius - self._width + 2), 0)
180180
)
181181
ye = self.radius + int(
182-
round(math.cos(math.radians(prog)) * (self.radius - self.width + 2), 0)
182+
round(math.cos(math.radians(prog)) * (self.radius - self._width + 2), 0)
183183
)
184184

185185
# Draw end line for level value
@@ -189,13 +189,13 @@ def _draw_level(self):
189189

190190
xp = self.radius + int(
191191
round(
192-
math.sin(math.radians(prog + 1)) * (self.radius - int(self.width / 2)),
192+
math.sin(math.radians(prog + 1)) * (self.radius - int(self._width / 2)),
193193
0,
194194
)
195195
)
196196
yp = self.radius + int(
197197
round(
198-
math.cos(math.radians(prog + 1)) * (self.radius - int(self.width / 2)),
198+
math.cos(math.radians(prog + 1)) * (self.radius - int(self._width / 2)),
199199
0,
200200
)
201201
)
@@ -205,14 +205,14 @@ def _draw_level(self):
205205
xp = self.radius + int(
206206
round(
207207
math.sin(math.radians(prog + i))
208-
* (self.radius - int(self.width / 2)),
208+
* (self.radius - int(self._width / 2)),
209209
0,
210210
)
211211
)
212212
yp = self.radius + int(
213213
round(
214214
math.cos(math.radians(prog + i))
215-
* (self.radius - int(self.width / 2)),
215+
* (self.radius - int(self._width / 2)),
216216
0,
217217
)
218218
)
@@ -234,10 +234,10 @@ def _draw_regress(self):
234234
round(math.cos(math.radians(prog)) * (self.radius - 1), 0)
235235
)
236236
xe = self.radius + int(
237-
round(math.sin(math.radians(prog)) * (self.radius - self.width + 2), 0)
237+
round(math.sin(math.radians(prog)) * (self.radius - self._width + 2), 0)
238238
)
239239
ye = self.radius + int(
240-
round(math.cos(math.radians(prog)) * (self.radius - self.width + 2), 0)
240+
round(math.cos(math.radians(prog)) * (self.radius - self._width + 2), 0)
241241
)
242242

243243
# Draw end line for level value
@@ -250,13 +250,13 @@ def _draw_regress(self):
250250

251251
xp = self.radius + int(
252252
round(
253-
math.sin(math.radians(prog - 1)) * (self.radius - int(self.width / 2)),
253+
math.sin(math.radians(prog - 1)) * (self.radius - int(self._width / 2)),
254254
0,
255255
)
256256
)
257257
yp = self.radius + int(
258258
round(
259-
math.cos(math.radians(prog - 1)) * (self.radius - int(self.width / 2)),
259+
math.cos(math.radians(prog - 1)) * (self.radius - int(self._width / 2)),
260260
0,
261261
)
262262
)
@@ -266,14 +266,14 @@ def _draw_regress(self):
266266
xp = self.radius + int(
267267
round(
268268
math.sin(math.radians(prog - i))
269-
* (self.radius - int(self.width / 2)),
269+
* (self.radius - int(self._width / 2)),
270270
0,
271271
)
272272
)
273273
yp = self.radius + int(
274274
round(
275275
math.cos(math.radians(prog - i))
276-
* (self.radius - int(self.width / 2)),
276+
* (self.radius - int(self._width / 2)),
277277
0,
278278
)
279279
)

examples/displayio_gauge_multiple_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
gauge4.foreground_color = 0x00FF00
9898
gauge5.foreground_color = 0x00FF00
9999

100-
gauge4.level= i
100+
gauge4.level = i
101101
gauge5.level = i
102102
time.sleep(0.1)
103103

@@ -109,6 +109,6 @@
109109
gauge4.foreground_color = 0x00FF00
110110
gauge5.foreground_color = 0x00FF00
111111

112-
gauge4.level= i
112+
gauge4.level = i
113113
gauge5.level = i
114114
time.sleep(0.1)

examples/displayio_gauge_simpletest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
radius=30,
3333
foreground_color=0x00FF00,
3434
background_color=0x000000,
35-
outline_color=0xFFFFFF
35+
outline_color=0xFFFFFF,
3636
)
3737
main_group.append(example_gauge)
3838

examples/test_for_leaks.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,28 @@
1616
color_pass = 0x009900
1717
color_fail = 0x990000
1818

19+
1920
def make_gauge(radius, thickness):
20-
return Gauge(x=display.width//2,y=display.height//2,
21-
radius=radius, thickness=thickness, level=10,
21+
return Gauge(
22+
x=display.width // 2,
23+
y=display.height // 2,
24+
radius=radius,
25+
thickness=thickness,
26+
level=10,
2227
outline_color=0xEEEEEE,
2328
foreground_color=0xFFCC00,
24-
background_color=0x3333FF)
29+
background_color=0x3333FF,
30+
)
31+
2532

2633
# pylint: disable=W0212
2734
# test access to gauge._bitmap
2835
def check(gauge):
2936
bitmap = gauge._bitmap
30-
top_left = (1,1)
31-
top_right = (bitmap.width-1,1)
32-
bottom_center = (bitmap.width//2, bitmap.height-1)
33-
if bitmap[top_left[0],top_left[1]] != 0:
37+
top_left = (1, 1)
38+
top_right = (bitmap.width - 1, 1)
39+
bottom_center = (bitmap.width // 2, bitmap.height - 1)
40+
if bitmap[top_left[0], top_left[1]] != 0:
3441
raise ValueError("leak detected top_left")
3542
if bitmap[top_right[0], top_right[1]] != 0:
3643
raise ValueError("leak detected top_right")
@@ -39,27 +46,27 @@ def check(gauge):
3946

4047

4148
def find_leaks(gauge):
42-
for x in range(360*3.0):
49+
for x in range(360 * 3.0):
4350
theta = math.radians(x)
4451
level = int(abs(math.sin(theta) * 100))
4552
gauge.level = level
4653
check(gauge)
4754

4855

49-
5056
for iteration in range(5):
51-
my_radius = random.randrange(10,90)
52-
my_thickness = int(min(
53-
max(my_radius*0.2, my_radius*random.random()),my_radius*0.85))
57+
my_radius = random.randrange(10, 90)
58+
my_thickness = int(
59+
min(max(my_radius * 0.2, my_radius * random.random()), my_radius * 0.85)
60+
)
5461
print(f"iteration={iteration} radius={my_radius} thickness={my_thickness}")
5562
my_gauge = make_gauge(my_radius, my_thickness)
5663
top_group[0] = my_gauge
5764
try:
5865
find_leaks(my_gauge)
59-
my_gauge.background_color=color_pass
66+
my_gauge.background_color = color_pass
6067
time.sleep(3)
6168
except ValueError:
62-
my_gauge.background_color=color_fail
69+
my_gauge.background_color = color_fail
6370
break
6471

6572
if my_gauge.background_color == color_pass:

0 commit comments

Comments
 (0)