-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e808fb9
commit 0a81216
Showing
20 changed files
with
665 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
//! [Error] module for [super::Display] | ||
use display_interface::DisplayError; | ||
//! Error module for [super::Display] | ||
/// Error returned by [`Builder::init`](crate::Builder). | ||
#[derive(Debug)] | ||
pub enum InitError<PE> { | ||
pub enum InitError<DI, P> { | ||
/// Error caused by the display interface. | ||
DisplayError, | ||
DisplayError(DI), | ||
/// Error caused by the reset pin's [`OutputPin`](embedded_hal::digital::OutputPin) implementation. | ||
Pin(PE), | ||
} | ||
|
||
/// | ||
/// Alias of [DisplayError] for out-of-init use cases | ||
/// since the pin error is only possible during [super::Builder] use | ||
/// | ||
pub type Error = DisplayError; | ||
|
||
impl<PE> From<DisplayError> for InitError<PE> { | ||
fn from(_: DisplayError) -> Self { | ||
InitError::DisplayError | ||
} | ||
Pin(P), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! Interface traits and implementations | ||
/// Command interface | ||
pub trait CommandInterface { | ||
/// Error type | ||
type Error: core::fmt::Debug; | ||
|
||
/// Send a command with optional parameters | ||
/// | ||
/// [`CommandInterface::flush`] must be called to ensure the data is actually sent | ||
fn send_command(&mut self, command: u8, args: &[u8]) -> Result<(), Self::Error>; | ||
|
||
/// Sends any remaining buffered data | ||
fn flush(&mut self) -> Result<(), Self::Error>; | ||
} | ||
|
||
/// Pixel interface | ||
pub trait PixelInterface<P: Copy>: CommandInterface { | ||
/// Send a single pixel | ||
/// | ||
/// `WriteMemoryStart` must be sent before calling this function | ||
/// | ||
/// [`CommandInterface::flush`] must be called to ensure the data is actually sent | ||
fn send_pixel(&mut self, pixel: P) -> Result<(), Self::Error>; | ||
|
||
/// Send the same pixel value multiple times | ||
/// | ||
/// `WriteMemoryStart` must be sent before calling this function | ||
/// | ||
/// [`CommandInterface::flush`] must be called to ensure the data is actually sent | ||
fn send_repeated_pixel(&mut self, pixel: P, count: u32) -> Result<(), Self::Error>; | ||
} | ||
|
||
mod spi; | ||
pub use spi::*; | ||
|
||
mod parallel; | ||
pub use parallel::*; |
Oops, something went wrong.