ili9342c
ILI9342C — a 320×240 RGB565 SPI TFT controller.
The display on the M5Stack Core2. Layer 3: it knows the ILI9342C command set
and pixel format, not the SPI controller or DMA engine underneath — those
live behind a [DisplayInterface], which the board builds from its SPI +
GPIO + DMA and hands in. So this driver is portable to any board that wires
an ILI9342C, and the fast path (DMA, chip-select batching) is the interface’s
job, not repeated here.
Performance model
Section titled “Performance model”There is no framebuffer. A 320×240×2 frame is 150 KB — more than the ESP32’s
DMA-reachable DRAM — so this driver streams: it opens one SPI transaction
per fill or blit ([DisplayInterface::start]/[end]), sets the address
window, and lets the interface DMA the pixels. A solid fill costs no
per-pixel CPU work (the interface repeats one packed color); a blit hands the
interface the caller’s pixels and the interface overlaps converting the next
chunk with transferring the current one. This is the same “no framebuffer,
stream windowed regions” model the fast Arduino libraries (TFT_eSPI,
LovyanGFX) use, and it is what a future higher-level (LVGL-style) layer would
call blit through.
Configuring orientation
Section titled “Configuring orientation”[Config] carries rotation, RGB/BGR order and inversion — the three things
boards disagree about. The Core2 runs BGR with inversion on; [Config::CORE2]
is that, and [Config::default] matches it.
Modules
Section titled “Modules”color— RGB565 color helpers. Pixels are plainu16on this driver’s surface (so a
Structs
Section titled “Structs”Config
Section titled “Config”struct Config { pub width: u16, pub height: u16, pub rotation: Rotation, pub color_order: ColorOrder, pub invert: bool,}Board-specific display facts: native size, rotation, color order, inversion.
Implements: Clone, Copy, Debug, Default
References: ColorOrder, Rotation
Ili9342c
Section titled “Ili9342c”struct Ili9342c<I> { /* private fields */ }An ILI9342C on a [DisplayInterface].
ColorOrder
Section titled “ColorOrder”enum ColorOrder { Rgb, Bgr,}Whether the panel’s subpixels are wired red-first or blue-first.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
Rotation
Section titled “Rotation”enum Rotation { Deg0, Deg90, Deg180, Deg270,}Display rotation, in 90° steps clockwise from the panel’s native landscape.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq