[−][src]Module ssd1306::builder
Interface factory
This is the easiest way to create a driver instance, with the ability to set various parameters of the driver.
To finish the builder and produce a connected display interface, call .connect_i2c(i2c)
or
.connect_spi(spi, dc)
. The builder will be consumed into a
mode::RawMode
object which can be coerced into a richer
display mode like mode::Graphics for drawing
primitives and text.
Examples
Connect over SPI with default rotation (0 deg) and size (128x64):
use ssd1306::Builder; Builder::new().connect_spi(spi, dc);
Connect over I2C, changing lots of options
use ssd1306::{prelude::*, Builder}; Builder::new() .with_rotation(DisplayRotation::Rotate180) .with_i2c_addr(0x3D) .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:
use ssd1306::{prelude::*, Builder}; let display: TerminalMode<_> = Builder::new().connect_spi(spi, dc).into();
Structs
Builder | Builder struct. Driver options and interface are set using its methods. |