diff --git a/examples/raspberry_pi_inky_phat.rs b/examples/raspberry_pi_inky_phat.rs index 6830b1d..ada528d 100644 --- a/examples/raspberry_pi_inky_phat.rs +++ b/examples/raspberry_pi_inky_phat.rs @@ -63,11 +63,11 @@ fn main() -> Result<(), std::io::Error> { // 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 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"); @@ -92,7 +92,7 @@ fn main() -> Result<(), std::io::Error> { // Initialise display controller let mut delay = Delay {}; - let controller = ssd1675::Interface::new(spi, cs, busy, dc, reset); + let controller = ssd1675::Interface::new(spi, busy, dc, reset); let mut black_buffer = [0u8; ROWS as usize * COLS as usize / 8]; let mut red_buffer = [0u8; ROWS as usize * COLS as usize / 8]; diff --git a/src/interface.rs b/src/interface.rs index 433f0cf..88d32c5 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -80,12 +80,9 @@ pub trait DisplayInterface { /// // Build the interface from the pins and SPI device /// let controller = ssd1675::Interface::new(spi, cs, busy, dc, reset); -#[allow(dead_code)] // Prevent warning about CS being unused -pub struct Interface { +pub struct Interface { /// SPI interface spi: SPI, - /// CS (chip select) for SPI (output) - cs: CS, /// Active low busy pin (input) busy: BUSY, /// Data/Command Control Pin (High for data, Low for command) (output) @@ -94,19 +91,17 @@ pub struct Interface { reset: RESET, } -impl Interface +impl Interface where SPI: hal::blocking::spi::Write, - CS: hal::digital::v2::OutputPin, BUSY: hal::digital::v2::InputPin, DC: hal::digital::v2::OutputPin, RESET: hal::digital::v2::OutputPin, { /// Create a new Interface from embedded hal traits. - pub fn new(spi: SPI, cs: CS, busy: BUSY, dc: DC, reset: RESET) -> Self { + pub fn new(spi: SPI, busy: BUSY, dc: DC, reset: RESET) -> Self { Self { spi, - cs, busy, dc, reset, @@ -114,9 +109,6 @@ where } fn write(&mut self, data: &[u8]) -> Result<(), SPI::Error> { - // Select the controller with chip select (CS) - // self.cs.set_low(); - // Linux has a default limit of 4096 bytes per SPI transfer // https://github.com/torvalds/linux/blob/ccda4af0f4b92f7b4c308d3acc262f4a7e3affad/drivers/spi/spidev.c#L93 if cfg!(target_os = "linux") { @@ -134,11 +126,9 @@ where } } -impl DisplayInterface for Interface +impl DisplayInterface for Interface where SPI: hal::blocking::spi::Write, - CS: hal::digital::v2::OutputPin, - CS::Error: Debug, BUSY: hal::digital::v2::InputPin, DC: hal::digital::v2::OutputPin, DC::Error: Debug,