-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathscroll.py
More file actions
71 lines (51 loc) · 1.5 KB
/
scroll.py
File metadata and controls
71 lines (51 loc) · 1.5 KB
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
69
70
71
"""
scroll.py
=========
.. figure:: ../_static/scroll.jpg
:align: center
Test for hardware scrolling.
Smoothly scrolls all font characters up the screen.
Only works with fonts with heights that are even multiples of the screen height,
(i.e. 8 or 16 pixels high)
.. note:: This example requires the following modules:
.. hlist::
:columns: 3
- `st7789py`
- `tft_config`
- `vga2_bold_16x16`
"""
import time
import tft_text
import tft_config
palette = tft_config.palette
import vga2_bold_16x16 as font
def main():
"""main"""
tft = tft_config.config(tft_config.SCROLL)
last_line = tft.height - font.HEIGHT
tfa = tft_config.TFA # top free area when scrolling
bfa = tft_config.BFA # bottom free area when scrolling
tft.vscrdef(tfa, tft.height - tfa - bfa, bfa)
tft.draw.fill(palette.BLUE)
scroll = 0
character = 0
col = tft.width // 2 - 5 * font.WIDTH // 2
while True:
tft.draw.fill_rect(0, scroll, tft.width, 1, palette.BLUE)
if scroll % font.HEIGHT == 0:
tft_text.text(
tft,
font,
f"x{character:02x} {chr(character)}",
col,
(scroll + last_line) % tft.height,
palette.WHITE,
palette.BLUE,
)
character = character + 1 if character < 256 else 0
tft.vscsad(scroll + tfa)
scroll += 1
if scroll == tft.height:
scroll = 0
time.sleep(0.01)
main()