mirror of
https://github.com/Feliix42/ssd1675.git
synced 2024-11-23 19:26:31 +00:00
Replace custom error type in favour of Debug constraints
This commit is contained in:
parent
9d8b68d78e
commit
f27c2c6f68
3 changed files with 10 additions and 25 deletions
16
src/error.rs
16
src/error.rs
|
@ -1,16 +0,0 @@
|
|||
use core::fmt::{self, Debug};
|
||||
use hal::digital::v2::OutputPin;
|
||||
|
||||
pub enum Error<GPIO: OutputPin> {
|
||||
/// A GPIO could not be set.
|
||||
Gpio(GPIO::Error),
|
||||
}
|
||||
|
||||
impl<GPIO: OutputPin> Debug for Error<GPIO>
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::Gpio(_) => write!(f, "GPIO error"),
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue