ILI9341 color TFT
The 2.4 inch 240x320 color TFT panel, over 4-wire SPI. DC says whether a byte is
a command or data; everything else follows from that one line.
SPI mode 0, MSB first: MOSI is sampled on the rising edge of SCK while CS is
low, and a rising CS throws away a part-built byte, the way a real controller
drops a frame that ends early.
Pins
| Pin | What it does |
|---|---|
VCC |
Supply. |
GND |
Ground. |
CS |
Chip select, active low. |
RST |
Reset. |
DC |
Low for a command byte, high for its data or for pixels. |
SCK |
SPI clock. |
MOSI |
SPI data in. |
MISO |
Present on the header, never driven; this model answers no register reads. |
LED |
The backlight; pulling it low blanks the panel. |
Properties
None. Behavior comes entirely from the command stream.
What the model gets right
MADCTL (command 0x36) is the whole of "rotation" on this controller: MV
exchanges the two axes and MX/MY count the other way along them, and the frame
handed to the display is always in the address counter's own coordinates, so the
picture is upright whichever rotation the sketch chose. A module you rotate on the
bench is a part you rotate on the canvas. CASET/PASET set the pixel window and
RAMWR streams pixels into it, exactly as the datasheet has it.
What it does not model
BGR (a MADCTL bit some panels use for their color filter order) is accepted but
has no effect: a pixel is always the RGB565 value that was written. The long init
sequences every library sends (power control, gamma, frame rate, VCOM) are accepted
and their parameters ignored, so a driver that sends a wrong or incomplete init gets a
perfect picture here and whatever the panel feels like on the bench.
No timing at all on the bus. SCK has no maximum rate, CS has no setup or hold
requirement, and a byte is latched the instant its eighth rising edge arrives. A real
ILI9341 wants SWRESET followed by 5 ms of quiet and SLPOUT followed by 120 ms
before it will take pixels; here both take effect immediately, so a driver that skips
those waits works here and not on a real module. There is no frame rate, no tearing
signal and no TE pin.
Also absent: vertical scrolling (0x33/0x37), partial mode, idle mode, tearing
effect control, and gamma or VCOM having any visible effect. COLMOD accepts both
16-bit and 18-bit pixel formats, but a pixel is stored as RGB565 either way, so 18-bit
mode loses the two extra bits per channel a real panel would keep. There is no
backlight brightness. LED is on or off, not a PWM dimmer.
Common mistakes
Forgetting LED is a real pin here, not a decoration. A driver that never sets it
high leaves the panel dark even while the framebuffer is being drawn correctly
underneath.
See it in action
Snake, D-pad pong and Pong, two buttons all draw to an ILI9341 panel. Open them at /templates.