|
|
|
|
@ -36,27 +36,24 @@ const IS_BUSY_LOW: bool = false;
|
|
|
|
|
|
|
|
|
|
/// EPD7in5 (HD) driver
|
|
|
|
|
///
|
|
|
|
|
pub struct Epd7in5<SPI, CS, BUSY, DC, RST> { |
|
|
|
|
pub struct Epd7in5<SPI, CS, BUSY, DC, RST, DELAY> { |
|
|
|
|
/// Connection Interface
|
|
|
|
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, |
|
|
|
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>, |
|
|
|
|
/// Background Color
|
|
|
|
|
color: Color, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> |
|
|
|
|
for Epd7in5<SPI, CS, BUSY, DC, RST> |
|
|
|
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY> |
|
|
|
|
for Epd7in5<SPI, CS, BUSY, DC, RST, DELAY> |
|
|
|
|
where |
|
|
|
|
SPI: Write<u8>, |
|
|
|
|
CS: OutputPin, |
|
|
|
|
BUSY: InputPin, |
|
|
|
|
DC: OutputPin, |
|
|
|
|
RST: OutputPin, |
|
|
|
|
DELAY: DelayMs<u8>, |
|
|
|
|
{ |
|
|
|
|
fn init<DELAY: DelayMs<u8>>( |
|
|
|
|
&mut self, |
|
|
|
|
spi: &mut SPI, |
|
|
|
|
delay: &mut DELAY, |
|
|
|
|
) -> Result<(), SPI::Error> { |
|
|
|
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { |
|
|
|
|
// Reset the device
|
|
|
|
|
self.interface.reset(delay, 2); |
|
|
|
|
|
|
|
|
|
@ -99,17 +96,18 @@ where
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> |
|
|
|
|
for Epd7in5<SPI, CS, BUSY, DC, RST> |
|
|
|
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY> |
|
|
|
|
for Epd7in5<SPI, CS, BUSY, DC, RST, DELAY> |
|
|
|
|
where |
|
|
|
|
SPI: Write<u8>, |
|
|
|
|
CS: OutputPin, |
|
|
|
|
BUSY: InputPin, |
|
|
|
|
DC: OutputPin, |
|
|
|
|
RST: OutputPin, |
|
|
|
|
DELAY: DelayMs<u8>, |
|
|
|
|
{ |
|
|
|
|
type DisplayColor = Color; |
|
|
|
|
fn new<DELAY: DelayMs<u8>>( |
|
|
|
|
fn new( |
|
|
|
|
spi: &mut SPI, |
|
|
|
|
cs: CS, |
|
|
|
|
busy: BUSY, |
|
|
|
|
@ -127,21 +125,22 @@ where
|
|
|
|
|
Ok(epd) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn wake_up<DELAY: DelayMs<u8>>( |
|
|
|
|
&mut self, |
|
|
|
|
spi: &mut SPI, |
|
|
|
|
delay: &mut DELAY, |
|
|
|
|
) -> Result<(), SPI::Error> { |
|
|
|
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { |
|
|
|
|
self.init(spi, delay) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { |
|
|
|
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { |
|
|
|
|
self.wait_until_idle(); |
|
|
|
|
self.cmd_with_data(spi, Command::DeepSleep, &[0x01])?; |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { |
|
|
|
|
fn update_frame( |
|
|
|
|
&mut self, |
|
|
|
|
spi: &mut SPI, |
|
|
|
|
buffer: &[u8], |
|
|
|
|
_delay: &mut DELAY, |
|
|
|
|
) -> Result<(), SPI::Error> { |
|
|
|
|
self.wait_until_idle(); |
|
|
|
|
self.cmd_with_data(spi, Command::SetRamYAc, &[0x00, 0x00])?; |
|
|
|
|
self.cmd_with_data(spi, Command::WriteRamBw, buffer)?; |
|
|
|
|
@ -161,19 +160,24 @@ where
|
|
|
|
|
unimplemented!(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { |
|
|
|
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { |
|
|
|
|
self.command(spi, Command::MasterActivation)?; |
|
|
|
|
self.wait_until_idle(); |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { |
|
|
|
|
self.update_frame(spi, buffer)?; |
|
|
|
|
self.display_frame(spi)?; |
|
|
|
|
fn update_and_display_frame( |
|
|
|
|
&mut self, |
|
|
|
|
spi: &mut SPI, |
|
|
|
|
buffer: &[u8], |
|
|
|
|
delay: &mut DELAY, |
|
|
|
|
) -> Result<(), SPI::Error> { |
|
|
|
|
self.update_frame(spi, buffer, delay)?; |
|
|
|
|
self.display_frame(spi, delay)?; |
|
|
|
|
Ok(()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { |
|
|
|
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> { |
|
|
|
|
let pixel_count = WIDTH * HEIGHT / 8; |
|
|
|
|
let background_color_byte = self.color.get_byte_value(); |
|
|
|
|
|
|
|
|
|
@ -221,13 +225,14 @@ where
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl<SPI, CS, BUSY, DC, RST> Epd7in5<SPI, CS, BUSY, DC, RST> |
|
|
|
|
impl<SPI, CS, BUSY, DC, RST, DELAY> Epd7in5<SPI, CS, BUSY, DC, RST, DELAY> |
|
|
|
|
where |
|
|
|
|
SPI: Write<u8>, |
|
|
|
|
CS: OutputPin, |
|
|
|
|
BUSY: InputPin, |
|
|
|
|
DC: OutputPin, |
|
|
|
|
RST: OutputPin, |
|
|
|
|
DELAY: DelayMs<u8>, |
|
|
|
|
{ |
|
|
|
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> { |
|
|
|
|
self.interface.cmd(spi, command) |
|
|
|
|
|