ST7789 Display Driver
This crate provides an async driver for the ST7789 display controller, implementing the Panel trait to be used with the display-driver crate.
Usage
This driver is designed to work with the display-driver crate. You can use the DisplayDriver struct to drive the display.
1. Choose a Spec
The ST7789 has many variations in resolution and internal offsets. This crate provides Generic types that map to common variations, as well as specific Vendor specs for known modules.
2. Implementation Example
use ;
// The `Spec` (Generic240x240Type1) defines the hardware-specific constants (Gamma, Voltage).
use ;
// 1. Configure Reset
let reset_opt = new_pin;
// 2. Create the Panel instance using a Spec
let panel = new;
// 3. Bind Bus and Panel, Configure, and Initialize
let mut display = builder
.with_color_format
.with_orientation
.init.await.unwrap;
// Now you can use `display` to draw:
display.write_frame.await.unwrap;
Full examples can be found at examples
Specs
Because ST7789 panels come in various resolutions and offsets, we use a Spec trait (combining PanelSpec and St7789Spec).
Generic Specs (spec::generic)
| Type | Resolution | Offset (X, Y) | Rotated Offset | Note |
|---|---|---|---|---|
Generic240x320Type1 |
240x320 | (0, 0) | (0, 0) | 2.4" |
Generic240x240Type1 |
240x240 | (0, 0) | (0, 80) | 1.3", 1.54" |
Generic135x240Type1 |
135x240 | (52, 40) | (53, 40) | 1.14" |
Generic240x280Type1 |
240x280 | (0, 20) | - | 1.69" |
Generic172x320Type1 |
172x320 | (34, 0) | - | 1.47" |
Generic170x320Type1 |
170x320 | (35, 0) | - | 1.9" |
Vendor Specs (spec::vendor_specs)
| Type | Description |
|---|---|
TB154 |
1.54 inch 240x240 |
GMT114_02 |
1.14 inch 135x240 |
N114_2413THBIG01_H13 |
1.14 inch 135x240 |
Implementing a Custom Spec
If the built-in specs don't match your display, you can define your own.
[!TIP] You can use the
impl_st7789_generic!macro to use standard initialization parameters (Gamma, Voltages, etc.) while customizing resolution and offsets.
use ;
// 1. Define your type
;
// 2. Configure Resolution & Offsets
// 3. Implement St7789Spec
// Option A: Use default generic initialization parameters
impl_st7789_generic!;
// Option B: Manual implementation for fine-tuning
// impl St7789Spec for MyCustomPanel {
// const PORCTRL_PARAMS: [u8; 5] = ...;
// ...
// }
License
This project is under Apache License, Version 2.0 (LICENSE or http://www.apache.org/licenses/LICENSE-2.0).