2020-01-21 23:10:50 +01:00
|
|
|
from machine import Pin
|
|
|
|
from machine import SPI
|
|
|
|
|
2020-01-23 19:59:43 +01:00
|
|
|
from drivers.st7789 import ST7789_SPI
|
2020-01-21 23:10:50 +01:00
|
|
|
|
|
|
|
def st7789():
|
|
|
|
spi = SPI(0)
|
|
|
|
# Mode 3, maximum clock speed!
|
|
|
|
spi.init(polarity=1, phase=1, baudrate=8000000)
|
|
|
|
|
2020-01-28 19:30:04 +01:00
|
|
|
# Configure the display
|
2020-01-21 23:10:50 +01:00
|
|
|
cs = Pin("SPI_SS2", Pin.OUT)
|
|
|
|
dc = Pin("P18", Pin.OUT)
|
|
|
|
rst = Pin("P26", Pin.OUT)
|
2020-01-23 19:59:43 +01:00
|
|
|
tft = ST7789_SPI(240, 240, spi, cs=cs, dc=dc, res=rst)
|
2020-01-28 19:30:04 +01:00
|
|
|
|
|
|
|
# Bring up the backlight
|
|
|
|
bl = Pin("P22", Pin.OUT)
|
2020-01-21 23:10:50 +01:00
|
|
|
bl.off() # active low
|
|
|
|
return tft
|