Implement Error for error types
This commit is contained in:
parent
420e9f098d
commit
16d8071a03
1 changed files with 7 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ use embedded_hal::{
|
|||
digital::{InputPin, OutputPin},
|
||||
spi::{Operation, SpiDevice},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
const EPD_WIDTH: usize = 240;
|
||||
const EPD_HEIGHT: usize = 320;
|
||||
|
|
@ -27,25 +28,31 @@ pub struct EPaperDisplay<BusyPin, ResetPin, DcPin, SpiDevice, Delay> {
|
|||
delay: Delay,
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
/// An error that may occur during display initialisation.
|
||||
pub enum InitError<ResetError, DcError, SpiError> {
|
||||
/// This variant is for any error with setting the level of the reset pin.
|
||||
///
|
||||
/// This variant may be uninhabited if the `ResetPin` type parameter for [EPaperDisplay] is one that
|
||||
/// doesn't produce errors.
|
||||
#[error("While initialising the display, an error occurred when toggling the reset pin: {0}")]
|
||||
ResetError(ResetError),
|
||||
/// This variant is for errors when attempting to communicate with the display controller after reset.
|
||||
#[error("While initialising the display, a communication error occurred: {0}")]
|
||||
WriteError(WriteError<DcError, SpiError>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
/// An error when trying to communicate with the display controller.
|
||||
pub enum WriteError<DcError, SpiError> {
|
||||
/// This variant is for any error with setting the level of the DC (Data/Command) pin.
|
||||
///
|
||||
/// This variant may be uninhabited if the `DcPin` type parameter for [EPaperDisplay] is one that
|
||||
/// doesn't produce errors.
|
||||
#[error("Failed to set the data/command line: {0}")]
|
||||
DcError(DcError),
|
||||
/// This variant is for errors produced by the SPI driver.
|
||||
#[error("Failed to perform SPI operations: {0}")]
|
||||
SpiError(SpiError),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue