Merge branch 'fix-70' of https://github.com/olback/epd-waveshare into olback-fix-70

This commit is contained in:
Caemor
2021-04-18 18:13:40 +02:00
18 changed files with 445 additions and 372 deletions
+34 -28
View File
@@ -33,25 +33,22 @@ mod graphics;
pub use self::graphics::Display1in54b;
/// Epd1in54b driver
pub struct Epd1in54b<SPI, CS, BUSY, DC, RST> {
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
pub struct Epd1in54b<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 Epd1in54b<SPI, CS, BUSY, DC, RST>
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
for Epd1in54b<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);
// set the power settings
@@ -88,14 +85,15 @@ where
}
}
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
for Epd1in54b<SPI, CS, BUSY, DC, RST>
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
for Epd1in54b<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,
@@ -131,17 +129,18 @@ where
}
}
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for Epd1in54b<SPI, CS, BUSY, DC, RST>
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
for Epd1in54b<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,
@@ -159,7 +158,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.interface
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
@@ -179,11 +178,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)
}
@@ -203,7 +198,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.wait_until_idle();
self.send_resolution(spi)?;
@@ -241,19 +241,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.wait_until_idle();
self.command(spi, Command::DisplayRefresh)?;
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.send_resolution(spi)?;
@@ -301,13 +306,14 @@ where
}
}
impl<SPI, CS, BUSY, DC, RST> Epd1in54b<SPI, CS, BUSY, DC, RST>
impl<SPI, CS, BUSY, DC, RST, DELAY> Epd1in54b<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)
@@ -327,7 +333,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);
}
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {