#![deny(missing_docs)]
#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(
not(all(feature = "async", feature = "framebuffer")),
allow(rustdoc::broken_intra_doc_links)
)]
#[cfg(feature = "async")]
pub mod asynch;
pub mod blocking;
pub mod cmd;
mod command;
#[cfg(feature = "framebuffer")]
pub mod framebuffer;
pub mod instr;
pub mod presets;
pub use command::WriteCommand;
use core::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum InitStep<'a> {
Cmd(u8, &'a [u8]),
DelayMs(u32),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PowerMode {
High,
Low,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error<S, P> {
Spi(S),
Pin(P),
}
impl<S: fmt::Debug, P: fmt::Debug> fmt::Display for Error<S, P> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Spi(e) => write!(f, "SPI error: {e:?}"),
Error::Pin(e) => write!(f, "GPIO pin error: {e:?}"),
}
}
}
impl<S: fmt::Debug, P: fmt::Debug> core::error::Error for Error<S, P> {}
#[cfg(feature = "defmt")]
impl<S: fmt::Debug, P: fmt::Debug> defmt::Format for Error<S, P> {
fn format(&self, f: defmt::Formatter) {
match self {
Error::Spi(e) => defmt::write!(f, "SPI error: {}", defmt::Debug2Format(e)),
Error::Pin(e) => defmt::write!(f, "GPIO pin error: {}", defmt::Debug2Format(e)),
}
}
}