tartelette / documentation demossource ↗

st7789: TFT display controller

The Sitronix ST7789, the controller behind most small colour TFTs (240x240, 240x320 and 320x240 panels), on a 4-wire SPI link with a separate D/C pin.

Keys

KeyTypeDefault
busspi0 | spi1the bus it sits on
csGPIOchip select, active low; left out, always selected
dcGPIOrequireddata/command select
rstGPIOhardware reset, active low
blGPIObacklight enable
width1..480240panel width, in its native orientation
height1..480320panel height
[buses]
spi0 = { sck = 18, mosi = 19 }

[parts.screen]
kind = "st7789"
bus = "spi0"
cs = 9
dc = 13
bl = 17

width and height are the panel's native (portrait, usually) size, before any rotation the firmware applies with MADCTL. A Pico Display Pack 2.0 is 240x320 native and shows 320x240 because the firmware rotates it.

What's modelled

The command/data protocol; the address window (CASET/RASET) and RAMWR / RAMWRC; MADCTL orientation (row/column exchange and mirroring) and RGB/BGR order; 12, 16 and 18 bits per pixel; display on/off, sleep in/out, inversion; software reset and the RST pin. The ID registers can be read (without the dummy cycle real chips insert).

Commands that only tune the analog side (gamma, power control, porch settings and so on) are accepted and their parameters ignored.

Panel

The picture, as the glass would show it. rotate = 0 | 90 | 180 | 270 turns the widget to match how the panel is mounted on the board.

Events

update, with the number of pixels written, when chip select is released after a pixel write.

Headless, --dump-screen NAME=FILE.png saves the picture at the end of the run.

Not modelled

Partial mode, vertical scrolling, the tearing-effect output and 3-wire (9-bit) SPI. The bl pin is reserved for the backlight, but the panel doesn't dim the picture when it is off.