1.28" 240x240 GC9A01 SPI IPS on RP2040/MicroPython, using russhughes/gc9a01py lib.

It's ZhongJingYuan 1.28" 240x240 Round IPS LCD with GC9A01, on WeAct RP2040 (16MB) with MicroPython v1.19.1, using russhughes/gc9a01py library.


Library:

To prepare Library (russhughes/gc9a01py library), visit: https://github.com/russhughes/gc9a01py.

Upload lib, fonts and examples folders to MicroPython device's /

Connection:
GC9A01	RP2040 
--------------------------
BLK		GP26
CS		GP22
DC		GP21
RES		GP20
SDA		GP19
SCL		GP18
VCC		3V3
GND		GND

Code:

Modify the examples code as shown in the video above. Modified hello.py is listed here for reference.

hello.py
"""
hello.py

    Writes "Hello!" in random colors at random locations on the display

"""
import random
from machine import Pin, SPI
import gc9a01py as gc9a01

# Choose a font

# from fonts import vga1_8x8 as font
# from fonts import vga2_8x8 as font
# from fonts import vga1_8x16 as font
# from fonts import vga2_8x16 as font
# from fonts import vga1_16x16 as font
# from fonts import vga1_bold_16x16 as font
# from fonts import vga2_16x16 as font
# from fonts import vga2_bold_16x16 as font
# from fonts import vga1_16x32 as font
# from fonts import vga1_bold_16x32 as font
# from fonts import vga2_16x32 as font
from fonts.romfonts import vga2_bold_16x32 as font

#=========================
TFT_BLK=26
TFT_CS=22
TFT_DC=21
TFT_RES=20
TFT_SDA=19
TFT_SCL=18

print("BLK\t", TFT_BLK)
print("CD\t", TFT_CS)
print("DC\t", TFT_DC)
print("RES\t", TFT_RES)
print("SDA\t", TFT_SDA)
print("SCL\t", TFT_SCL)

spi = SPI(0, baudrate=60000000, sck=Pin(TFT_SCL), mosi=Pin(TFT_SDA))
print(spi)
tft = gc9a01.GC9A01(
    spi,
    dc=Pin(TFT_DC, Pin.OUT),
    cs=Pin(TFT_CS, Pin.OUT),
    reset=Pin(TFT_RES, Pin.OUT),
    backlight=Pin(TFT_BLK, Pin.OUT),
    rotation=0)

#=========================

def main():
    """
    spi = SPI(2, baudrate=60000000, sck=Pin(18), mosi=Pin(23))
    tft = gc9a01.GC9A01(
        spi,
        dc=Pin(21, Pin.OUT),
        cs=Pin(13, Pin.OUT),
        reset=Pin(26, Pin.OUT),
        backlight=Pin(14, Pin.OUT),
        rotation=0)
    """

    while True:
        for rotation in range(8):
            tft.rotation(rotation)
            tft.fill(0)
            col_max = tft.width - font.WIDTH*6
            row_max = tft.height - font.HEIGHT

            for _ in range(25):
                tft.text(
                    font,
                    "Hello!",
                    random.randint(0, col_max),
                    random.randint(0, row_max),
                    gc9a01.color565(
                        random.getrandbits(8),
                        random.getrandbits(8),
                        random.getrandbits(8)),
                    gc9a01.color565(
                        random.getrandbits(8),
                        random.getrandbits(8),
                        random.getrandbits(8))
                )


main()



Comments

Popular posts from this blog

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.

CameraWebServe: ESP32-S3 (arduino-esp32) + OV5640 camera module