mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
API change to partially fix #70
This commit is contained in:
+34
-28
@@ -31,25 +31,22 @@ mod graphics;
|
||||
pub use self::graphics::Display1in54c;
|
||||
|
||||
/// EPD1in54c driver
|
||||
pub struct EPD1in54c<SPI, CS, BUSY, DC, RST> {
|
||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
||||
pub struct EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||
color: Color,
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
for EPD1in54c<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> {
|
||||
// Based on Reference Program Code from:
|
||||
// https://www.waveshare.com/w/upload/a/ac/1.54inch_e-Paper_Module_C_Specification.pdf
|
||||
// and:
|
||||
@@ -76,14 +73,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
|
||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
for EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
where
|
||||
SPI: Write<u8>,
|
||||
CS: OutputPin,
|
||||
BUSY: InputPin,
|
||||
DC: OutputPin,
|
||||
RST: OutputPin,
|
||||
DELAY: DelayMs<u8>,
|
||||
{
|
||||
fn update_color_frame(
|
||||
&mut self,
|
||||
@@ -114,17 +112,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
for EPD1in54c<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,
|
||||
@@ -142,7 +141,7 @@ where
|
||||
Ok(epd)
|
||||
}
|
||||
|
||||
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.command(spi, Command::POWER_OFF)?;
|
||||
@@ -152,11 +151,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -176,7 +171,12 @@ where
|
||||
HEIGHT
|
||||
}
|
||||
|
||||
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.update_achromatic_frame(spi, buffer)?;
|
||||
|
||||
// Clear the chromatic layer
|
||||
@@ -201,21 +201,26 @@ 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::DISPLAY_REFRESH)?;
|
||||
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> {
|
||||
self.wait_until_idle();
|
||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||
|
||||
@@ -243,13 +248,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54c<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54c<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)
|
||||
@@ -269,7 +275,7 @@ where
|
||||
}
|
||||
|
||||
fn wait_until_idle(&mut self) {
|
||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||
}
|
||||
|
||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||
|
||||
Reference in New Issue
Block a user