-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_test.py
51 lines (47 loc) · 1.25 KB
/
display_test.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
from display import Display
from PIL import Image, ImageDraw, ImageFont
from pathlib import Path
display = Display(rotate=90)
min_dimension = min(display.width, display.height)
top_left = (
display.width / 2 - (min_dimension / 2 - 10),
display.height / 2 - (min_dimension / 2 - 10),
)
bottom_right = (
display.width / 2 + (min_dimension / 2 - 10),
display.height / 2 + (min_dimension / 2 - 10),
)
fonts_dir = (Path(__file__).parent / "./assets/fonts").resolve()
font_regular = ImageFont.truetype(
(fonts_dir / "Cantarell-VF.otf").resolve(),
size=16,
)
for frame in range(360 * 4):
image = Image.new("1", (display.width, display.height), 255)
draw = ImageDraw.Draw(image)
draw.arc(
[top_left, bottom_right],
frame * 15,
frame * 15 + 90,
fill=0,
width=2,
)
draw.text(
(display.width / 2, display.height / 2),
str(frame),
fill=0,
font=font_regular,
anchor="mm",
)
if frame == 0:
display.display(
image,
update_mode=display.FULL_UPDATE,
blocking=False,
)
else:
display.display(
image,
update_mode=display.PARTIAL_UPDATE,
blocking=True,
)