Update to new error type from eh 1.0a6
parent
2cb7775896
commit
53bfeab6cc
|
|
@ -7,12 +7,15 @@ use linux_embedded_hal::{
|
||||||
sysfs_gpio::Direction,
|
sysfs_gpio::Direction,
|
||||||
Delay, Spidev, SysfsPin as Pin,
|
Delay, Spidev, SysfsPin as Pin,
|
||||||
};
|
};
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use linux_embedded_hal::SPIError;
|
||||||
|
|
||||||
|
|
||||||
// activate spi, gpio in raspi-config
|
// activate spi, gpio in raspi-config
|
||||||
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
||||||
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
||||||
|
|
||||||
fn main() -> Result<(), linux_embedded_hal::SPIError> {
|
fn main() -> Result<(), epd_waveshare::Error<SPIError, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, Infallible>> {
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
// SPI settings are from eink-waveshare-rs documenation
|
// SPI settings are from eink-waveshare-rs documenation
|
||||||
let mut spi = Spidev::open("/dev/spidev0.0")?;
|
let mut spi = Spidev::open("/dev/spidev0.0")?;
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,15 @@ use linux_embedded_hal::{
|
||||||
sysfs_gpio::Direction,
|
sysfs_gpio::Direction,
|
||||||
Delay, Spidev, SysfsPin as Pin,
|
Delay, Spidev, SysfsPin as Pin,
|
||||||
};
|
};
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use linux_embedded_hal::SPIError;
|
||||||
|
|
||||||
|
|
||||||
// activate spi, gpio in raspi-config
|
// activate spi, gpio in raspi-config
|
||||||
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
||||||
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
||||||
|
|
||||||
fn main() -> Result<(), linux_embedded_hal::SPIError> {
|
fn main() -> Result<(), epd_waveshare::Error<SPIError, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, Infallible>> {
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
// Settings are taken from
|
// Settings are taken from
|
||||||
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,9 @@ use linux_embedded_hal::{
|
||||||
sysfs_gpio::Direction,
|
sysfs_gpio::Direction,
|
||||||
Delay, Spidev, SysfsPin as Pin,
|
Delay, Spidev, SysfsPin as Pin,
|
||||||
};
|
};
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use linux_embedded_hal::SPIError;
|
||||||
|
|
||||||
|
|
||||||
// activate spi, gpio in raspi-config
|
// activate spi, gpio in raspi-config
|
||||||
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
||||||
|
|
@ -34,7 +37,7 @@ use linux_embedded_hal::{
|
||||||
//
|
//
|
||||||
// after finishing, put the display to sleep
|
// after finishing, put the display to sleep
|
||||||
|
|
||||||
fn main() -> Result<(), linux_embedded_hal::SPIError> {
|
fn main() -> Result<(), epd_waveshare::Error<SPIError, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, Infallible>> {
|
||||||
let busy = Pin::new(24); // GPIO 24, board J-18
|
let busy = Pin::new(24); // GPIO 24, board J-18
|
||||||
busy.export().expect("busy export");
|
busy.export().expect("busy export");
|
||||||
while !busy.is_exported() {}
|
while !busy.is_exported() {}
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,14 @@ use linux_embedded_hal::{
|
||||||
sysfs_gpio::Direction,
|
sysfs_gpio::Direction,
|
||||||
Delay, Spidev, SysfsPin as Pin,
|
Delay, Spidev, SysfsPin as Pin,
|
||||||
};
|
};
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use linux_embedded_hal::SPIError;
|
||||||
|
|
||||||
// activate spi, gpio in raspi-config
|
// activate spi, gpio in raspi-config
|
||||||
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
||||||
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
||||||
|
|
||||||
fn main() -> Result<(), linux_embedded_hal::SPIError> {
|
fn main() -> Result<(), epd_waveshare::Error<SPIError, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, Infallible>> {
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
// Settings are taken from
|
// Settings are taken from
|
||||||
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,16 @@ use linux_embedded_hal::{
|
||||||
sysfs_gpio::Direction,
|
sysfs_gpio::Direction,
|
||||||
Delay, Spidev, SysfsPin as Pin,
|
Delay, Spidev, SysfsPin as Pin,
|
||||||
};
|
};
|
||||||
|
use core::convert::Infallible;
|
||||||
|
use linux_embedded_hal::SPIError;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// activate spi, gpio in raspi-config
|
// activate spi, gpio in raspi-config
|
||||||
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
// needs to be run with sudo because of some sysfs_gpio permission problems and follow-up timing problems
|
||||||
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
// see https://github.com/rust-embedded/rust-sysfs-gpio/issues/5 and follow-up issues
|
||||||
|
|
||||||
fn main() -> Result<(), linux_embedded_hal::SPIError> {
|
fn main() -> Result<(), epd_waveshare::Error<SPIError, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, linux_embedded_hal::sysfs_gpio::Error, Infallible>> {
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
// Settings are taken from
|
// Settings are taken from
|
||||||
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ use crate::type_a::{
|
||||||
command::Command,
|
command::Command,
|
||||||
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
||||||
};
|
};
|
||||||
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
||||||
use crate::traits::{RefreshLut, WaveshareDisplay};
|
use crate::traits::{RefreshLut, WaveshareDisplay};
|
||||||
|
|
@ -80,6 +80,8 @@ pub struct Epd1in54<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
refresh: RefreshLut,
|
refresh: RefreshLut,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST, DELAY> Epd1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> Epd1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
|
|
@ -89,8 +91,8 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// 3 Databytes:
|
// 3 Databytes:
|
||||||
// A[7:0]
|
// A[7:0]
|
||||||
|
|
@ -161,7 +163,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
|
|
||||||
let mut epd = Epd1in54 {
|
let mut epd = Epd1in54 {
|
||||||
|
|
@ -175,11 +177,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
||||||
//TODO: is 0x00 needed here or would 0x01 be even more efficient?
|
//TODO: is 0x00 needed here or would 0x01 be even more efficient?
|
||||||
|
|
@ -193,7 +195,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -210,7 +212,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
||||||
self.set_ram_counter(spi, x, y)?;
|
self.set_ram_counter(spi, x, y)?;
|
||||||
|
|
@ -220,7 +222,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version)
|
// 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)
|
//TODO: test control_1 or control_2 with default value 0xFF (from the datasheet)
|
||||||
|
|
@ -239,13 +241,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -270,7 +272,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if let Some(refresh_lut) = refresh_rate {
|
if let Some(refresh_lut) = refresh_rate {
|
||||||
self.refresh = refresh_lut;
|
self.refresh = refresh_lut;
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +300,7 @@ where
|
||||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
pub(crate) fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// choose full frame/ram
|
// choose full frame/ram
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
|
|
||||||
|
|
@ -313,7 +315,7 @@ where
|
||||||
start_y: u32,
|
start_y: u32,
|
||||||
end_x: u32,
|
end_x: u32,
|
||||||
end_y: u32,
|
end_y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
assert!(start_x < end_x);
|
assert!(start_x < end_x);
|
||||||
assert!(start_y < end_y);
|
assert!(start_y < end_y);
|
||||||
|
|
@ -345,7 +347,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
x: u32,
|
x: u32,
|
||||||
y: u32,
|
y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
||||||
// aren't relevant
|
// aren't relevant
|
||||||
|
|
@ -361,7 +363,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
assert!(buffer.len() == 30);
|
assert!(buffer.len() == 30);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! A simple Driver for the Waveshare 1.54" (B) E-Ink Display via SPI
|
//! A simple Driver for the Waveshare 1.54" (B) E-Ink Display via SPI
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -44,8 +44,8 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// set the power settings
|
// set the power settings
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -57,7 +57,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -96,12 +96,12 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, black)?;
|
self.update_achromatic_frame(spi, black)?;
|
||||||
self.update_chromatic_frame(spi, chromatic)
|
self.update_chromatic_frame(spi, chromatic)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
self.interface.data(spi, chromatic)?;
|
self.interface.data(spi, chromatic)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -143,7 +143,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
|
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
|
||||||
|
|
@ -174,7 +174,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,7 +199,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -233,11 +233,11 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -248,13 +248,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?;
|
.cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?;
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -311,11 +311,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -332,7 +332,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
//! A simple Driver for the Waveshare 1.54" (C) E-Ink Display via SPI
|
//! A simple Driver for the Waveshare 1.54" (C) E-Ink Display via SPI
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -42,19 +42,19 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Based on Reference Program Code from:
|
// Based on Reference Program Code from:
|
||||||
// https://www.waveshare.com/w/upload/a/ac/1.54inch_e-Paper_Module_C_Specification.pdf
|
// https://www.waveshare.com/w/upload/a/ac/1.54inch_e-Paper_Module_C_Specification.pdf
|
||||||
// and:
|
// and:
|
||||||
// https://github.com/waveshare/e-Paper/blob/master/STM32/STM32-F103ZET6/User/e-Paper/EPD_1in54c.c
|
// https://github.com/waveshare/e-Paper/blob/master/STM32/STM32-F103ZET6/User/e-Paper/EPD_1in54c.c
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
// start the booster
|
// start the booster
|
||||||
self.cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?;
|
self.cmd_with_data(spi, Command::BoosterSoftStart, &[0x17, 0x17, 0x17])?;
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -84,12 +84,12 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, black)?;
|
self.update_achromatic_frame(spi, black)?;
|
||||||
self.update_chromatic_frame(spi, chromatic)
|
self.update_chromatic_frame(spi, chromatic)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::DataStartTransmission1, black)?;
|
self.cmd_with_data(spi, Command::DataStartTransmission1, black)?;
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::DataStartTransmission2, chromatic)?;
|
self.cmd_with_data(spi, Command::DataStartTransmission2, chromatic)?;
|
||||||
|
|
||||||
|
|
@ -126,7 +126,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
self.command(spi, Command::PowerOff)?;
|
self.command(spi, Command::PowerOff)?;
|
||||||
|
|
@ -147,7 +147,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, buffer)?;
|
self.update_achromatic_frame(spi, buffer)?;
|
||||||
|
|
||||||
// Clear the chromatic layer
|
// Clear the chromatic layer
|
||||||
|
|
@ -193,11 +193,11 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
|
|
@ -209,14 +209,14 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -253,11 +253,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,7 +274,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
|
//! - [Controller Datasheet SS1780](http://www.e-paper-display.com/download_detail/downloadsId=682.html)
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::buffer_len;
|
use crate::{buffer_len};use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::eh_prelude::*;
|
use crate::eh_prelude::*;
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
|
|
@ -62,9 +62,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// HW reset
|
// HW reset
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
if self.refresh == RefreshLut::Quick {
|
if self.refresh == RefreshLut::Quick {
|
||||||
self.set_vcom_register(spi, (-9).vcom())?;
|
self.set_vcom_register(spi, (-9).vcom())?;
|
||||||
|
|
@ -164,7 +164,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let mut epd = Epd2in13 {
|
let mut epd = Epd2in13 {
|
||||||
interface: DisplayInterface::new(cs, busy, dc, rst),
|
interface: DisplayInterface::new(cs, busy, dc, rst),
|
||||||
sleep_mode: DeepSleepMode::Mode1,
|
sleep_mode: DeepSleepMode::Mode1,
|
||||||
|
|
@ -176,11 +176,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// All sample code enables and disables analog/clocks...
|
// All sample code enables and disables analog/clocks...
|
||||||
|
|
@ -203,7 +203,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(buffer.len() == buffer_len(WIDTH as usize, HEIGHT as usize));
|
assert!(buffer.len() == buffer_len(WIDTH as usize, HEIGHT as usize));
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
self.set_ram_address_counters(spi, 0, 0)?;
|
self.set_ram_address_counters(spi, 0, 0)?;
|
||||||
|
|
@ -231,7 +231,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!((width * height / 8) as usize == buffer.len());
|
assert!((width * height / 8) as usize == buffer.len());
|
||||||
|
|
||||||
// This should not be used when doing partial refresh. The RAM_RED must
|
// This should not be used when doing partial refresh. The RAM_RED must
|
||||||
|
|
@ -260,7 +260,7 @@ where
|
||||||
|
|
||||||
/// Never use directly this function when using partial refresh, or also
|
/// Never use directly this function when using partial refresh, or also
|
||||||
/// keep the base buffer in syncd using `set_partial_base_buffer` function.
|
/// keep the base buffer in syncd using `set_partial_base_buffer` function.
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if self.refresh == RefreshLut::Full {
|
if self.refresh == RefreshLut::Full {
|
||||||
self.set_display_update_control_2(
|
self.set_display_update_control_2(
|
||||||
spi,
|
spi,
|
||||||
|
|
@ -285,7 +285,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
|
|
||||||
|
|
@ -295,7 +295,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let color = self.background_color.get_byte_value();
|
let color = self.background_color.get_byte_value();
|
||||||
|
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
|
|
@ -343,7 +343,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let buffer = match refresh_rate {
|
let buffer = match refresh_rate {
|
||||||
Some(RefreshLut::Full) | None => &LUT_FULL_UPDATE,
|
Some(RefreshLut::Full) | None => &LUT_FULL_UPDATE,
|
||||||
Some(RefreshLut::Quick) => &LUT_PARTIAL_UPDATE,
|
Some(RefreshLut::Quick) => &LUT_PARTIAL_UPDATE,
|
||||||
|
|
@ -372,7 +372,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(buffer_len(WIDTH as usize, HEIGHT as usize) == buffer.len());
|
assert!(buffer_len(WIDTH as usize, HEIGHT as usize) == buffer.len());
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
self.set_ram_address_counters(spi, 0, 0)?;
|
self.set_ram_address_counters(spi, 0, 0)?;
|
||||||
|
|
@ -393,7 +393,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
refresh: RefreshLut,
|
refresh: RefreshLut,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if self.refresh != refresh {
|
if self.refresh != refresh {
|
||||||
self.refresh = refresh;
|
self.refresh = refresh;
|
||||||
self.init(spi, delay)?;
|
self.init(spi, delay)?;
|
||||||
|
|
@ -405,7 +405,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
start: u16,
|
start: u16,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(start <= 295);
|
assert!(start <= 295);
|
||||||
self.cmd_with_data(
|
self.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
|
|
@ -418,7 +418,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
borderwaveform: BorderWaveForm,
|
borderwaveform: BorderWaveForm,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(
|
self.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
Command::BorderWaveformControl,
|
Command::BorderWaveformControl,
|
||||||
|
|
@ -426,7 +426,7 @@ where
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_vcom_register(&mut self, spi: &mut SPI, vcom: Vcom) -> Result<(), SPI::Error> {
|
fn set_vcom_register(&mut self, spi: &mut SPI, vcom: Vcom) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0])
|
self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,7 +434,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
voltage: GateDrivingVoltage,
|
voltage: GateDrivingVoltage,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::GateDrivingVoltageCtrl, &[voltage.0])
|
self.cmd_with_data(spi, Command::GateDrivingVoltageCtrl, &[voltage.0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,12 +442,12 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
number_of_lines: u8,
|
number_of_lines: u8,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(number_of_lines <= 127);
|
assert!(number_of_lines <= 127);
|
||||||
self.cmd_with_data(spi, Command::SetDummyLinePeriod, &[number_of_lines])
|
self.cmd_with_data(spi, Command::SetDummyLinePeriod, &[number_of_lines])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_gate_line_width(&mut self, spi: &mut SPI, width: u8) -> Result<(), SPI::Error> {
|
fn set_gate_line_width(&mut self, spi: &mut SPI, width: u8) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::SetGateLineWidth, &[width & 0x0F])
|
self.cmd_with_data(spi, Command::SetGateLineWidth, &[width & 0x0F])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,7 +458,7 @@ where
|
||||||
vsh1: SourceDrivingVoltage,
|
vsh1: SourceDrivingVoltage,
|
||||||
vsh2: SourceDrivingVoltage,
|
vsh2: SourceDrivingVoltage,
|
||||||
vsl: SourceDrivingVoltage,
|
vsl: SourceDrivingVoltage,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(
|
self.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
Command::SourceDrivingVoltageCtrl,
|
Command::SourceDrivingVoltageCtrl,
|
||||||
|
|
@ -472,16 +472,16 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
value: DisplayUpdateControl2,
|
value: DisplayUpdateControl2,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::DisplayUpdateControl2, &[value.0])
|
self.cmd_with_data(spi, Command::DisplayUpdateControl2, &[value.0])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Triggers the deep sleep mode
|
/// Triggers the deep sleep mode
|
||||||
fn set_sleep_mode(&mut self, spi: &mut SPI, mode: DeepSleepMode) -> Result<(), SPI::Error> {
|
fn set_sleep_mode(&mut self, spi: &mut SPI, mode: DeepSleepMode) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::DeepSleepMode, &[mode as u8])
|
self.cmd_with_data(spi, Command::DeepSleepMode, &[mode as u8])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_driver_output(&mut self, spi: &mut SPI, output: DriverOutput) -> Result<(), SPI::Error> {
|
fn set_driver_output(&mut self, spi: &mut SPI, output: DriverOutput) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::DriverOutputControl, &output.to_bytes())
|
self.cmd_with_data(spi, Command::DriverOutputControl, &output.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -492,7 +492,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
counter_incr_mode: DataEntryModeIncr,
|
counter_incr_mode: DataEntryModeIncr,
|
||||||
counter_direction: DataEntryModeDir,
|
counter_direction: DataEntryModeDir,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let mode = counter_incr_mode as u8 | counter_direction as u8;
|
let mode = counter_incr_mode as u8 | counter_direction as u8;
|
||||||
self.cmd_with_data(spi, Command::DataEntryModeSetting, &[mode])
|
self.cmd_with_data(spi, Command::DataEntryModeSetting, &[mode])
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +505,7 @@ where
|
||||||
start_y: u32,
|
start_y: u32,
|
||||||
end_x: u32,
|
end_x: u32,
|
||||||
end_y: u32,
|
end_y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(
|
self.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
Command::SetRamXAddressStartEndPosition,
|
Command::SetRamXAddressStartEndPosition,
|
||||||
|
|
@ -530,7 +530,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
x: u32,
|
x: u32,
|
||||||
y: u32,
|
y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::SetRamXAddressCounter, &[(x >> 3) as u8])?;
|
self.cmd_with_data(spi, Command::SetRamXAddressCounter, &[(x >> 3) as u8])?;
|
||||||
|
|
||||||
|
|
@ -542,7 +542,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -551,7 +551,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
//!# }
|
//!# }
|
||||||
//!```
|
//!```
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -99,10 +99,10 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Values taken from datasheet and sample code
|
// Values taken from datasheet and sample code
|
||||||
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// start the booster
|
// start the booster
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -110,7 +110,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -148,7 +148,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, black)?;
|
self.update_achromatic_frame(spi, black)?;
|
||||||
self.update_chromatic_frame(spi, chromatic)
|
self.update_chromatic_frame(spi, chromatic)
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +156,7 @@ where
|
||||||
/// Update only the black/white data of the display.
|
/// Update only the black/white data of the display.
|
||||||
///
|
///
|
||||||
/// Finish by calling `update_chromatic_frame`.
|
/// Finish by calling `update_chromatic_frame`.
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
self.interface.data(spi, black)?;
|
self.interface.data(spi, black)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -169,7 +169,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
self.interface.data(spi, chromatic)?;
|
self.interface.data(spi, chromatic)?;
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Section 8.2 from datasheet
|
// Section 8.2 from datasheet
|
||||||
self.interface.cmd_with_data(
|
self.interface.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
|
|
@ -224,7 +224,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -249,7 +249,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
@ -273,11 +273,11 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -289,13 +289,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
@ -317,7 +317,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -335,11 +335,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,7 +348,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,7 +356,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
@ -368,7 +368,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the outer border of the display to the chosen color.
|
/// Set the outer border of the display to the chosen color.
|
||||||
pub fn set_border_color(&mut self, spi: &mut SPI, color: TriColor) -> Result<(), SPI::Error> {
|
pub fn set_border_color(&mut self, spi: &mut SPI, color: TriColor) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let border = match color {
|
let border = match color {
|
||||||
TriColor::Black => BLACK_BORDER,
|
TriColor::Black => BLACK_BORDER,
|
||||||
TriColor::White => WHITE_BORDER,
|
TriColor::White => WHITE_BORDER,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
//!
|
//!
|
||||||
//! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT_(B))
|
//! [Documentation](https://www.waveshare.com/wiki/2.7inch_e-Paper_HAT_(B))
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -48,13 +48,13 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// reset the device
|
// reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set panel settings, 0xbf is bw, 0xaf is multi-color
|
// set panel settings, 0xbf is bw, 0xaf is multi-color
|
||||||
|
|
@ -122,7 +122,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -133,11 +133,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0xf7])?;
|
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0xf7])?;
|
||||||
|
|
@ -154,7 +154,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
self.send_buffer_helper(spi, buffer)?;
|
self.send_buffer_helper(spi, buffer)?;
|
||||||
|
|
||||||
|
|
@ -175,7 +175,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface
|
self.interface
|
||||||
.cmd(spi, Command::PartialDataStartTransmission1)?;
|
.cmd(spi, Command::PartialDataStartTransmission1)?;
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ where
|
||||||
self.interface.cmd(spi, Command::DataStop)
|
self.interface.cmd(spi, Command::DataStop)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -205,13 +205,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
@ -248,7 +248,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?;
|
self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?;
|
||||||
self.cmd_with_data(spi, Command::LutWhiteToWhite, &LUT_WW)?;
|
self.cmd_with_data(spi, Command::LutWhiteToWhite, &LUT_WW)?;
|
||||||
|
|
@ -278,7 +278,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, black)?;
|
self.update_achromatic_frame(spi, black)?;
|
||||||
self.update_chromatic_frame(spi, chromatic)
|
self.update_chromatic_frame(spi, chromatic)
|
||||||
}
|
}
|
||||||
|
|
@ -290,7 +290,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
achromatic: &[u8],
|
achromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
|
|
||||||
self.send_buffer_helper(spi, achromatic)?;
|
self.send_buffer_helper(spi, achromatic)?;
|
||||||
|
|
@ -305,7 +305,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
|
|
||||||
self.send_buffer_helper(spi, chromatic)?;
|
self.send_buffer_helper(spi, chromatic)?;
|
||||||
|
|
@ -326,15 +326,15 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_buffer_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn send_buffer_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Based on the waveshare implementation, all data for color values is flipped. This helper
|
// Based on the waveshare implementation, all data for color values is flipped. This helper
|
||||||
// method makes that transmission easier
|
// method makes that transmission easier
|
||||||
for b in buffer.iter() {
|
for b in buffer.iter() {
|
||||||
|
|
@ -348,7 +348,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -364,7 +364,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::PartialDisplayRefresh)?;
|
self.command(spi, Command::PartialDisplayRefresh)?;
|
||||||
self.send_data(spi, &[(x >> 8) as u8])?;
|
self.send_data(spi, &[(x >> 8) as u8])?;
|
||||||
self.send_data(spi, &[(x & 0xf8) as u8])?;
|
self.send_data(spi, &[(x & 0xf8) as u8])?;
|
||||||
|
|
@ -387,7 +387,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface
|
self.interface
|
||||||
.cmd(spi, Command::PartialDataStartTransmission1)?;
|
.cmd(spi, Command::PartialDataStartTransmission1)?;
|
||||||
self.send_data(spi, &[(x >> 8) as u8])?;
|
self.send_data(spi, &[(x >> 8) as u8])?;
|
||||||
|
|
@ -417,7 +417,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface
|
self.interface
|
||||||
.cmd(spi, Command::PartialDataStartTransmission2)?;
|
.cmd(spi, Command::PartialDataStartTransmission2)?;
|
||||||
self.send_data(spi, &[(x >> 8) as u8])?;
|
self.send_data(spi, &[(x >> 8) as u8])?;
|
||||||
|
|
|
||||||
|
|
@ -49,12 +49,12 @@ pub const HEIGHT: u32 = 296;
|
||||||
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
const IS_BUSY_LOW: bool = false;
|
const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::type_a::{
|
use crate::type_a::{
|
||||||
command::Command,
|
command::Command,
|
||||||
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
constants::{LUT_FULL_UPDATE, LUT_PARTIAL_UPDATE},
|
||||||
};
|
};
|
||||||
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
@ -86,8 +86,8 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
|
|
@ -154,7 +154,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
|
|
||||||
let mut epd = Epd2in9 {
|
let mut epd = Epd2in9 {
|
||||||
|
|
@ -168,7 +168,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
||||||
//TODO: is 0x00 needed here? (see also epd1in54)
|
//TODO: is 0x00 needed here? (see also epd1in54)
|
||||||
|
|
@ -177,7 +177,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.init(spi, delay)?;
|
self.init(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -188,7 +188,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -206,7 +206,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
||||||
self.set_ram_counter(spi, x, y)?;
|
self.set_ram_counter(spi, x, y)?;
|
||||||
|
|
@ -216,7 +216,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// enable clock signal, enable cp, display pattern -> 0xC4 (tested with the arduino version)
|
// 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)
|
//TODO: test control_1 or control_2 with default value 0xFF (from the datasheet)
|
||||||
|
|
@ -235,13 +235,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if let Some(refresh_lut) = refresh_rate {
|
if let Some(refresh_lut) = refresh_rate {
|
||||||
self.refresh = refresh_lut;
|
self.refresh = refresh_lut;
|
||||||
}
|
}
|
||||||
|
|
@ -294,7 +294,7 @@ where
|
||||||
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// choose full frame/ram
|
// choose full frame/ram
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
|
|
||||||
|
|
@ -309,7 +309,7 @@ where
|
||||||
start_y: u32,
|
start_y: u32,
|
||||||
end_x: u32,
|
end_x: u32,
|
||||||
end_y: u32,
|
end_y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(start_x < end_x);
|
assert!(start_x < end_x);
|
||||||
assert!(start_y < end_y);
|
assert!(start_y < end_y);
|
||||||
|
|
||||||
|
|
@ -334,7 +334,7 @@ where
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_ram_counter(&mut self, spi: &mut SPI, x: u32, y: u32) -> Result<(), SPI::Error> {
|
fn set_ram_counter(&mut self, spi: &mut SPI, x: u32, y: u32) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
||||||
// aren't relevant
|
// aren't relevant
|
||||||
|
|
@ -351,7 +351,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set your own LUT, this function is also used internally for set_lut
|
/// Set your own LUT, this function is also used internally for set_lut
|
||||||
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
assert!(buffer.len() == 30);
|
assert!(buffer.len() == 30);
|
||||||
self.interface
|
self.interface
|
||||||
|
|
|
||||||
|
|
@ -74,9 +74,9 @@ const LUT_PARTIAL_2IN9: [u8; 153] = [
|
||||||
0x22, 0x0, 0x0, 0x0,
|
0x22, 0x0, 0x0, 0x0,
|
||||||
];
|
];
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::type_a::command::Command;
|
use crate::type_a::command::Command;
|
||||||
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
@ -109,8 +109,8 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface.cmd(spi, Command::SwReset)?;
|
self.interface.cmd(spi, Command::SwReset)?;
|
||||||
|
|
@ -167,7 +167,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
|
|
||||||
let mut epd = Epd2in9 {
|
let mut epd = Epd2in9 {
|
||||||
|
|
@ -181,7 +181,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
// 0x00 for Normal mode (Power on Reset), 0x01 for Deep Sleep Mode
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -189,7 +189,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)?;
|
self.init(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -199,7 +199,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface.cmd_with_data(spi, Command::WriteRam, buffer)
|
self.interface.cmd_with_data(spi, Command::WriteRam, buffer)
|
||||||
}
|
}
|
||||||
|
|
@ -212,7 +212,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
//TODO This is copied from epd2in9 but it seems not working. Partial refresh supported by version 2?
|
//TODO This is copied from epd2in9 but it seems not working. Partial refresh supported by version 2?
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
self.set_ram_area(spi, x, y, x + width, y + height)?;
|
||||||
|
|
@ -223,7 +223,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// Enable clock signal, Enable Analog, Load temperature value, DISPLAY with DISPLAY Mode 1, Disable Analog, Disable OSC
|
// Enable clock signal, Enable Analog, Load temperature value, DISPLAY with DISPLAY Mode 1, Disable Analog, Disable OSC
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -238,13 +238,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// clear the ram with the background color
|
// clear the ram with the background color
|
||||||
|
|
@ -266,7 +266,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if let Some(refresh_lut) = refresh_rate {
|
if let Some(refresh_lut) = refresh_rate {
|
||||||
self.refresh = refresh_lut;
|
self.refresh = refresh_lut;
|
||||||
}
|
}
|
||||||
|
|
@ -291,7 +291,7 @@ where
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW);
|
self.interface.wait_until_idle(IS_BUSY_LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// choose full frame/ram
|
// choose full frame/ram
|
||||||
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
|
||||||
|
|
||||||
|
|
@ -306,7 +306,7 @@ where
|
||||||
start_y: u32,
|
start_y: u32,
|
||||||
end_x: u32,
|
end_x: u32,
|
||||||
end_y: u32,
|
end_y: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
assert!(start_x < end_x);
|
assert!(start_x < end_x);
|
||||||
assert!(start_y < end_y);
|
assert!(start_y < end_y);
|
||||||
|
|
||||||
|
|
@ -331,7 +331,7 @@ where
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_ram_counter(&mut self, spi: &mut SPI, x: u32, y: u32) -> Result<(), SPI::Error> {
|
fn set_ram_counter(&mut self, spi: &mut SPI, x: u32, y: u32) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
// x is positioned in bytes, so the last 3 bits which show the position inside a byte in the ram
|
||||||
// aren't relevant
|
// aren't relevant
|
||||||
|
|
@ -348,7 +348,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set your own LUT, this function is also used internally for set_lut
|
/// Set your own LUT, this function is also used internally for set_lut
|
||||||
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn set_lut_helper(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::WriteLutRegister, buffer)?;
|
.cmd_with_data(spi, Command::WriteLutRegister, buffer)?;
|
||||||
|
|
@ -373,7 +373,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::WriteRam, buffer)?;
|
.cmd_with_data(spi, Command::WriteRam, buffer)?;
|
||||||
|
|
@ -387,9 +387,9 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
self.set_lut_helper(spi, &LUT_PARTIAL_2IN9)?;
|
self.set_lut_helper(spi, &LUT_PARTIAL_2IN9)?;
|
||||||
self.interface.cmd_with_data(
|
self.interface.cmd_with_data(
|
||||||
|
|
@ -413,7 +413,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// For a quick refresh of the new updated frame. To be used immediately after `update_new_frame`
|
/// For a quick refresh of the new updated frame. To be used immediately after `update_new_frame`
|
||||||
fn display_new_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_new_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::DisplayUpdateControl2, &[0x0F])?;
|
.cmd_with_data(spi, Command::DisplayUpdateControl2, &[0x0F])?;
|
||||||
|
|
@ -428,7 +428,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_new_frame(spi, buffer, delay)?;
|
self.update_new_frame(spi, buffer, delay)?;
|
||||||
self.display_new_frame(spi, delay)?;
|
self.display_new_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -444,7 +444,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
//TODO supported by display?
|
//TODO supported by display?
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
@ -459,7 +459,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
//TODO supported by display?
|
//TODO supported by display?
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
@ -473,7 +473,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
//TODO supported by display?
|
//TODO supported by display?
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
//!# }
|
//!# }
|
||||||
//!```
|
//!```
|
||||||
//!
|
//!
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{
|
use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
|
|
@ -76,6 +76,7 @@ const BLACK_BORDER: u8 = 0x30;
|
||||||
const CHROMATIC_BORDER: u8 = 0xb0;
|
const CHROMATIC_BORDER: u8 = 0xb0;
|
||||||
const FLOATING_BORDER: u8 = 0xF0;
|
const FLOATING_BORDER: u8 = 0xF0;
|
||||||
|
|
||||||
|
|
||||||
use crate::color::{Color, TriColor};
|
use crate::color::{Color, TriColor};
|
||||||
|
|
||||||
pub(crate) mod command;
|
pub(crate) mod command;
|
||||||
|
|
@ -102,10 +103,10 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Values taken from datasheet and sample code
|
// Values taken from datasheet and sample code
|
||||||
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// start the booster
|
// start the booster
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -113,7 +114,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -151,7 +152,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_achromatic_frame(spi, black)?;
|
self.update_achromatic_frame(spi, black)?;
|
||||||
self.update_chromatic_frame(spi, chromatic)
|
self.update_chromatic_frame(spi, chromatic)
|
||||||
}
|
}
|
||||||
|
|
@ -159,7 +160,7 @@ where
|
||||||
/// Update only the black/white data of the display.
|
/// Update only the black/white data of the display.
|
||||||
///
|
///
|
||||||
/// Finish by calling `update_chromatic_frame`.
|
/// Finish by calling `update_chromatic_frame`.
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error> {
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
self.interface.data(spi, black)?;
|
self.interface.data(spi, black)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -172,7 +173,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
self.interface.cmd(spi, Command::DataStartTransmission2)?;
|
||||||
self.interface.data(spi, chromatic)?;
|
self.interface.data(spi, chromatic)?;
|
||||||
|
|
||||||
|
|
@ -199,7 +200,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -210,7 +211,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Section 8.2 from datasheet
|
// Section 8.2 from datasheet
|
||||||
self.interface.cmd_with_data(
|
self.interface.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
|
|
@ -227,7 +228,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -252,7 +253,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
|
|
||||||
self.interface.data(spi, buffer)?;
|
self.interface.data(spi, buffer)?;
|
||||||
|
|
@ -276,11 +277,11 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -292,13 +293,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
@ -320,7 +321,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -338,11 +339,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -351,7 +352,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -359,7 +360,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
@ -371,7 +372,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the outer border of the display to the chosen color.
|
/// Set the outer border of the display to the chosen color.
|
||||||
pub fn set_border_color(&mut self, spi: &mut SPI, color: TriColor) -> Result<(), SPI::Error> {
|
pub fn set_border_color(&mut self, spi: &mut SPI, color: TriColor) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let border = match color {
|
let border = match color {
|
||||||
TriColor::Black => BLACK_BORDER,
|
TriColor::Black => BLACK_BORDER,
|
||||||
TriColor::White => WHITE_BORDER,
|
TriColor::White => WHITE_BORDER,
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
//!
|
//!
|
||||||
//! BE CAREFUL! The screen can get ghosting/burn-ins through the Partial Fast Update Drawing.
|
//! BE CAREFUL! The screen can get ghosting/burn-ins through the Partial Fast Update Drawing.
|
||||||
|
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -96,9 +96,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// reset the device
|
// reset the device
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// set the power settings
|
// set the power settings
|
||||||
self.interface.cmd_with_data(
|
self.interface.cmd_with_data(
|
||||||
|
|
@ -113,7 +113,7 @@ where
|
||||||
|
|
||||||
// power on
|
// power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// set the panel settings
|
// set the panel settings
|
||||||
|
|
@ -159,7 +159,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -174,11 +174,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
|
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
|
||||||
|
|
@ -202,7 +202,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
||||||
|
|
@ -223,7 +223,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
if buffer.len() as u32 != width / 8 * height {
|
if buffer.len() as u32 != width / 8 * height {
|
||||||
//TODO: panic!! or sth like that
|
//TODO: panic!! or sth like that
|
||||||
|
|
@ -261,7 +261,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -272,13 +272,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -314,7 +314,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
if let Some(refresh_lut) = refresh_rate {
|
if let Some(refresh_lut) = refresh_rate {
|
||||||
self.refresh = refresh_lut;
|
self.refresh = refresh_lut;
|
||||||
}
|
}
|
||||||
|
|
@ -347,11 +347,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,7 +360,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,7 +368,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
@ -387,7 +387,7 @@ where
|
||||||
lut_bw: &[u8],
|
lut_bw: &[u8],
|
||||||
lut_wb: &[u8],
|
lut_wb: &[u8],
|
||||||
lut_bb: &[u8],
|
lut_bb: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// LUT VCOM
|
// LUT VCOM
|
||||||
self.cmd_with_data(spi, Command::LutForVcom, lut_vcom)?;
|
self.cmd_with_data(spi, Command::LutForVcom, lut_vcom)?;
|
||||||
|
|
@ -415,7 +415,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.send_data(spi, &[(x >> 8) as u8])?;
|
self.send_data(spi, &[(x >> 8) as u8])?;
|
||||||
let tmp = x & 0xf8;
|
let tmp = x & 0xf8;
|
||||||
self.send_data(spi, &[tmp as u8])?; // x should be the multiple of 8, the last 3 bit will always be ignored
|
self.send_data(spi, &[tmp as u8])?; // x should be the multiple of 8, the last 3 bit will always be ignored
|
||||||
|
|
@ -451,7 +451,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
self.interface.cmd(spi, Command::DataStartTransmission1)?;
|
||||||
|
|
@ -467,7 +467,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// self.send_resolution(spi)?;
|
// self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -480,7 +480,7 @@ where
|
||||||
|
|
||||||
/// This is a wrapper around `display_frame` for using this device as a true
|
/// This is a wrapper around `display_frame` for using this device as a true
|
||||||
/// `QuickRefresh` device.
|
/// `QuickRefresh` device.
|
||||||
fn display_new_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_new_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.display_frame(spi, delay)
|
self.display_frame(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -493,7 +493,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_new_frame(spi, buffer, delay)?;
|
self.update_new_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)
|
self.display_frame(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
@ -506,7 +506,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
if buffer.len() as u32 != width / 8 * height {
|
if buffer.len() as u32 != width / 8 * height {
|
||||||
|
|
@ -536,7 +536,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
if buffer.len() as u32 != width / 8 * height {
|
if buffer.len() as u32 != width / 8 * height {
|
||||||
//TODO: panic!! or sth like that
|
//TODO: panic!! or sth like that
|
||||||
|
|
@ -560,7 +560,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,9 @@
|
||||||
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_5in65f.c)
|
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_5in65f.c)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd5in65f.py)
|
||||||
|
|
||||||
|
use crate::Error;
|
||||||
use crate::color::OctColor;
|
use crate::color::OctColor;
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -46,9 +47,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
self.cmd_with_data(spi, Command::PanelSetting, &[0xEF, 0x08])?;
|
self.cmd_with_data(spi, Command::PanelSetting, &[0xEF, 0x08])?;
|
||||||
self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00, 0x23, 0x23])?;
|
self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00, 0x23, 0x23])?;
|
||||||
|
|
@ -62,7 +63,7 @@ where
|
||||||
|
|
||||||
self.cmd_with_data(spi, Command::FlashMode, &[0xAA])?;
|
self.cmd_with_data(spi, Command::FlashMode, &[0xAA])?;
|
||||||
|
|
||||||
delay.delay_ms(100);
|
delay.delay_ms(100).map_err(|e| Error::Delay(e))?;
|
||||||
|
|
||||||
self.update_vcom(spi)?;
|
self.update_vcom(spi)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -87,7 +88,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -98,11 +99,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?;
|
self.cmd_with_data(spi, Command::DeepSleep, &[0xA5])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +113,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
self.update_vcom(spi)?;
|
self.update_vcom(spi)?;
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
@ -128,11 +129,11 @@ where
|
||||||
_y: u32,
|
_y: u32,
|
||||||
_width: u32,
|
_width: u32,
|
||||||
_height: u32,
|
_height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
|
|
@ -148,13 +149,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let bg = OctColor::colors_byte(self.color, self.color);
|
let bg = OctColor::colors_byte(self.color, self.color);
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
self.update_vcom(spi)?;
|
self.update_vcom(spi)?;
|
||||||
|
|
@ -185,7 +186,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,11 +204,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +217,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,7 +227,7 @@ where
|
||||||
fn wait_busy_low(&mut self) {
|
fn wait_busy_low(&mut self) {
|
||||||
let _ = self.interface.wait_until_idle(false);
|
let _ = self.interface.wait_until_idle(false);
|
||||||
}
|
}
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
@ -237,7 +238,7 @@ where
|
||||||
self.send_data(spi, &[h as u8])
|
self.send_data(spi, &[h as u8])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_vcom(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn update_vcom(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let bg_color = (self.color.get_nibble() & 0b111) << 5;
|
let bg_color = (self.color.get_nibble() & 0b111) << 5;
|
||||||
self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17 | bg_color])?;
|
self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17 | bg_color])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
//! - [Datasheet](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT)
|
//! - [Datasheet](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT)
|
||||||
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5.c)
|
//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5.c)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bcb75983c98b0f9d25d43c552c248eb0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5.py)
|
||||||
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -46,9 +46,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10)?;
|
||||||
|
|
||||||
// Set the power settings
|
// Set the power settings
|
||||||
self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00])?;
|
self.cmd_with_data(spi, Command::PowerSetting, &[0x37, 0x00])?;
|
||||||
|
|
@ -63,7 +63,7 @@ where
|
||||||
|
|
||||||
// Power on
|
// Power on
|
||||||
self.command(spi, Command::PowerOn)?;
|
self.command(spi, Command::PowerOn)?;
|
||||||
delay.delay_ms(5);
|
delay.delay_ms(5).map_err(|e| Error::Delay(e))?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// Set the clock frequency to 50Hz (default)
|
// Set the clock frequency to 50Hz (default)
|
||||||
|
|
@ -110,7 +110,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -121,11 +121,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::PowerOff)?;
|
self.command(spi, Command::PowerOff)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -138,7 +138,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DataStartTransmission1)?;
|
self.command(spi, Command::DataStartTransmission1)?;
|
||||||
for byte in buffer {
|
for byte in buffer {
|
||||||
|
|
@ -163,11 +163,11 @@ where
|
||||||
_y: u32,
|
_y: u32,
|
||||||
_width: u32,
|
_width: u32,
|
||||||
_height: u32,
|
_height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -178,13 +178,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -215,7 +215,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,11 +233,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -246,7 +246,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ where
|
||||||
let _ = 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> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@
|
||||||
//!
|
//!
|
||||||
//! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf)
|
//! - [Datasheet](https://www.waveshare.com/w/upload/2/27/7inch_HD_e-Paper_Specification.pdf)
|
||||||
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py)
|
//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py)
|
||||||
//!
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -49,9 +49,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
// HD procedure as described here:
|
// HD procedure as described here:
|
||||||
// https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py
|
// https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd/epd7in5_HD.py
|
||||||
|
|
@ -110,7 +110,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -121,11 +121,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::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(())
|
||||||
|
|
@ -136,7 +136,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
_delay: &mut DELAY,
|
_delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::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)?;
|
||||||
|
|
@ -152,11 +152,11 @@ where
|
||||||
_y: u32,
|
_y: u32,
|
||||||
_width: u32,
|
_width: u32,
|
||||||
_height: u32,
|
_height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.command(spi, Command::MasterActivation)?;
|
self.command(spi, Command::MasterActivation)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -167,13 +167,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.display_frame(spi, delay)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::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();
|
||||||
|
|
||||||
|
|
@ -212,7 +212,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@
|
||||||
//! Important note for V2:
|
//! Important note for V2:
|
||||||
//! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1.
|
//! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1.
|
||||||
//! The hardware and interface of V2 are compatible with V1, however, the related software should be updated.
|
//! The hardware and interface of V2 are compatible with V1, however, the related software should be updated.
|
||||||
|
use crate::Error;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*};
|
||||||
use crate::interface::DisplayInterface;
|
use crate::interface::DisplayInterface;
|
||||||
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
|
||||||
|
|
||||||
|
|
@ -50,9 +50,9 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2)?;
|
||||||
|
|
||||||
// V2 procedure as described here:
|
// V2 procedure as described here:
|
||||||
// https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5bc_V2.py
|
// https://github.com/waveshare/e-Paper/blob/master/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5bc_V2.py
|
||||||
|
|
@ -92,7 +92,7 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error> {
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
let interface = DisplayInterface::new(cs, busy, dc, rst);
|
||||||
let color = DEFAULT_BACKGROUND_COLOR;
|
let color = DEFAULT_BACKGROUND_COLOR;
|
||||||
|
|
||||||
|
|
@ -103,11 +103,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle(spi, delay)?;
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.command(spi, Command::PowerOff)?;
|
self.command(spi, Command::PowerOff)?;
|
||||||
self.wait_until_idle(spi, delay)?;
|
self.wait_until_idle(spi, delay)?;
|
||||||
|
|
@ -120,7 +120,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle(spi, delay)?;
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.cmd_with_data(spi, Command::DataStartTransmission2, buffer)?;
|
self.cmd_with_data(spi, Command::DataStartTransmission2, buffer)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -134,11 +134,11 @@ where
|
||||||
_y: u32,
|
_y: u32,
|
||||||
_width: u32,
|
_width: u32,
|
||||||
_height: u32,
|
_height: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle(spi, delay)?;
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -149,13 +149,13 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.update_frame(spi, buffer, delay)?;
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DisplayRefresh)?;
|
self.command(spi, Command::DisplayRefresh)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.wait_until_idle(spi, delay)?;
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -189,7 +189,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
_spi: &mut SPI,
|
_spi: &mut SPI,
|
||||||
_refresh_rate: Option<RefreshLut>,
|
_refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,11 +207,11 @@ where
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
DELAY: DelayUs,
|
DELAY: DelayUs,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn send_data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.data(spi, data)
|
self.interface.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -220,19 +220,19 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: Command,
|
command: Command,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
fn wait_until_idle(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
while self.interface.is_busy(IS_BUSY_LOW) {
|
while self.interface.is_busy(IS_BUSY_LOW) {
|
||||||
self.interface.cmd(spi, Command::GetStatus)?;
|
self.interface.cmd(spi, Command::GetStatus)?;
|
||||||
delay.delay_ms(20);
|
delay.delay_ms(20).map_err(|e| Error::Delay(e))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
let h = self.height();
|
let h = self.height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use crate::traits::Command;
|
use crate::traits::Command;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ where
|
||||||
/// Basic function for sending [Commands](Command).
|
/// Basic function for sending [Commands](Command).
|
||||||
///
|
///
|
||||||
/// Enables direct interaction with the device with the help of [data()](DisplayInterface::data())
|
/// Enables direct interaction with the device with the help of [data()](DisplayInterface::data())
|
||||||
pub(crate) fn cmd<T: Command>(&mut self, spi: &mut SPI, command: T) -> Result<(), SPI::Error> {
|
pub(crate) fn cmd<T: Command>(&mut self, spi: &mut SPI, command: T) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// low for commands
|
// low for commands
|
||||||
let _ = self.dc.set_low();
|
let _ = self.dc.set_low();
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ where
|
||||||
/// Basic function for sending an array of u8-values of data over spi
|
/// Basic function for sending an array of u8-values of data over spi
|
||||||
///
|
///
|
||||||
/// Enables direct interaction with the device with the help of [command()](Epd4in2::command())
|
/// Enables direct interaction with the device with the help of [command()](Epd4in2::command())
|
||||||
pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// high for data
|
// high for data
|
||||||
let _ = self.dc.set_high();
|
let _ = self.dc.set_high();
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
command: T,
|
command: T,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
self.cmd(spi, command)?;
|
self.cmd(spi, command)?;
|
||||||
self.data(spi, data)
|
self.data(spi, data)
|
||||||
}
|
}
|
||||||
|
|
@ -86,7 +86,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
val: u8,
|
val: u8,
|
||||||
repetitions: u32,
|
repetitions: u32,
|
||||||
) -> Result<(), SPI::Error> {
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// high for data
|
// high for data
|
||||||
let _ = self.dc.set_high();
|
let _ = self.dc.set_high();
|
||||||
// Transfer data (u8) over spi
|
// Transfer data (u8) over spi
|
||||||
|
|
@ -97,7 +97,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// spi write helper/abstraction function
|
// spi write helper/abstraction function
|
||||||
fn write(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
|
fn write(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>{
|
||||||
// activate spi with cs low
|
// activate spi with cs low
|
||||||
let _ = self.cs.set_low();
|
let _ = self.cs.set_low();
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// deactivate spi with cs high
|
// deactivate spi with cs high
|
||||||
let _ = self.cs.set_high();
|
self.cs.set_high().map_err(|e| Error::CS(e))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -166,15 +166,16 @@ where
|
||||||
/// The timing of keeping the reset pin low seems to be important and different per device.
|
/// The timing of keeping the reset pin low seems to be important and different per device.
|
||||||
/// Most displays seem to require keeping it low for 10ms, but the 7in5_v2 only seems to reset
|
/// Most displays seem to require keeping it low for 10ms, but the 7in5_v2 only seems to reset
|
||||||
/// properly with 2ms
|
/// properly with 2ms
|
||||||
pub(crate) fn reset(&mut self, delay: &mut DELAY, duration: u32) {
|
pub(crate) fn reset(&mut self, delay: &mut DELAY, duration: u32) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>> {
|
||||||
let _ = self.rst.set_high();
|
self.rst.set_high().map_err(|e| Error::RST(e))?;
|
||||||
delay.delay_ms(10);
|
delay.delay_ms(10).map_err(|e| Error::Delay(e))?;
|
||||||
|
|
||||||
let _ = self.rst.set_low();
|
self.rst.set_low().map_err(|e| Error::RST(e))?;
|
||||||
delay.delay_ms(duration);
|
delay.delay_ms(duration).map_err(|e| Error::Delay(e))?;
|
||||||
let _ = self.rst.set_high();
|
self.rst.set_high().map_err(|e| Error::RST(e))?;
|
||||||
//TODO: the upstream libraries always sleep for 200ms here
|
//TODO: the upstream libraries always sleep for 200ms here
|
||||||
// 10ms works fine with just for the 7in5_v2 but this needs to be validated for other devices
|
// 10ms works fine with just for the 7in5_v2 but this needs to be validated for other devices
|
||||||
delay.delay_ms(200);
|
delay.delay_ms(200).map_err(|e| Error::Delay(e))?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
27
src/lib.rs
27
src/lib.rs
|
|
@ -124,7 +124,7 @@ pub const fn buffer_len(width: usize, height: usize) -> usize {
|
||||||
(width + 7) / 8 * height
|
(width + 7) / 8 * height
|
||||||
}
|
}
|
||||||
|
|
||||||
use embedded_hal::spi::{Mode, Phase, Polarity};
|
use embedded_hal::{spi::{Mode, Phase, Polarity}};
|
||||||
|
|
||||||
/// SPI mode -
|
/// SPI mode -
|
||||||
/// For more infos see [Requirements: SPI](index.html#spi)
|
/// For more infos see [Requirements: SPI](index.html#spi)
|
||||||
|
|
@ -132,3 +132,28 @@ pub const SPI_MODE: Mode = Mode {
|
||||||
phase: Phase::CaptureOnFirstTransition,
|
phase: Phase::CaptureOnFirstTransition,
|
||||||
polarity: Polarity::IdleLow,
|
polarity: Polarity::IdleLow,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
/// Error
|
||||||
|
pub enum Error<SPIError, CSError, BUSYError, DCError, RSTError, DELAYError> {
|
||||||
|
/// SPI Errors
|
||||||
|
Spi(SPIError),
|
||||||
|
/// Delay Errors
|
||||||
|
Delay(DELAYError),
|
||||||
|
/// CS Pin Error
|
||||||
|
CS(CSError),
|
||||||
|
/// Busy Pin Reading Error
|
||||||
|
BUSY(BUSYError),
|
||||||
|
/// Data Command Select Pin Error
|
||||||
|
DC(DCError),
|
||||||
|
/// Reset Pin Error
|
||||||
|
RST(RSTError),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl <SPIError, CSError, BUSYError, DCError, RSTError, DELAYError> From<SPIError> for Error<SPIError, CSError, BUSYError, DCError, RSTError, DELAYError> {
|
||||||
|
fn from(spi: SPIError) -> Self {
|
||||||
|
Self::Spi(spi)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::eh_prelude::*;
|
use crate::{eh_prelude::*, Error};
|
||||||
use core::marker::Sized;
|
use core::marker::Sized;
|
||||||
|
|
||||||
/// All commands need to have this trait which gives the address of the command
|
/// All commands need to have this trait which gives the address of the command
|
||||||
|
|
@ -42,7 +42,7 @@ where
|
||||||
/// This function calls [reset](WaveshareDisplay::reset),
|
/// This function calls [reset](WaveshareDisplay::reset),
|
||||||
/// so you don't need to call reset your self when trying to wake your device up
|
/// so you don't need to call reset your self when trying to wake your device up
|
||||||
/// after setting it to sleep.
|
/// after setting it to sleep.
|
||||||
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions to interact with three color panels
|
/// Functions to interact with three color panels
|
||||||
|
|
@ -64,19 +64,19 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
black: &[u8],
|
black: &[u8],
|
||||||
chromatic: &[u8],
|
chromatic: &[u8],
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Update only the black/white data of the display.
|
/// Update only the black/white data of the display.
|
||||||
///
|
///
|
||||||
/// This must be finished by calling `update_chromatic_frame`.
|
/// This must be finished by calling `update_chromatic_frame`.
|
||||||
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), SPI::Error>;
|
fn update_achromatic_frame(&mut self, spi: &mut SPI, black: &[u8]) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Update only the chromatic data of the display.
|
/// Update only the chromatic data of the display.
|
||||||
///
|
///
|
||||||
/// This should be preceded by a call to `update_achromatic_frame`.
|
/// This should be preceded by a call to `update_achromatic_frame`.
|
||||||
/// This data takes precedence over the black/white data.
|
/// This data takes precedence over the black/white data.
|
||||||
fn update_chromatic_frame(&mut self, spi: &mut SPI, chromatic: &[u8])
|
fn update_chromatic_frame(&mut self, spi: &mut SPI, chromatic: &[u8])
|
||||||
-> Result<(), SPI::Error>;
|
-> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All the functions to interact with the EPDs
|
/// All the functions to interact with the EPDs
|
||||||
|
|
@ -144,19 +144,19 @@ where
|
||||||
dc: DC,
|
dc: DC,
|
||||||
rst: RST,
|
rst: RST,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<Self, SPI::Error>
|
) -> Result<Self, Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
||||||
/// Let the device enter deep-sleep mode to save power.
|
/// Let the device enter deep-sleep mode to save power.
|
||||||
///
|
///
|
||||||
/// The deep sleep mode returns to standby with a hardware reset.
|
/// The deep sleep mode returns to standby with a hardware reset.
|
||||||
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Wakes the device up from sleep
|
/// Wakes the device up from sleep
|
||||||
///
|
///
|
||||||
/// Also reintialises the device if necessary.
|
/// Also reintialises the device if necessary.
|
||||||
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Sets the backgroundcolor for various commands like [clear_frame](WaveshareDisplay::clear_frame)
|
/// Sets the backgroundcolor for various commands like [clear_frame](WaveshareDisplay::clear_frame)
|
||||||
fn set_background_color(&mut self, color: Self::DisplayColor);
|
fn set_background_color(&mut self, color: Self::DisplayColor);
|
||||||
|
|
@ -176,7 +176,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Transmits partial data to the SRAM of the EPD
|
/// Transmits partial data to the SRAM of the EPD
|
||||||
///
|
///
|
||||||
|
|
@ -191,12 +191,12 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Displays the frame data from SRAM
|
/// Displays the frame data from SRAM
|
||||||
///
|
///
|
||||||
/// This function waits until the device isn`t busy anymore
|
/// This function waits until the device isn`t busy anymore
|
||||||
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Provide a combined update&display and save some time (skipping a busy check in between)
|
/// Provide a combined update&display and save some time (skipping a busy check in between)
|
||||||
fn update_and_display_frame(
|
fn update_and_display_frame(
|
||||||
|
|
@ -204,12 +204,12 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Clears the frame buffer on the EPD with the declared background color
|
/// Clears the frame buffer on the EPD with the declared background color
|
||||||
///
|
///
|
||||||
/// The background color can be changed with [`WaveshareDisplay::set_background_color`]
|
/// The background color can be changed with [`WaveshareDisplay::set_background_color`]
|
||||||
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Trait for using various Waveforms from different LUTs
|
/// Trait for using various Waveforms from different LUTs
|
||||||
/// E.g. for partial refreshes
|
/// E.g. for partial refreshes
|
||||||
|
|
@ -223,7 +223,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
refresh_rate: Option<RefreshLut>,
|
refresh_rate: Option<RefreshLut>,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Checks if the display is busy transmitting data
|
/// Checks if the display is busy transmitting data
|
||||||
///
|
///
|
||||||
|
|
@ -293,7 +293,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Updates the new frame.
|
/// Updates the new frame.
|
||||||
fn update_new_frame(
|
fn update_new_frame(
|
||||||
|
|
@ -301,10 +301,10 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Displays the new frame
|
/// Displays the new frame
|
||||||
fn display_new_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error>;
|
fn display_new_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Updates and displays the new frame.
|
/// Updates and displays the new frame.
|
||||||
fn update_and_display_new_frame(
|
fn update_and_display_new_frame(
|
||||||
|
|
@ -312,7 +312,7 @@ where
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Updates the old frame for a portion of the display.
|
/// Updates the old frame for a portion of the display.
|
||||||
fn update_partial_old_frame(
|
fn update_partial_old_frame(
|
||||||
|
|
@ -323,7 +323,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Updates the new frame for a portion of the display.
|
/// Updates the new frame for a portion of the display.
|
||||||
fn update_partial_new_frame(
|
fn update_partial_new_frame(
|
||||||
|
|
@ -334,7 +334,7 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
|
|
||||||
/// Clears the partial frame buffer on the EPD with the declared background color
|
/// Clears the partial frame buffer on the EPD with the declared background color
|
||||||
/// The background color can be changed with [`WaveshareDisplay::set_background_color`]
|
/// The background color can be changed with [`WaveshareDisplay::set_background_color`]
|
||||||
|
|
@ -345,5 +345,5 @@ where
|
||||||
y: u32,
|
y: u32,
|
||||||
width: u32,
|
width: u32,
|
||||||
height: u32,
|
height: u32,
|
||||||
) -> Result<(), SPI::Error>;
|
) -> Result<(), Error<SPI::Error, CS::Error, BUSY::Error, DC::Error, RST::Error, DELAY::Error>>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue