Skip to main content

Crate st7789v2

Crate st7789v2 

Source
Expand description

§ST7789V2 Driver Crate

An embedded-graphics compatible driver for the Sitronix ST7789V2 TFT-LCD display controller (240x320, 262K color).

The driver is generic over the communication interface and reset pin, allowing it to work with SPI or any other bus by implementing ControllerInterface and ResetInterface.

§Buffering modes

The builder defaults to an unbuffered instance. Three additional modes are available when the embedded-graphics feature is enabled (default):

ModeTypeRAMDrawTargetFlush
Unbuffered (default)St7789v2<I, R>0Nosend_pixels()
Unbuffered DrawTargetSt7789v2<I, R, Unbuffered<C>>0Yes (fallible)Each draw -> HW
Single-bufferedSt7789v2<I, R, Buffered<C>>1x FBYes (infallible)flush() (dirty-aware)
Double-bufferedSt7789v2<I, R, DoubleBuffered<C>>2x FBYes (infallible)swap_buffers() + flush_front()

§Single-buffered with dirty tracking

The recommended mode for most applications. All DrawTarget operations automatically track which rows were modified. flush() sends only the dirty band — a single contiguous slice with no allocation. If nothing changed, flush() is a no-op.

let mut display = St7789v2::builder(iface, reset, size)
    .with_init_commands(&PANEL_INIT)
    .buffered::<Rgb565>(Framebuffer::heap::<FB_SIZE>())
    .build(ColorMode::Rgb565, &mut delay)?;

Circle::new(Point::new(100, 100), 50)
    .into_styled(PrimitiveStyle::with_fill(Rgb565::RED))
    .draw(&mut display)?;
display.flush()?;  // sends only the affected rows

§Platform access

interface_mut() exposes the underlying ControllerInterface for platform-specific operations (e.g. non-blocking DMA flush) that go beyond the trait’s synchronous API.

See commands for the full register set from the datasheet.

Modules§

commands

Structs§

Buffered
Single-buffered mode with dirty-band tracking.
DisplaySize
Display dimensions in pixels.
DoubleBuffered
Double-buffered mode for DMA overlap.
St7789v2
Driver for the ST7789V2 TFT-LCD display controller.
St7789v2Builder
Builder for St7789v2.
Unbuffered
Unbuffered DrawTarget — each draw sends pixels directly to the display.

Enums§

ColorMode
Pixel color format for the controller’s COLMOD register.
DriverError
Driver errors, generic over interface and reset error types.
Framebuffer
Holds either a static or heap-allocated framebuffer.

Traits§

ControllerInterface
Communication interface for the ST7789V2 (SPI, parallel, etc.).
ResetInterface
Hardware reset control for the ST7789V2.
St7789v2Color
Pixel color encoding for the ST7789V2 framebuffer.

Functions§

framebuffer_size
Compute framebuffer size in bytes for a given display and color mode.

Type Aliases§

DriverResult
Convenience alias for results from driver operations.