forked from MTN-RowinAndruscavage/STEM4T-Display-ESP32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchango.py
58 lines (42 loc) · 1.99 KB
/
chango.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
"""
chango.py proportional font test for font2bitmap converter.
"""
import time
import gc
import st7789
import tft_config
tft = tft_config.config(1)
#
# Large fonts take alot of memory, they should be frozen in the
# firmaware or compiled using the mpy-cross compiler.
#
import chango_64 as font_64
gc.collect()
def display_font(font):
tft.fill(st7789.BLACK) # clear the screen
column = 0 # first column
row = 0 # first row
for char in font.MAP: # for each character in the font map
width = tft.write_len(font, char) # get the width of the character
if column + width > tft.width(): # if the character will not fit on the current line
row += font.HEIGHT # move to the next row
column = 0 # reset the column
if row+font.HEIGHT > tft.height(): # if the row will not fit on the screen
time.sleep(1) # pause for a second
tft.fill(st7789.BLACK) # clear the screen
row = 0 # reset the row
tft.write( # write to the screen
font, # in this font
char, # the character
column, # at this column
row + 40, # on this row
st7789.MAGENTA, # in magenta
st7789.BLACK) # with black background
column += width # move the column past the character
def main():
tft.init()
tft.fill(st7789.BLACK)
for font in [font_64]: # for each font
display_font(font) # display the font characters
time.sleep(1) # pause for a second
main()