use embedded_hal::delay::DelayNs;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ColorMode {
BlackWhite,
TriColor,
QuadColor,
SevenColor,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SevenColor {
Black = 0x00,
White = 0x01,
Yellow = 0x02,
Red = 0x03,
Orange = 0x04,
Blue = 0x05,
Green = 0x06,
Clean = 0x07,
}
impl SevenColor {
pub const fn pack(pixel_high: Self, pixel_low: Self) -> u8 {
((pixel_high as u8) << 4) | (pixel_low as u8)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ColorChannel {
BlackWhite,
RedYellow,
Red,
Yellow,
Color7(u8),
}
pub trait EpdPanel {
const WIDTH: u32;
const HEIGHT: u32;
const COLOR_MODE: ColorMode = ColorMode::BlackWhite;
fn vcom(&self) -> Option<u8> {
None
}
fn custom_lut(&self) -> Option<&'static [u8]> {
None
}
fn gate_voltage(&self) -> Option<u8> {
None
}
}
pub trait EpdController<BUS> {
type Error;
fn init_sequence<DELAY: DelayNs>(
&mut self,
bus: &mut BUS,
delay: &mut DELAY,
) -> Result<(), Self::Error>;
fn set_window(
&mut self,
bus: &mut BUS,
x_start: u32,
y_start: u32,
x_end: u32,
y_end: u32,
) -> Result<(), Self::Error>;
fn set_cursor(&mut self, bus: &mut BUS, x: u32, y: u32) -> Result<(), Self::Error>;
fn write_frame(
&mut self,
bus: &mut BUS,
channel: ColorChannel,
data: &[u8],
) -> Result<(), Self::Error>;
fn write_frame_pattern(
&mut self,
bus: &mut BUS,
channel: ColorChannel,
byte: u8,
count: usize,
) -> Result<(), Self::Error>;
fn trigger_refresh<DELAY: DelayNs>(
&mut self,
bus: &mut BUS,
delay: &mut DELAY,
) -> Result<(), Self::Error>;
fn sleep<DELAY: DelayNs>(
&mut self,
bus: &mut BUS,
delay: &mut DELAY,
) -> Result<(), Self::Error>;
}