1"""LilyGo T-embed 170x320
2"""
3
4from machine import Pin, SPI
5import st7789py as st7789
6
7
8TFA = 0
9BFA = 0
10WIDE = 1
11TALL = 0
12SCROLL = 0 # orientation for scroll.py
13FEATHERS = 1 # orientation for feathers.py
14
15POWER = Pin(46, Pin.OUT, value=1)
16
17def config(rotation=0):
18 """
19 Configures and returns an instance of the ST7789 display driver.
20
21 Args:
22 rotation (int): The rotation of the display (default: 0).
23
24 Returns:
25 ST7789: An instance of the ST7789 display driver.
26 """
27
28 custom_rotations = (
29 (0x00, 170, 320, 35, 0, False),
30 (0x60, 320, 170, 0, 35, False),
31 (0xC0, 170, 320, 35, 0, False),
32 (0xA0, 320, 170, 0, 35, False),
33 )
34
35 return st7789.ST7789(
36 SPI(2, baudrate=40000000, sck=Pin(12), mosi=Pin(11), miso=None),
37 170,
38 320,
39 cs=Pin(10, Pin.OUT),
40 dc=Pin(13, Pin.OUT),
41 reset=Pin(9, Pin.OUT),
42 backlight=Pin(15, Pin.OUT),
43 custom_rotations=custom_rotations,
44 rotation=rotation,
45 color_order=st7789.BGR,
46 )