mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-04 06:16:42 +00:00
API change to partially fix #70
This commit is contained in:
+30
-25
@@ -72,28 +72,25 @@ pub use crate::epd1in54::graphics::Display1in54;
|
||||
|
||||
/// EPD1in54 driver
|
||||
///
|
||||
pub struct EPD1in54<SPI, CS, BUSY, DC, RST> {
|
||||
pub struct EPD1in54<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||
/// SPI
|
||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||
/// Color
|
||||
background_color: Color,
|
||||
/// Refresh LUT
|
||||
refresh: RefreshLUT,
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54<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> {
|
||||
self.interface.reset(delay, 10);
|
||||
|
||||
// 3 Databytes:
|
||||
@@ -142,14 +139,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
||||
for EPD1in54<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
for EPD1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
where
|
||||
SPI: Write<u8, Error = E>,
|
||||
CS: OutputPin,
|
||||
BUSY: InputPin,
|
||||
DC: OutputPin,
|
||||
RST: OutputPin,
|
||||
DELAY: DelayMs<u8>,
|
||||
{
|
||||
type DisplayColor = Color;
|
||||
fn width(&self) -> u32 {
|
||||
@@ -160,7 +158,7 @@ where
|
||||
HEIGHT
|
||||
}
|
||||
|
||||
fn new<DELAY: DelayMs<u8>>(
|
||||
fn new(
|
||||
spi: &mut SPI,
|
||||
cs: CS,
|
||||
busy: BUSY,
|
||||
@@ -181,15 +179,11 @@ 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();
|
||||
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
||||
//TODO: is 0x00 needed here or would 0x01 be even more efficient?
|
||||
@@ -198,7 +192,12 @@ where
|
||||
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.use_full_frame(spi)?;
|
||||
self.interface
|
||||
@@ -225,7 +224,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
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.wait_until_idle();
|
||||
// enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version)
|
||||
//TODO: test control_1 or control_2 with default value 0xFF (from the datasheet)
|
||||
@@ -239,13 +238,18 @@ where
|
||||
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();
|
||||
self.use_full_frame(spi)?;
|
||||
|
||||
@@ -285,16 +289,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54<SPI, CS, BUSY, DC, RST>
|
||||
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||
where
|
||||
SPI: Write<u8>,
|
||||
CS: OutputPin,
|
||||
BUSY: InputPin,
|
||||
DC: OutputPin,
|
||||
RST: OutputPin,
|
||||
DELAY: DelayMs<u8>,
|
||||
{
|
||||
fn wait_until_idle(&mut self) {
|
||||
self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||
}
|
||||
|
||||
pub(crate) fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||
|
||||
Reference in New Issue
Block a user