Skip to content

Commit

Permalink
Replace custom error type in favour of Debug constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
wezm committed Mar 10, 2020
1 parent 9d8b68d commit f27c2c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 25 deletions.
16 changes: 0 additions & 16 deletions src/error.rs

This file was deleted.

17 changes: 10 additions & 7 deletions src/interface.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::Error;
use core::fmt::Debug;
use hal;

// Section 15.2 of the HINK-E0213A07 data sheet says to hold for 10ms
Expand Down Expand Up @@ -138,29 +138,32 @@ impl<SPI, CS, BUSY, DC, RESET> DisplayInterface for Interface<SPI, CS, BUSY, DC,
where
SPI: hal::blocking::spi::Write<u8>,
CS: hal::digital::v2::OutputPin,
CS::Error: Debug,
BUSY: hal::digital::v2::InputPin,
DC: hal::digital::v2::OutputPin,
DC::Error: Debug,
RESET: hal::digital::v2::OutputPin,
RESET::Error: Debug,
{
type Error = SPI::Error;

fn reset<D: hal::blocking::delay::DelayMs<u8>>(&mut self, delay: &mut D){
self.reset.set_low().map_err::<Error<RESET>, _>(Error::Gpio).unwrap();
fn reset<D: hal::blocking::delay::DelayMs<u8>>(&mut self, delay: &mut D) {
self.reset.set_low().unwrap();
delay.delay_ms(RESET_DELAY_MS);
self.reset.set_high().map_err::<Error<RESET>, _>(Error::Gpio).unwrap();
self.reset.set_high().unwrap();
delay.delay_ms(RESET_DELAY_MS);
}

fn send_command(&mut self, command: u8) -> Result<(), Self::Error> {
self.dc.set_low().map_err::<Error<DC>, _>(Error::Gpio).unwrap();
self.dc.set_low().unwrap();
self.write(&[command])?;
self.dc.set_high().map_err::<Error<DC>, _>(Error::Gpio).unwrap();
self.dc.set_high().unwrap();

Ok(())
}

fn send_data(&mut self, data: &[u8]) -> Result<(), Self::Error> {
self.dc.set_high().map_err::<Error<DC>, _>(Error::Gpio).unwrap();
self.dc.set_high().unwrap();
self.write(data)
}

Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ mod color;
pub mod command;
pub mod config;
pub mod display;
pub mod error;
pub mod graphics;
pub mod interface;

pub use color::Color;
pub use config::Builder;
pub use display::{Dimensions, Display, Rotation};
pub use error::Error;
pub use graphics::GraphicDisplay;
pub use interface::DisplayInterface;
pub use interface::Interface;

0 comments on commit f27c2c6

Please sign in to comment.