Waveshare Pico LCD 2 240x320

https://www.waveshare.com/wiki/Pico-LCD-2

tft_configs/waveshare_2/tft_config.py

 1"""Waveshare Pico LCD 2 240x320
 2
 3https://www.waveshare.com/wiki/Pico-LCD-2
 4
 5"""
 6
 7from machine import Pin, SPI
 8import st7789py as st7789
 9
10TFA = 0
11BFA = 0
12WIDE = 1
13TALL = 0
14SCROLL = 0  # orientation for scroll.py
15FEATHERS = 1  # orientation for feathers.py
16
17
18def config(rotation=0):
19    """
20    Configures and returns an instance of the ST7789 display driver.
21
22    Args:
23        rotation (int): The rotation of the display. Defaults to 0.
24
25    Returns:
26        ST7789: An instance of the ST7789 display driver.
27    """
28    return st7789.ST7789(
29        SPI(1, baudrate=60000000, sck=Pin(10), mosi=Pin(11)),
30        240,
31        320,
32        reset=Pin(12, Pin.OUT),
33        cs=Pin(9, Pin.OUT),
34        dc=Pin(8, Pin.OUT),
35        backlight=Pin(13, Pin.OUT),
36        rotation=rotation,
37    )

tft_configs/waveshare_2/tft_buttons.py

input pins for ws_pico_2

 1"""
 2input pins for ws_pico_2
 3"""
 4
 5from machine import Pin
 6
 7class Buttons():
 8    """
 9    Buttons class for examples, modify for your device.
10
11    Attributes:
12        name (str): The name of the device.
13        left (Pin): The Pin object representing the left button.
14        right (Pin): The Pin object representing the right button.
15        fire (Pin): The Pin object representing the fire button.
16        thrust (Pin): The Pin object representing the thrust button.
17        hyper (Pin): The Pin object representing the hyper button.
18    """
19
20    def __init__(self):
21        self.name = "ws_pico_2"
22        self.key0 = Pin(15, Pin.IN, Pin.PULL_UP)    # Top Right
23        self.key1 = Pin(17, Pin.IN, Pin.PULL_UP)    # Bottom Right
24        self.key2 = Pin(2, Pin.IN, Pin.PULL_UP)     # Bottom Left
25        self.key3 = Pin(3, Pin.IN, Pin.PULL_UP)     # Top Left
26
27        # for roids.py in landscape mode
28
29        self.left = self.key2
30        self.right = self.key3
31        self.fire = self.key1
32        self.thrust = self.key0
33        self.hyper = None