"""
ESP32-DevKitC V4/MicroPython exercise
240x240 ST7789 SPI LCD
using MicroPython library:
https://github.com/russhughes/st7789py_mpy
"""
import uos
from machine import Pin, SoftSPI ,SPI
import st7789py as st7789
"""
ST7789 Display ESP32-DevKitC (SPI2)
SCL (SCK) GPIO18
SDA (MOSI) GPIO23
GPIO19 (miso not used)
ST7789_rst GPIO5
ST7789_dc GPIO4
lines.py
Draws lines and rectangles in random colors at random locations on the
display.
"""
import random
from machine import Pin, SoftSPI ,SPI
import st7789py as st7789
# SCK 18
# MOSI 23
# MISO NC
# LED NC
# BACKLIGHT NC
def main():
spi = SPI(0,
baudrate=20000000,
polarity=1,
phase=0,
sck=Pin(18),
mosi=Pin(23),
miso=Pin(0))
tft = st7789.ST7789(
spi,
240,
240,
reset=Pin(5, Pin.OUT),
cs=Pin(15, Pin.OUT),
dc=Pin(4, Pin.OUT),
backlight=Pin(0, Pin.OUT),
rotation=1)
tft.fill(st7789.RED)
tft.rect(40, 10, 120, 100, st7789.WHITE)
main()