Module ssd1306::builder[][src]

Interface factory

This is the easiest way to create a driver instance. You can set various parameters of the driver and give it an interface to use. The builder will return a mode::RawMode object which you should coerce to a richer display mode, like mode::Graphics for drawing primitives and text.

Examples

Connect over SPI with default rotation (0 deg) and size (128x64):

This example is not tested
let spi = /* SPI interface from your HAL of choice */;
let dc = /* GPIO data/command select pin */;

Builder::new().connect_spi(spi, dc);

Connect over I2C, changing lots of options

This example is not tested
let i2c = /* I2C interface from your HAL of choice */;

Builder::new()
    .with_rotation(DisplayRotation::Rotate180)
    .with_i2c_addr(0x3D)
    .with_size(DisplaySize::Display128x32)
    .connect_i2c(i2c);

The above examples will produce a RawMode instance by default. You need to coerce them into a mode by specifying a type on assignment. For example, to use TerminalMode mode:

This example is not tested
let spi = /* SPI interface from your HAL of choice */;
let dc = /* GPIO data/command select pin */;

let display: TerminalMode<_> = Builder::new().connect_spi(spi, dc).into();

Structs

Builder

Builder struct. Driver options and interface are set using its methods.