use display_interface::AsyncWriteOnlyDataCommand;
use hal::digital::OutputPin;
use crate::{
displayrotation::DisplayRotation,
mode::{displaymode::DisplayMode, raw::RawMode},
properties::DisplayProperties,
};
#[derive(Clone, Copy)]
pub struct Builder<DV> {
variant: DV,
rotation: DisplayRotation,
}
impl<DV> Builder<DV> {
pub fn new(variant: DV) -> Builder<DV> {
Builder::<DV> {
variant,
rotation: DisplayRotation::Rotate0,
}
}
}
impl<DV> Builder<DV> {
pub fn with_rotation(self, rotation: DisplayRotation) -> Self {
Self { rotation, ..self }
}
pub fn connect<DI>(self, interface: DI) -> DisplayMode<RawMode<DV, DI>>
where
DI: AsyncWriteOnlyDataCommand,
DV: crate::display::DisplayVariant,
{
let properties = DisplayProperties::new(self.variant, interface, self.rotation);
DisplayMode::<RawMode<DV, DI>>::new(properties)
}
}
#[derive(Clone, Copy)]
pub enum NoOutputPin {}
impl OutputPin for NoOutputPin {
fn set_low(&mut self) -> Result<(), Self::Error> {
Ok(())
}
fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(())
}
}
impl hal::digital::ErrorType for NoOutputPin {
type Error = core::convert::Infallible;
}
#[cfg(test)]
mod tests {
use super::NoOutputPin;
use embedded_hal::digital::v2::OutputPin;
enum SomeError {}
struct SomeDriver<P: OutputPin<Error = SomeError>> {
#[allow(dead_code)]
p: P,
}
#[test]
fn test_output_pin() {
let p = NoOutputPin::new();
let _d = SomeDriver { p };
assert!(true);
}
}