M5STACK CORE 320x240 (ILI9342)

tft_configs/m5stack_core/tft_config.py

 1"""M5STACK CORE 320x240 (ILI9342)
 2"""
 3
 4from machine import Pin, SPI
 5import st7789py as st7789
 6
 7TFA = 0
 8BFA = 0
 9WIDE = 0
10TALL = 1
11SCROLL = 0      # orientation for scroll.py
12FEATHERS = 1    # orientation for feathers.py
13
14def config(rotation=0):
15    """Configure the M5Stack CORE display using a custom_init and
16        custom_rotations since the display is ili9342c. The custom_init is a
17        list of commands to send to the display during the init() metehod. The
18        list contains tuples with a bytes object, optionally followed by a
19        delay specified in ms. The first byte of the bytes object contains the
20        command to send optionally followed by data bytes.
21    """
22
23    custom_init = (
24        (b'\x11', None, 150),	               # exit sleep
25        (b'\xCB', b'\x39\x2C\x00\x34\x02', 0), # power control A
26        (b'\xCF', b'\x00\xC1\x30', 0),		   # power control B
27        (b'\xE8', b'\x85\x00\x78', 0),		   # driver timing control A
28        (b'\xEA', b'\x00\x00', 0),			   # driver timing control B
29        (b'\xED', b'\x64\x03\x12\x81', 0),	   # power on sequence control
30        (b'\xF7', b'\x20', 0),			       # pump ratio control
31        (b'\xC0', b'\x23', 0),			       # power control,VRH[5:0]
32        (b'\xC1', b'\x10', 0),			       # Power control,SAP[2:0];BT[3:0]
33        (b'\xC5', b'\x3E\x28', 0),			   # vcm control
34        (b'\xC7', b'\x86', 0),			       # vcm control 2
35        (b'\x3A', b'\x55', 0),			       # pixel format
36        (b'\x36', b'\x00', 0),			       # madctl
37        (b'\x21', None, 0),			           # inversion on
38        (b'\xB1', b'\x00\x18', 0),			   # frameration control,normal mode full colours
39        (b'\xB6', b'\x08\x82\x27', 0),		   # display function control
40        (b'\xF2', b'\x00', 0),			       # 3gamma function disable
41        (b'\x26', b'\x01', 0),			       # gamma curve selected
42        # set positive gamma correction
43        (b'\xE0', b'\x0F\x31\x2B\x0C\x0E\x08\x4E\xF1\x37\x07\x10\x03\x0E\x09\x00', 0),
44        # set negative gamma correction
45        (b'\xE1', b'\x00\x0E\x14\x03\x11\x07\x31\xC1\x48\x08\x0F\x0C\x31\x36\x0F', 0),
46        (b'\x29', None, 100),                  # display on
47    )
48
49    custom_rotations = (
50        (0x08, 320, 240, 0, 0, False),
51        (0x68, 240, 320, 0, 0, False),
52        (0xc8, 320, 240, 0, 0, False),
53        (0xa8, 240, 320, 0, 0, False),
54    )
55
56    return st7789.ST7789(
57        SPI(2, baudrate=40000000, sck=Pin(18), mosi=Pin(23)),
58        320,
59        240,
60        reset=Pin(33, Pin.OUT),
61        cs=Pin(14, Pin.OUT),
62        dc=Pin(27, Pin.OUT),
63        backlight=Pin(32, Pin.OUT),
64        custom_init=custom_init,
65        custom_rotations=custom_rotations,
66        rotation=rotation)

tft_configs/m5stack_core/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
 2# input pins for ws_pico_13
 3
 4from machine import Pin
 5
 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 = "m5stack_core"
22
23        self.left = Pin(39, Pin.IN)  # button A
24        self.fire = Pin(38, Pin.IN)  # button B
25        self.right = Pin(37, Pin.IN)  # button C
26        self.thrust = None
27        self.hyper = None