Skip to content

Instantly share code, notes, and snippets.

@maditnerd
Last active July 28, 2022 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maditnerd/e89c30fe2d3e82371445e96a52e3eced to your computer and use it in GitHub Desktop.
Save maditnerd/e89c30fe2d3e82371445e96a52e3eced to your computer and use it in GitHub Desktop.
How to use M5Stick C screen with micropython
# Use this firmware : https://github.com/russhughes/st7789_mpy/tree/master/firmware/GENERIC-7789
# Need AXP192 library (to turn on tft) https://github.com/usini/stickc_micropython/tree/main/lib
from axp192 import AXP192
from machine import Pin, I2C, SPI
import st7789
i2c = I2C(0, sda=Pin(21), scl=Pin(22))
axp = AXP192(i2c)
axp.setup()
axp.set_LD02(True)
spi = SPI(1, baudrate=27000000,polarity=0, phase=0, bits=8, firstbit=SPI.MSB,sck=Pin(13), mosi=Pin(15))
rotations = [
(0x00, 80, 160, 26, 1),
(0x60, 160, 80, 1, 26),
(0xc0, 80, 160, 26, 1),
(0xa0, 160, 80, 1, 26)
]
tft = st7789.ST7789(spi,
80,
160,
dc=Pin(23, Pin.OUT,Pin.PULL_DOWN),
cs=Pin(5, Pin.OUT, Pin.PULL_DOWN),
reset=Pin(18, Pin.OUT, Pin.PULL_DOWN),
rotations=rotations,
color_order=st7789.BGR,
rotation=1)
tft.init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment