-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhello.py
68 lines (52 loc) · 1.56 KB
/
hello.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
63
64
65
66
67
68
"""
hello.py
========
.. figure:: ../_static/hello.jpg
:align: center
Test for text_font_converter.
Writes "Hello!" in random colors at random locations on the Display.
https://www.youtube.com/watch?v=atBa0BYPAAc
.. note:: This example requires the following modules:
.. hlist::
:columns: 3
- `st7789py`
- `tft_config`
- `vga2_bold_16x32`
"""
import random
import tft_config
import tft_text
import vga2_bold_16x32 as font
palette = tft_config.palette
def main():
"""
The big show!
"""
tft = tft_config.config(tft_config.WIDE)
while True:
for rotation in range(4):
tft.rotation = rotation
tft.draw.fill(0)
col_max = tft.width - font.WIDTH * 5
row_max = tft.height - font.HEIGHT
if col_max < 0 or row_max < 0:
raise RuntimeError("This font is too big to display on this screen.")
for _ in range(100):
tft_text.text(
tft,
font,
"Hello",
random.randint(0, col_max),
random.randint(0, row_max),
palette.color565(
random.getrandbits(8),
random.getrandbits(8),
random.getrandbits(8),
),
palette.color565(
random.getrandbits(8),
random.getrandbits(8),
random.getrandbits(8),
),
)
main()