diff --git a/src/lib.rs b/src/lib.rs index 8394bbc..f0376f9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 { delay: Delay, } +#[derive(Debug, Error)] /// An error that may occur during display initialisation. pub enum InitError { /// 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), } +#[derive(Debug, Error)] /// An error when trying to communicate with the display controller. pub enum WriteError { /// 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), }