Fix missing parts of merge of #71
parent
93b1a21cdb
commit
8ef83eb88a
|
|
@ -36,27 +36,24 @@ const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
/// EPD7in5 (HD) driver
|
/// EPD7in5 (HD) driver
|
||||||
///
|
///
|
||||||
pub struct Epd7in5<SPI, CS, BUSY, DC, RST> {
|
pub struct Epd7in5<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<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>
|
for Epd7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2);
|
||||||
|
|
||||||
|
|
@ -99,17 +96,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<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>
|
for Epd7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -127,21 +125,22 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
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.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::DeepSleep, &[0x01])?;
|
self.cmd_with_data(spi, Command::DeepSleep, &[0x01])?;
|
||||||
Ok(())
|
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.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::SetRamYAc, &[0x00, 0x00])?;
|
self.cmd_with_data(spi, Command::SetRamYAc, &[0x00, 0x00])?;
|
||||||
self.cmd_with_data(spi, Command::WriteRamBw, buffer)?;
|
self.cmd_with_data(spi, Command::WriteRamBw, buffer)?;
|
||||||
|
|
@ -161,19 +160,24 @@ where
|
||||||
unimplemented!();
|
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.command(spi, Command::MasterActivation)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
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 pixel_count = WIDTH * HEIGHT / 8;
|
||||||
let background_color_byte = self.color.get_byte_value();
|
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
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue