[][src]Module ssd1309::builder

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
use display_interface_spi::SPIInterface;

let spi = /* SPI interface from your HAL of choice */;
let dc = /* GPIO data/command select pin */;

let spi_interface = SPIInterfaceNoCS::new(spi, dc);

Builder::new().connect(spi_interface);

Connect over I2C, changing rotation

This example is not tested
use display_interface_i2c::I2CInterface;

let i2c = /* I2C interface from your HAL of choice */;

let i2c_interface = I2CInterface::new(i2c, 0x3D, 0x40);

Builder::new()
    .with_rotation(DisplayRotation::Rotate180)
    .connect(i2c_interface);

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 GraphicsMode mode:

This example is not tested
let display: GraphicsMode<_> = Builder::new().connect(interface).into();

Structs

Builder

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

NoOutputPin

Represents an unused output pin.