Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace custom error type in favour of Debug constraints #10

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;