2020-02-01 21:14:12 +00:00
|
|
|
"""
|
2021-12-23 08:41:22 +00:00
|
|
|
fonts.py
|
2020-02-01 21:14:12 +00:00
|
|
|
|
2021-12-23 08:41:22 +00:00
|
|
|
Pages through all characters of four fonts on the display.
|
2020-02-01 21:14:12 +00:00
|
|
|
|
|
|
|
"""
|
|
|
|
import utime
|
2021-12-23 18:54:40 +00:00
|
|
|
from machine import Pin, SPI
|
2020-02-01 21:14:12 +00:00
|
|
|
import st7789py as st7789
|
|
|
|
|
|
|
|
# Choose fonts
|
|
|
|
|
2021-05-06 06:14:24 +00:00
|
|
|
# from romfonts import vga1_8x8 as font
|
|
|
|
from romfonts import vga2_8x8 as font1
|
|
|
|
# from romfonts import vga1_8x16 as font
|
|
|
|
from romfonts import vga2_8x16 as font2
|
|
|
|
# from romfonts import vga1_16x16 as font
|
|
|
|
# from romfonts import vga1_bold_16x16 as font
|
|
|
|
# from romfonts import vga2_16x16 as font
|
|
|
|
from romfonts import vga2_bold_16x16 as font3
|
|
|
|
# from romfonts import vga1_16x32 as font
|
|
|
|
# from romfonts import vga1_bold_16x32 as font
|
|
|
|
# from romfonts import vga2_16x32 as font
|
|
|
|
from romfonts import vga2_bold_16x32 as font4
|
|
|
|
|
2020-02-01 21:14:12 +00:00
|
|
|
|
|
|
|
def main():
|
2021-12-23 18:54:40 +00:00
|
|
|
spi = SPI(1, baudrate=31250000, sck=Pin(18), mosi=Pin(19))
|
2021-05-06 06:14:24 +00:00
|
|
|
|
2020-02-01 21:14:12 +00:00
|
|
|
tft = st7789.ST7789(
|
2021-05-06 06:14:24 +00:00
|
|
|
spi,
|
2021-12-23 08:41:22 +00:00
|
|
|
320,
|
2020-02-01 21:14:12 +00:00
|
|
|
240,
|
2021-12-23 08:41:22 +00:00
|
|
|
reset=Pin(4, Pin.OUT),
|
|
|
|
cs=Pin(13, Pin.OUT),
|
|
|
|
dc=Pin(12, Pin.OUT),
|
|
|
|
backlight=Pin(15, Pin.OUT),
|
2020-02-01 21:14:12 +00:00
|
|
|
rotation=0)
|
|
|
|
|
|
|
|
tft.vscrdef(40, 240, 40)
|
|
|
|
|
|
|
|
while True:
|
|
|
|
for font in (font1, font2, font3, font4):
|
|
|
|
tft.fill(st7789.BLUE)
|
|
|
|
line = 0
|
|
|
|
col = 0
|
|
|
|
|
|
|
|
for char in range(font.FIRST, font.LAST):
|
|
|
|
tft.text(font, chr(char), col, line, st7789.WHITE, st7789.BLUE)
|
|
|
|
col += font.WIDTH
|
|
|
|
if col > tft.width - font.WIDTH:
|
|
|
|
col = 0
|
|
|
|
line += font.HEIGHT
|
|
|
|
|
|
|
|
if line > tft.height-font.HEIGHT:
|
|
|
|
utime.sleep(3)
|
|
|
|
tft.fill(st7789.BLUE)
|
|
|
|
line = 0
|
|
|
|
col = 0
|
|
|
|
|
|
|
|
utime.sleep(3)
|
2021-05-06 06:14:24 +00:00
|
|
|
|
|
|
|
|
2020-02-01 21:14:12 +00:00
|
|
|
main()
|