M5STACK CoreS3 320x240 (ILI9342)

tft_configs/m5stack_core3/tft_config.py

 1"""M5STACK CoreS3 320x240 (ILI9342)
 2"""
 3
 4from machine import Pin, SPI
 5import m5cores3
 6import st7789py as st7789
 7
 8
 9TFA = 0
10BFA = 0
11WIDE = 0
12TALL = 1
13SCROLL = 0      # orientation for scroll.py
14FEATHERS = 1    # orientation for feathers.py
15
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_init = (
29        (b"\x01", None, 150),  # soft reset
30        (b"\x11", None, 255),  # exit sleep
31        (b"\xCB", b"\x39\x2C\x00\x34\x02", 0),  # power control A
32        (b"\xCF", b"\x00\xC1\x30", 0),  # power control B
33        (b"\xE8", b"\x85\x00\x78", 0),  # driver timing control A
34        (b"\xEA", b"\x00\x00", 0),  # driver timing control B
35        (b"\xED", b"\x64\x03\x12\x81", 0),  # power on sequence control
36        (b"\xF7", b"\x20", 0),  # pump ratio control
37        (b"\xC0", b"\x23", 0),  # power control,VRH[5:0]
38        (b"\xC1", b"\x10", 0),  # Power control,SAP[2:0];BT[3:0]
39        (b"\xC5", b"\x3E\x28", 0),  # vcm control
40        (b"\xC7", b"\x86", 0),  # vcm control 2
41        (b"\x3A", b"\x55", 0),  # pixel format
42        (b"\x36", b"\x08", 0),  # madctl
43        (b"\x21", None, 0),  # inversion on
44        (b"\xB1", b"\x00\x18", 0),  # frameration control,normal mode full colours
45        (b"\xB6", b"\x08\x82\x27", 0),  # display function control
46        (b"\xF2", b"\x00", 0),  # 3gamma function disable
47        (b"\x26", b"\x01", 0),  # gamma curve selected
48        # set positive gamma correction
49        (b"\xE0", b"\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00", 0),
50        # set negative gamma correction
51        (b"\xE1", b"\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F", 0),
52        (b"\x29", None, 100),  # display on
53    )
54
55    custom_rotations = (
56        (0x08, 320, 240, 0, 0, False),
57        (0x68, 240, 320, 0, 0, False),
58        (0xc8, 320, 240, 0, 0, False),
59        (0xa8, 240, 320, 0, 0, False),
60    )
61
62    return st7789.ST7789(
63        SPI(2, baudrate=20000000, sck=Pin(36), mosi=Pin(37), miso=None),
64        240,
65        320,
66        cs=Pin(3, Pin.OUT),
67        dc=Pin(35, Pin.OUT),
68        custom_init=custom_init,
69        custom_rotations=custom_rotations,
70        rotation=rotation,
71        color_order=st7789.BGR)

tft_configs/m5stack_core3/tft_buttons.py

Buttons class for examples, modify for your device.

Attributes:

name (str): The name of the device. left (Pin): The Pin object representing the left button. right (Pin): The Pin object representing the right button. fire (Pin): The Pin object representing the fire button. thrust (Pin): The Pin object representing the thrust button. hyper (Pin): The Pin object representing the hyper button.

 1# M5STACK CORES3
 2#  - Not working with DUAL BUTTON unit
 3
 4# DIN Base
 5#   Port A  1,  2
 6#   Port B  8,  9
 7#   Port C 18, 17
 8
 9from machine import Pin
10
11class Buttons:
12    """
13    Buttons class for examples, modify for your device.
14
15    Attributes:
16        name (str): The name of the device.
17        left (Pin): The Pin object representing the left button.
18        right (Pin): The Pin object representing the right button.
19        fire (Pin): The Pin object representing the fire button.
20        thrust (Pin): The Pin object representing the thrust button.
21        hyper (Pin): The Pin object representing the hyper button.
22    """
23
24    def __init__(self):
25        self.name = "m5stack_cores3"
26        self.left = Pin(1, Pin.IN, Pin.PULL_UP)  # PORT A
27        self.right = Pin(2, Pin.IN, Pin.PULL_UP) # PORT A
28        self.fire = None
29        self.thrust = None
30        self.hyper = None