RP2040-Touch-LCD-1.28 240x240 (GC9A01)

tft_configs/rp2040_touch_lcd_128/tft_config.py

 1"""RP2040-Touch-LCD-1.28 240x240 (GC9A01)
 2"""
 3
 4from machine import Pin, SPI
 5import st7789py as st7789
 6
 7TFA = 0
 8BFA = 0
 9WIDE = 1
10TALL = 0
11SCROLL = 0      # orientation for scroll.py
12FEATHERS = 1    # orientation for feathers.py
13
14def config(rotation=0):
15    """
16    Configures and returns an instance of the ST7789 display driver.
17
18    Args:
19        rotation (int): The rotation of the display (default: 0).
20
21    Returns:
22        ST7789: An instance of the ST7789 display driver.
23    """
24
25    INIT_CMDS = (
26        (b"\xEF", None, 0),
27        (b"\xEB", b"\x14", 0),
28        (b"\xFE", None, 0),
29        (b"\xEF", None, 0),
30        (b"\xEB", b"\x14", 0),
31        (b"\x84", b"\x40", 0),
32        (b"\x85", b"\xFF", 0),
33        (b"\x86", b"\xFF", 0),
34        (b"\x87", b"\xFF", 0),
35        (b"\x88", b"\x0A", 0),
36        (b"\x89", b"\x21", 0),
37        (b"\x8A", b"\x00", 0),
38        (b"\x8B", b"\x80", 0),
39        (b"\x8C", b"\x01", 0),
40        (b"\x8D", b"\x01", 0),
41        (b"\x8E", b"\xFF", 0),
42        (b"\x8F", b"\xFF", 0),
43        (b"\xB6", b"\x00\x00", 0),
44        (b"\x3A", b"\x55", 0),
45        (b"\x90", b"\x08\x08\x08\x08", 0),
46        (b"\xBD", b"\x06", 0),
47        (b"\xBC", b"\x00", 0),
48        (b"\xFF", b"\x60\x01\x04", 0),
49        (b"\xC3", b"\x13", 0),
50        (b"\xC4", b"\x13", 0),
51        (b"\xC9", b"\x22", 0),
52        (b"\xBE", b"\x11", 0),
53        (b"\xE1", b"\x10\x0E", 0),
54        (b"\xDF", b"\x21\x0c\x02", 0),
55        (b"\xF0", b"\x45\x09\x08\x08\x26\x2A", 0),
56        (b"\xF1", b"\x43\x70\x72\x36\x37\x6F", 0),
57        (b"\xF2", b"\x45\x09\x08\x08\x26\x2A", 0),
58        (b"\xF3", b"\x43\x70\x72\x36\x37\x6F", 0),
59        (b"\xED", b"\x1B\x0B", 0),
60        (b"\xAE", b"\x77", 0),
61        (b"\xCD", b"\x63", 0),
62        (b"\x70", b"\x07\x07\x04\x0E\x0F\x09\x07\x08\x03", 0),
63        (b"\xE8", b"\x34", 0),
64        (b"\x62", b"\x18\x0D\x71\xED\x70\x70\x18\x0F\x71\xEF\x70\x70", 0),
65        (b"\x63", b"\x18\x11\x71\xF1\x70\x70\x18\x13\x71\xF3\x70\x70", 0),
66        (b"\x64", b"\x28\x29\xF1\x01\xF1\x00\x07", 0),
67        (b"\x66", b"\x3C\x00\xCD\x67\x45\x45\x10\x00\x00\x00", 0),
68        (b"\x67", b"\x00\x3C\x00\x00\x00\x01\x54\x10\x32\x98", 0),
69        (b"\x74", b"\x10\x85\x80\x00\x00\x4E\x00", 0),
70        (b"\x98", b"\x3e\x07", 0),
71        (b"\x35", None, 0),
72        (b"\x21", None, 0),
73        (b"\x11", None, 120),
74        (b"\x29", None, 120),
75    )
76
77    DISPLAY_240x240 = (
78        (0x48, 240, 240,  0,  0, False),
79        (0x28, 240, 240,  0,  0, False),
80        (0x88, 240, 240,  0,  0, False),
81        (0xe8, 240, 240,  0,  0, False))
82
83    spi = SPI(1, baudrate=60000000, sck=Pin(10), mosi=Pin(11))
84    return st7789.ST7789(
85        spi,
86        240,
87        240,
88        reset=Pin(13, Pin.OUT),
89        cs=Pin(9, Pin.OUT),
90        dc=Pin(8, Pin.OUT),
91        backlight=Pin(25, Pin.OUT),
92        rotation=rotation,
93        custom_init=INIT_CMDS,
94        custom_rotations=DISPLAY_240x240,
95    )

tft_configs/rp2040_touch_lcd_128/tft_buttons.py

from machine import Pin

class Buttons:

 1"""RP2040-Touch-LCD-1.28"""
 2
 3from machine import Pin
 4
 5
 6class Buttons:
 7    """
 8    Buttons class for examples, modify for your device.
 9
10    Attributes:
11        name (str): The name of the device.
12        left (Pin): The Pin object representing the left button.
13        right (Pin): The Pin object representing the right button.
14        fire (Pin): The Pin object representing the fire button.
15        thrust (Pin): The Pin object representing the thrust button.
16        hyper (Pin): The Pin object representing the hyper button.
17    """
18
19    def __init__(self):
20        self.name = "RP2040-Touch-LCD-1.28"
21        self.left = None
22        self.right = None
23        self.fire = None
24        self.thrust = None
25        self.hyper = None