Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/embedded/display"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
graphics |
std/graphics |
display.dodo |
hal |
std/embedded/hal |
display.dodo |
Interface
Interface · Source
Bytes to a display controller.
pub interface Interface {
// Send command bytes.
fn write_command(&mut self, bytes: &[u8]) -> void!hal.Error
// Send data bytes: command parameters or pixels.
fn write_data(&mut self, bytes: &[u8]) -> void!hal.Error
}
SpiInterface
Struct · Source
A display on an SPI bus with a data/command pin, and a chip-select pin unless the panel’s is wired low. Each write selects the panel, sends its bytes, and deselects it. Configure the bus with the clock and mode the controller’s datasheet gives: SPI mode 3 for most ST7789 boards (mode 0 for those with a chip-select pin works too) and mode 0 for the SSD1306.
pub struct SpiInterface<B: hal.Spi, P: hal.OutputPin> {
// Private implementation fields omitted.
}
SpiInterface.new
Function · Source
Takes the bus and pins, and deselects the panel.
pub fn new(bus: B, data_command: P, select: Option<P>) -> SpiInterface<B, P> from(bus, data_command, select)
SpiInterface.write_command
Function · Source
pub fn write_command(&mut self, bytes: &[u8]) -> void!hal.Error
SpiInterface.write_data
Function · Source
pub fn write_data(&mut self, bytes: &[u8]) -> void!hal.Error
SpiInterface.bus
Function · Source
The bus, for example to reconfigure it between frames.
pub fn bus(&mut self) -> &mut B from(self)
SpiInterface.data_command
Function · Source
The data/command pin.
pub fn data_command(&self) -> &P from(self)
SpiInterface.release
Function · Source
Give back the bus. The pins are dropped with the interface.
pub fn release(self) -> B from(self)
I2C_CHUNK
Constant · Source
The largest number of bytes after the control byte in one I2C write. Larger writes are split, which costs one address and control byte each.
pub const I2C_CHUNK: usize = 128
I2C_COMMANDS
Constant · Source
Control bytes that start each I2C write: what follows is commands, or data.
pub const I2C_COMMANDS: u8 = 0x00
I2C_DATA
Constant · Source
pub const I2C_DATA: u8 = 0x40
I2cInterface
Struct · Source
A display on an I2C bus at a 7-bit address, such as 0x3C for most SSD1306 modules. Each write is one or more bus writes of a control byte followed by up to I2C_CHUNK bytes.
pub struct I2cInterface<B: hal.I2c> {
// Private implementation fields omitted.
}
I2cInterface.new
Function · Source
pub fn new(bus: B, address: u8) -> I2cInterface<B> from(bus)
I2cInterface.write_command
Function · Source
pub fn write_command(&mut self, bytes: &[u8]) -> void!hal.Error
I2cInterface.write_data
Function · Source
pub fn write_data(&mut self, bytes: &[u8]) -> void!hal.Error
I2cInterface.address
Function · Source
pub fn address(&self) -> u8
I2cInterface.bus
Function · Source
The bus, for example to talk to other devices on it between frames.
pub fn bus(&mut self) -> &mut B from(self)
I2cInterface.release
Function · Source
Give back the bus.
pub fn release(self) -> B from(self)
reset
Function · Source
Pulse a controller’s active-low reset pin and wait until the controller is ready: 1 ms high, 20 us low, then 120 ms, the longest an ST7789 or SSD1306 needs. Call it before creating a driver for a panel whose reset pin is wired to a GPIO; drivers also reset by command.
pub fn reset<P: hal.OutputPin, D: hal.Delay>(pin: &mut P, delay: &mut D)
visible
Function · Source
The part of
dirtya display ofwidthxheightshows fromcanvas: inside the canvas’s bounds and the display, or an empty rectangle. For drivers implementing graphics.Display.
pub fn visible(canvas: &graphics.Canvas, dirty: graphics.Rect, width: u32, height: u32) -> graphics.Rect