pub struct Interface<SPI, CS, BUSY, DC, RESET> { /* private fields */ }
Expand description
The hardware interface to a display.
Example
This example uses the Linux implementation of the embedded HAL traits to build a display interface. For a complete example see the Raspberry Pi Inky pHAT example.
ⓘ
extern crate linux_embedded_hal;
use linux_embedded_hal::spidev::{self, SpidevOptions};
use linux_embedded_hal::sysfs_gpio::Direction;
use linux_embedded_hal::Delay;
use linux_embedded_hal::{Pin, Spidev};
extern crate ssd1675;
use ssd1675::{Builder, Color, Dimensions, Display, GraphicDisplay, Rotation};
// Configure SPI
let mut spi = Spidev::open("/dev/spidev0.0").expect("SPI device");
let options = SpidevOptions::new()
.bits_per_word(8)
.max_speed_hz(4_000_000)
.mode(spidev::SPI_MODE_0)
.build();
spi.configure(&options).expect("SPI configuration");
// https://pinout.xyz/pinout/inky_phat
// Configure Digital I/O Pins
let cs = Pin::new(8); // BCM8
cs.export().expect("cs export");
while !cs.is_exported() {}
cs.set_direction(Direction::Out).expect("CS Direction");
cs.set_value(1).expect("CS Value set to 1");
let busy = Pin::new(17); // BCM17
busy.export().expect("busy export");
while !busy.is_exported() {}
busy.set_direction(Direction::In).expect("busy Direction");
let dc = Pin::new(22); // BCM22
dc.export().expect("dc export");
while !dc.is_exported() {}
dc.set_direction(Direction::Out).expect("dc Direction");
dc.set_value(1).expect("dc Value set to 1");
let reset = Pin::new(27); // BCM27
reset.export().expect("reset export");
while !reset.is_exported() {}
reset
.set_direction(Direction::Out)
.expect("reset Direction");
reset.set_value(1).expect("reset Value set to 1");
// Build the interface from the pins and SPI device
let controller = ssd1675::Interface::new(spi, cs, busy, dc, reset);
Implementations
sourceimpl<SPI, CS, BUSY, DC, RESET> Interface<SPI, CS, BUSY, DC, RESET> where
SPI: Write<u8>,
CS: OutputPin,
BUSY: InputPin,
DC: OutputPin,
RESET: OutputPin,
impl<SPI, CS, BUSY, DC, RESET> Interface<SPI, CS, BUSY, DC, RESET> where
SPI: Write<u8>,
CS: OutputPin,
BUSY: InputPin,
DC: OutputPin,
RESET: OutputPin,
Trait Implementations
sourceimpl<SPI, CS, BUSY, DC, RESET> DisplayInterface for Interface<SPI, CS, BUSY, DC, RESET> where
SPI: Write<u8>,
CS: OutputPin,
CS::Error: Debug,
BUSY: InputPin,
DC: OutputPin,
DC::Error: Debug,
RESET: OutputPin,
RESET::Error: Debug,
impl<SPI, CS, BUSY, DC, RESET> DisplayInterface for Interface<SPI, CS, BUSY, DC, RESET> where
SPI: Write<u8>,
CS: OutputPin,
CS::Error: Debug,
BUSY: InputPin,
DC: OutputPin,
DC::Error: Debug,
RESET: OutputPin,
RESET::Error: Debug,
Auto Trait Implementations
impl<SPI, CS, BUSY, DC, RESET> RefUnwindSafe for Interface<SPI, CS, BUSY, DC, RESET> where
BUSY: RefUnwindSafe,
CS: RefUnwindSafe,
DC: RefUnwindSafe,
RESET: RefUnwindSafe,
SPI: RefUnwindSafe,
impl<SPI, CS, BUSY, DC, RESET> Send for Interface<SPI, CS, BUSY, DC, RESET> where
BUSY: Send,
CS: Send,
DC: Send,
RESET: Send,
SPI: Send,
impl<SPI, CS, BUSY, DC, RESET> Sync for Interface<SPI, CS, BUSY, DC, RESET> where
BUSY: Sync,
CS: Sync,
DC: Sync,
RESET: Sync,
SPI: Sync,
impl<SPI, CS, BUSY, DC, RESET> Unpin for Interface<SPI, CS, BUSY, DC, RESET> where
BUSY: Unpin,
CS: Unpin,
DC: Unpin,
RESET: Unpin,
SPI: Unpin,
impl<SPI, CS, BUSY, DC, RESET> UnwindSafe for Interface<SPI, CS, BUSY, DC, RESET> where
BUSY: UnwindSafe,
CS: UnwindSafe,
DC: UnwindSafe,
RESET: UnwindSafe,
SPI: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcefn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcefn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.