[][src]Struct ssd1675::interface::Interface

pub struct Interface<SPI, CS, BUSY, DC, RESET> { /* fields omitted */ }

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.

This example is not tested
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);

Methods

impl<SPI, CS, BUSY, DC, RESET> Interface<SPI, CS, BUSY, DC, RESET> where
    SPI: Write<u8>,
    CS: OutputPin,
    BUSY: InputPin,
    DC: OutputPin,
    RESET: OutputPin
[src]

pub fn new(spi: SPI, cs: CS, busy: BUSY, dc: DC, reset: RESET) -> Self[src]

Create a new Interface from embedded hal traits.

Trait Implementations

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
[src]

type Error = SPI::Error

Auto Trait Implementations

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.