API change to partially fix #70
parent
a252d074de
commit
9a1575b2ec
|
|
@ -61,8 +61,8 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
let mut epd = EPD1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
let mut epd = EPD1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame(&mut spi)?;
|
epd.clear_frame(&mut spi, &mut delay)?;
|
||||||
epd.display_frame(&mut spi)?;
|
epd.display_frame(&mut spi, &mut delay)?;
|
||||||
|
|
||||||
// Speeddemo
|
// Speeddemo
|
||||||
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))?;
|
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))?;
|
||||||
|
|
@ -71,12 +71,12 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
for i in 0..number_of_runs {
|
for i in 0..number_of_runs {
|
||||||
let offset = i * 8 % 150;
|
let offset = i * 8 % 150;
|
||||||
epd.update_partial_frame(&mut spi, &small_buffer, 25 + offset, 25 + offset, 16, 16)?;
|
epd.update_partial_frame(&mut spi, &small_buffer, 25 + offset, 25 + offset, 16, 16)?;
|
||||||
epd.display_frame(&mut spi)?;
|
epd.display_frame(&mut spi, &mut delay)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame(&mut spi)?;
|
epd.clear_frame(&mut spi, &mut delay)?;
|
||||||
epd.display_frame(&mut spi)?;
|
epd.display_frame(&mut spi, &mut delay)?;
|
||||||
|
|
||||||
// Draw some squares
|
// Draw some squares
|
||||||
let small_buffer = [Color::Black.get_byte_value(); 3200]; //160x160
|
let small_buffer = [Color::Black.get_byte_value(); 3200]; //160x160
|
||||||
|
|
@ -89,11 +89,11 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
epd.update_partial_frame(&mut spi, &small_buffer, 96, 96, 8, 8)?;
|
epd.update_partial_frame(&mut spi, &small_buffer, 96, 96, 8, 8)?;
|
||||||
|
|
||||||
// Display updated frame
|
// Display updated frame
|
||||||
epd.display_frame(&mut spi)?;
|
epd.display_frame(&mut spi, &mut delay)?;
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
// Set the EPD to sleep
|
// Set the EPD to sleep
|
||||||
epd.sleep(&mut spi)?;
|
epd.sleep(&mut spi, &mut delay)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
draw_text(&mut display, "Rotate 270!", 5, 50);
|
draw_text(&mut display, "Rotate 270!", 5, 50);
|
||||||
|
|
||||||
epd2in13.update_frame(&mut spi, &display.buffer())?;
|
epd2in13.update_frame(&mut spi, &display.buffer(), &mut delay)?;
|
||||||
epd2in13
|
epd2in13
|
||||||
.display_frame(&mut spi)
|
.display_frame(&mut spi, &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
|
|
@ -123,7 +123,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
epd2in13
|
epd2in13
|
||||||
.set_refresh(&mut spi, &mut delay, RefreshLUT::QUICK)
|
.set_refresh(&mut spi, &mut delay, RefreshLUT::QUICK)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
epd2in13.clear_frame(&mut spi).unwrap();
|
epd2in13.clear_frame(&mut spi, &mut delay).unwrap();
|
||||||
|
|
||||||
// a moving `Hello World!`
|
// a moving `Hello World!`
|
||||||
let limit = 10;
|
let limit = 10;
|
||||||
|
|
@ -131,7 +131,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
draw_text(&mut display, " Hello World! ", 5 + i * 12, 50);
|
draw_text(&mut display, " Hello World! ", 5 + i * 12, 50);
|
||||||
|
|
||||||
epd2in13
|
epd2in13
|
||||||
.update_and_display_frame(&mut spi, &display.buffer())
|
.update_and_display_frame(&mut spi, &display.buffer(), &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(1_000u16);
|
delay.delay_ms(1_000u16);
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
// the screen can refresh for this kind of change (small single character)
|
// the screen can refresh for this kind of change (small single character)
|
||||||
display.clear_buffer(Color::White);
|
display.clear_buffer(Color::White);
|
||||||
epd2in13
|
epd2in13
|
||||||
.update_and_display_frame(&mut spi, &display.buffer())
|
.update_and_display_frame(&mut spi, &display.buffer(), &mut delay)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let spinner = ["|", "/", "-", "\\"];
|
let spinner = ["|", "/", "-", "\\"];
|
||||||
|
|
@ -148,12 +148,12 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
display.clear_buffer(Color::White);
|
display.clear_buffer(Color::White);
|
||||||
draw_text(&mut display, spinner[i % spinner.len()], 10, 100);
|
draw_text(&mut display, spinner[i % spinner.len()], 10, 100);
|
||||||
epd2in13
|
epd2in13
|
||||||
.update_and_display_frame(&mut spi, &display.buffer())
|
.update_and_display_frame(&mut spi, &display.buffer(), &mut delay)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Finished tests - going to sleep");
|
println!("Finished tests - going to sleep");
|
||||||
epd2in13.sleep(&mut spi)
|
epd2in13.sleep(&mut spi, &mut delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(display: &mut Display2in13, text: &str, x: i32, y: i32) {
|
fn draw_text(display: &mut Display2in13, text: &str, x: i32, y: i32) {
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
draw_text(&mut display, "Rotate 270!", 5, 50);
|
draw_text(&mut display, "Rotate 270!", 5, 50);
|
||||||
|
|
||||||
epd4in2.update_frame(&mut spi, &display.buffer())?;
|
epd4in2.update_frame(&mut spi, &display.buffer(), &mut delay)?;
|
||||||
epd4in2
|
epd4in2
|
||||||
.display_frame(&mut spi)
|
.display_frame(&mut spi, &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
|
|
@ -121,22 +121,24 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
// a moving `Hello World!`
|
// a moving `Hello World!`
|
||||||
let limit = 10;
|
let limit = 10;
|
||||||
epd4in2.set_lut(&mut spi, Some(RefreshLUT::QUICK)).unwrap();
|
epd4in2.set_lut(&mut spi, Some(RefreshLUT::QUICK)).unwrap();
|
||||||
epd4in2.clear_frame(&mut spi).unwrap();
|
epd4in2.clear_frame(&mut spi, &mut delay).unwrap();
|
||||||
for i in 0..limit {
|
for i in 0..limit {
|
||||||
//println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
//println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
||||||
|
|
||||||
draw_text(&mut display, " Hello World! ", 5 + i * 12, 50);
|
draw_text(&mut display, " Hello World! ", 5 + i * 12, 50);
|
||||||
|
|
||||||
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
|
||||||
epd4in2
|
epd4in2
|
||||||
.display_frame(&mut spi)
|
.update_frame(&mut spi, &display.buffer(), &mut delay)
|
||||||
|
.unwrap();
|
||||||
|
epd4in2
|
||||||
|
.display_frame(&mut spi, &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
|
|
||||||
delay.delay_ms(1_000u16);
|
delay.delay_ms(1_000u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Finished tests - going to sleep");
|
println!("Finished tests - going to sleep");
|
||||||
epd4in2.sleep(&mut spi)
|
epd4in2.sleep(&mut spi, &mut delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(display: &mut Display4in2, text: &str, x: i32, y: i32) {
|
fn draw_text(display: &mut Display4in2, text: &str, x: i32, y: i32) {
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
.update_partial_frame(&mut spi, &display.buffer(), x, y, width, height)
|
.update_partial_frame(&mut spi, &display.buffer(), x, y, width, height)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
epd4in2
|
epd4in2
|
||||||
.display_frame(&mut spi)
|
.display_frame(&mut spi, &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
|
|
@ -137,14 +137,14 @@ fn main() -> Result<(), std::io::Error> {
|
||||||
.update_partial_frame(&mut spi, &display.buffer(), x, y, width, height)
|
.update_partial_frame(&mut spi, &display.buffer(), x, y, width, height)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
epd4in2
|
epd4in2
|
||||||
.display_frame(&mut spi)
|
.display_frame(&mut spi, &mut delay)
|
||||||
.expect("display frame new graphics");
|
.expect("display frame new graphics");
|
||||||
|
|
||||||
delay.delay_ms(1_000u16);
|
delay.delay_ms(1_000u16);
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Finished tests - going to sleep");
|
println!("Finished tests - going to sleep");
|
||||||
epd4in2.sleep(&mut spi)
|
epd4in2.sleep(&mut spi, &mut delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_text(display: &mut VarDisplay, text: &str, x: i32, y: i32) {
|
fn draw_text(display: &mut VarDisplay, text: &str, x: i32, y: i32) {
|
||||||
|
|
|
||||||
|
|
@ -72,28 +72,25 @@ pub use crate::epd1in54::graphics::Display1in54;
|
||||||
|
|
||||||
/// EPD1in54 driver
|
/// EPD1in54 driver
|
||||||
///
|
///
|
||||||
pub struct EPD1in54<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD1in54<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// SPI
|
/// SPI
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Color
|
/// Color
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
/// Refresh LUT
|
/// Refresh LUT
|
||||||
refresh: RefreshLUT,
|
refresh: RefreshLUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
// 3 Databytes:
|
// 3 Databytes:
|
||||||
|
|
@ -142,14 +139,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54<SPI, CS, BUSY, DC, RST>
|
for EPD1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8, Error = E>,
|
SPI: Write<u8, Error = E>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
|
|
@ -160,7 +158,7 @@ where
|
||||||
HEIGHT
|
HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -181,15 +179,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
// 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?
|
||||||
|
|
@ -198,7 +192,12 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
self.interface
|
self.interface
|
||||||
|
|
@ -225,7 +224,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
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 +238,18 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -285,16 +289,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
pub(crate) fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -33,25 +33,22 @@ mod graphics;
|
||||||
pub use self::graphics::Display1in54b;
|
pub use self::graphics::Display1in54b;
|
||||||
|
|
||||||
/// EPD1in54b driver
|
/// EPD1in54b driver
|
||||||
pub struct EPD1in54b<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD1in54b<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54b<SPI, CS, BUSY, DC, RST>
|
for EPD1in54b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
// set the power settings
|
// set the power settings
|
||||||
|
|
@ -88,14 +85,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54b<SPI, CS, BUSY, DC, RST>
|
for EPD1in54b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -133,17 +131,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54b<SPI, CS, BUSY, DC, RST>
|
for EPD1in54b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -161,7 +160,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating
|
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating
|
||||||
|
|
@ -181,11 +180,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,7 +200,12 @@ where
|
||||||
HEIGHT
|
HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -245,19 +245,24 @@ where
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -307,13 +312,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54b<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -333,7 +339,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -31,25 +31,22 @@ mod graphics;
|
||||||
pub use self::graphics::Display1in54c;
|
pub use self::graphics::Display1in54c;
|
||||||
|
|
||||||
/// EPD1in54c driver
|
/// EPD1in54c driver
|
||||||
pub struct EPD1in54c<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
for EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// 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:
|
||||||
|
|
@ -76,14 +73,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
for EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -114,17 +112,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD1in54c<SPI, CS, BUSY, DC, RST>
|
for EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -142,7 +141,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
self.command(spi, Command::POWER_OFF)?;
|
self.command(spi, Command::POWER_OFF)?;
|
||||||
|
|
@ -152,11 +151,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,7 +171,12 @@ where
|
||||||
HEIGHT
|
HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.update_achromatic_frame(spi, buffer)?;
|
self.update_achromatic_frame(spi, buffer)?;
|
||||||
|
|
||||||
// Clear the chromatic layer
|
// Clear the chromatic layer
|
||||||
|
|
@ -201,21 +201,26 @@ where
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
||||||
|
|
@ -243,13 +248,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD1in54c<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD1in54c<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -269,7 +275,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -45,9 +45,9 @@ const IS_BUSY_LOW: bool = false;
|
||||||
|
|
||||||
/// EPD2in13 (V2) driver
|
/// EPD2in13 (V2) driver
|
||||||
///
|
///
|
||||||
pub struct EPD2in13<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD2in13<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
|
|
||||||
sleep_mode: DeepSleepMode,
|
sleep_mode: DeepSleepMode,
|
||||||
|
|
||||||
|
|
@ -56,20 +56,17 @@ pub struct EPD2in13<SPI, CS, BUSY, DC, RST> {
|
||||||
refresh: RefreshLUT,
|
refresh: RefreshLUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in13<SPI, CS, BUSY, DC, RST>
|
for EPD2in13<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// HW reset
|
// HW reset
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
|
|
@ -157,17 +154,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in13<SPI, CS, BUSY, DC, RST>
|
for EPD2in13<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -186,15 +184,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
// All sample code enables and disables analog/clocks...
|
// All sample code enables and disables analog/clocks...
|
||||||
|
|
@ -212,7 +206,12 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
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)?;
|
||||||
|
|
@ -269,7 +268,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) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::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,
|
||||||
|
|
@ -289,9 +288,14 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
|
|
||||||
if self.refresh == RefreshLUT::QUICK {
|
if self.refresh == RefreshLUT::QUICK {
|
||||||
self.set_partial_base_buffer(spi, buffer)?;
|
self.set_partial_base_buffer(spi, buffer)?;
|
||||||
|
|
@ -299,7 +303,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
let 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)?;
|
||||||
|
|
@ -361,13 +365,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD2in13<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD2in13<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// When using partial refresh, the controller uses the provided buffer for
|
/// When using partial refresh, the controller uses the provided buffer for
|
||||||
/// comparison with new buffer.
|
/// comparison with new buffer.
|
||||||
|
|
@ -391,7 +396,7 @@ where
|
||||||
|
|
||||||
/// Sets the refresh mode. When changing mode, the screen will be
|
/// Sets the refresh mode. When changing mode, the screen will be
|
||||||
/// re-initialized accordingly.
|
/// re-initialized accordingly.
|
||||||
pub fn set_refresh<DELAY: DelayMs<u8>>(
|
pub fn set_refresh(
|
||||||
&mut self,
|
&mut self,
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
delay: &mut DELAY,
|
delay: &mut DELAY,
|
||||||
|
|
@ -559,7 +564,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,27 +35,24 @@ mod graphics;
|
||||||
pub use self::graphics::Display2in7b;
|
pub use self::graphics::Display2in7b;
|
||||||
|
|
||||||
/// EPD2in7b driver
|
/// EPD2in7b driver
|
||||||
pub struct EPD2in7b<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD2in7b<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in7b<SPI, CS, BUSY, DC, RST>
|
for EPD2in7b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// reset the device
|
// reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2);
|
||||||
|
|
||||||
|
|
@ -111,17 +108,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in7b<SPI, CS, BUSY, DC, RST>
|
for EPD2in7b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -139,15 +137,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0xf7])?;
|
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0xf7])?;
|
||||||
|
|
@ -159,7 +153,12 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface
|
||||||
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
|
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
|
||||||
self.send_buffer_helper(spi, buffer)?;
|
self.send_buffer_helper(spi, buffer)?;
|
||||||
|
|
@ -201,19 +200,24 @@ where
|
||||||
self.interface.cmd(spi, Command::DATA_STOP)
|
self.interface.cmd(spi, Command::DATA_STOP)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
@ -267,14 +271,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in7b<SPI, CS, BUSY, DC, RST>
|
for EPD2in7b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -322,13 +327,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD2in7b<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD2in7b<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -357,7 +363,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refresh display for partial frame
|
/// Refresh display for partial frame
|
||||||
|
|
|
||||||
|
|
@ -72,28 +72,25 @@ pub use crate::epd2in9::graphics::Display2in9;
|
||||||
|
|
||||||
/// EPD2in9 driver
|
/// EPD2in9 driver
|
||||||
///
|
///
|
||||||
pub struct EPD2in9<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD2in9<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// SPI
|
/// SPI
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Color
|
/// Color
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
/// Refresh LUT
|
/// Refresh LUT
|
||||||
refresh: RefreshLUT,
|
refresh: RefreshLUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD2in9<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD2in9<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -138,14 +135,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in9<SPI, CS, BUSY, DC, RST>
|
for EPD2in9<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
|
|
@ -156,7 +154,7 @@ where
|
||||||
HEIGHT
|
HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -177,7 +175,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.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)
|
||||||
|
|
@ -186,17 +184,18 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.init(spi, delay)?;
|
self.init(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -224,7 +223,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
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)
|
||||||
|
|
@ -238,13 +237,18 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.use_full_frame(spi)?;
|
self.use_full_frame(spi)?;
|
||||||
|
|
||||||
|
|
@ -284,16 +288,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD2in9<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD2in9<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW);
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn use_full_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -90,25 +90,22 @@ mod graphics;
|
||||||
pub use self::graphics::Display2in9bc;
|
pub use self::graphics::Display2in9bc;
|
||||||
|
|
||||||
/// EPD2in9bc driver
|
/// EPD2in9bc driver
|
||||||
pub struct EPD2in9bc<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD2in9bc<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in9bc<SPI, CS, BUSY, DC, RST>
|
for EPD2in9bc<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// Values taken from datasheet and sample code
|
// Values taken from datasheet and sample code
|
||||||
|
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
@ -142,14 +139,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in9bc<SPI, CS, BUSY, DC, RST>
|
for EPD2in9bc<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn update_color_frame(
|
fn update_color_frame(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -188,17 +186,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD2in9bc<SPI, CS, BUSY, DC, RST>
|
for EPD2in9bc<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -216,7 +215,7 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
// Section 8.2 from datasheet
|
// Section 8.2 from datasheet
|
||||||
self.interface.cmd_with_data(
|
self.interface.cmd_with_data(
|
||||||
spi,
|
spi,
|
||||||
|
|
@ -233,11 +232,7 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +252,12 @@ where
|
||||||
HEIGHT
|
HEIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.interface
|
self.interface
|
||||||
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
|
.cmd(spi, Command::DATA_START_TRANSMISSION_1)?;
|
||||||
|
|
||||||
|
|
@ -287,20 +287,25 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
|
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
let color = DEFAULT_BACKGROUND_COLOR.get_byte_value();
|
||||||
|
|
@ -333,13 +338,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD2in9bc<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD2in9bc<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -359,7 +365,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -81,29 +81,26 @@ pub use self::graphics::Display4in2;
|
||||||
|
|
||||||
/// EPD4in2 driver
|
/// EPD4in2 driver
|
||||||
///
|
///
|
||||||
pub struct EPD4in2<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD4in2<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: Color,
|
color: Color,
|
||||||
/// Refresh LUT
|
/// Refresh LUT
|
||||||
refresh: RefreshLUT,
|
refresh: RefreshLUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD4in2<SPI, CS, BUSY, DC, RST>
|
for EPD4in2<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// reset the device
|
// reset the device
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
|
|
@ -148,17 +145,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD4in2<SPI, CS, BUSY, DC, RST>
|
for EPD4in2<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -180,15 +178,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.interface
|
self.interface
|
||||||
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating
|
.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x17])?; //border floating
|
||||||
|
|
@ -207,7 +201,12 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
let color_value = self.color.get_byte_value();
|
let color_value = self.color.get_byte_value();
|
||||||
|
|
||||||
|
|
@ -267,19 +266,24 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -341,13 +345,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD4in2<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD4in2<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -367,7 +372,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
@ -437,14 +442,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> QuickRefresh<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> QuickRefresh<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD4in2<SPI, CS, BUSY, DC, RST>
|
for EPD4in2<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// To be followed immediately after by `update_old_frame`.
|
/// To be followed immediately after by `update_old_frame`.
|
||||||
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -33,27 +33,24 @@ const IS_BUSY_LOW: bool = true;
|
||||||
|
|
||||||
/// EPD5in65f driver
|
/// EPD5in65f driver
|
||||||
///
|
///
|
||||||
pub struct EPD5in65f<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD5in65f<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: OctColor,
|
color: OctColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD5in65f<SPI, CS, BUSY, DC, RST>
|
for EPD5in65f<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2);
|
||||||
|
|
||||||
|
|
@ -76,17 +73,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD5in65f<SPI, CS, BUSY, DC, RST>
|
for EPD5in65f<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = OctColor;
|
type DisplayColor = OctColor;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -104,20 +102,21 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?;
|
self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, buffer)?;
|
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_1, buffer)?;
|
||||||
|
|
@ -136,7 +135,7 @@ where
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
self.command(spi, Command::POWER_ON)?;
|
self.command(spi, Command::POWER_ON)?;
|
||||||
self.wait_busy_high();
|
self.wait_busy_high();
|
||||||
|
|
@ -147,19 +146,24 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
self.display_frame(spi)?;
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
let 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.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
||||||
self.interface.data_x_times(spi, bg, WIDTH * HEIGHT / 2)?;
|
self.interface.data_x_times(spi, bg, WIDTH * HEIGHT / 2)?;
|
||||||
self.display_frame(spi)?;
|
self.display_frame(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,13 +196,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD5in65f<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD5in65f<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -218,10 +223,10 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_busy_high(&mut self) {
|
fn wait_busy_high(&mut self) {
|
||||||
self.interface.wait_until_idle(true)
|
let _ = self.interface.wait_until_idle(true, None);
|
||||||
}
|
}
|
||||||
fn wait_busy_low(&mut self) {
|
fn wait_busy_low(&mut self) {
|
||||||
self.interface.wait_until_idle(false)
|
let _ = self.interface.wait_until_idle(false, None);
|
||||||
}
|
}
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
let w = self.width();
|
let w = self.width();
|
||||||
|
|
|
||||||
|
|
@ -33,27 +33,24 @@ const IS_BUSY_LOW: bool = true;
|
||||||
|
|
||||||
/// EPD7in5 driver
|
/// EPD7in5 driver
|
||||||
///
|
///
|
||||||
pub struct EPD7in5<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD7in5<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD7in5<SPI, CS, BUSY, DC, RST>
|
for EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 10);
|
self.interface.reset(delay, 10);
|
||||||
|
|
||||||
|
|
@ -99,17 +96,18 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD7in5<SPI, CS, BUSY, DC, RST>
|
for EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -127,15 +125,11 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::POWER_OFF)?;
|
self.command(spi, Command::POWER_OFF)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
|
|
@ -143,7 +137,12 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
_delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
||||||
for byte in buffer {
|
for byte in buffer {
|
||||||
|
|
@ -172,19 +171,24 @@ where
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, _delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle();
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
@ -224,13 +228,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD7in5<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -250,7 +255,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self) {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
let _ = self.interface.wait_until_idle(IS_BUSY_LOW, None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -37,27 +37,24 @@ const IS_BUSY_LOW: bool = true;
|
||||||
|
|
||||||
/// EPD7in5 (V2) driver
|
/// EPD7in5 (V2) driver
|
||||||
///
|
///
|
||||||
pub struct EPD7in5<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD7in5<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// Connection Interface
|
/// Connection Interface
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
|
||||||
/// Background Color
|
/// Background Color
|
||||||
color: Color,
|
color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD7in5<SPI, CS, BUSY, DC, RST>
|
for EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn init<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
// Reset the device
|
// Reset the device
|
||||||
self.interface.reset(delay, 2);
|
self.interface.reset(delay, 2);
|
||||||
|
|
||||||
|
|
@ -69,29 +66,30 @@ where
|
||||||
self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x27, 0x17])?;
|
self.cmd_with_data(spi, Command::BOOSTER_SOFT_START, &[0x17, 0x17, 0x27, 0x17])?;
|
||||||
self.cmd_with_data(spi, Command::POWER_SETTING, &[0x07, 0x17, 0x3F, 0x3F])?;
|
self.cmd_with_data(spi, Command::POWER_SETTING, &[0x07, 0x17, 0x3F, 0x3F])?;
|
||||||
self.command(spi, Command::POWER_ON)?;
|
self.command(spi, Command::POWER_ON)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x1F])?;
|
self.cmd_with_data(spi, Command::PANEL_SETTING, &[0x1F])?;
|
||||||
self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x06])?;
|
self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x06])?;
|
||||||
self.cmd_with_data(spi, Command::TCON_RESOLUTION, &[0x03, 0x20, 0x01, 0xE0])?;
|
self.cmd_with_data(spi, Command::TCON_RESOLUTION, &[0x03, 0x20, 0x01, 0xE0])?;
|
||||||
self.cmd_with_data(spi, Command::DUAL_SPI, &[0x00])?;
|
self.cmd_with_data(spi, Command::DUAL_SPI, &[0x00])?;
|
||||||
self.cmd_with_data(spi, Command::TCON_SETTING, &[0x22])?;
|
self.cmd_with_data(spi, Command::TCON_SETTING, &[0x22])?;
|
||||||
self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x10, 0x07])?;
|
self.cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x10, 0x07])?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
for EPD7in5<SPI, CS, BUSY, DC, RST>
|
for EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
type DisplayColor = Color;
|
type DisplayColor = Color;
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -109,24 +107,25 @@ where
|
||||||
Ok(epd)
|
Ok(epd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wake_up<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error> {
|
|
||||||
self.init(spi, delay)
|
self.init(spi, delay)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.command(spi, Command::POWER_OFF)?;
|
self.command(spi, Command::POWER_OFF)?;
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?;
|
self.cmd_with_data(spi, Command::DEEP_SLEEP, &[0xA5])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_frame(
|
||||||
self.wait_until_idle();
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, buffer)?;
|
self.cmd_with_data(spi, Command::DATA_START_TRANSMISSION_2, buffer)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -143,20 +142,25 @@ where
|
||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
|
fn update_and_display_frame(
|
||||||
self.update_frame(spi, buffer)?;
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
self.update_frame(spi, buffer, delay)?;
|
||||||
self.command(spi, Command::DISPLAY_REFRESH)?;
|
self.command(spi, Command::DISPLAY_REFRESH)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.wait_until_idle();
|
self.wait_until_idle(spi, delay)?;
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
self.command(spi, Command::DATA_START_TRANSMISSION_1)?;
|
||||||
|
|
@ -198,13 +202,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> EPD7in5<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> EPD7in5<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
fn command(&mut self, spi: &mut SPI, command: Command) -> Result<(), SPI::Error> {
|
||||||
self.interface.cmd(spi, command)
|
self.interface.cmd(spi, command)
|
||||||
|
|
@ -223,8 +228,16 @@ where
|
||||||
self.interface.cmd_with_data(spi, command, data)
|
self.interface.cmd_with_data(spi, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_idle(&mut self) {
|
fn wait_until_idle(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> {
|
||||||
self.interface.wait_until_idle(IS_BUSY_LOW)
|
self.interface.wait_until_idle(
|
||||||
|
IS_BUSY_LOW,
|
||||||
|
Some((spi, delay, |i, s, d| {
|
||||||
|
i.cmd(s, Command::GET_STATUS)?;
|
||||||
|
d.delay_ms(20);
|
||||||
|
Ok(())
|
||||||
|
})),
|
||||||
|
)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
fn send_resolution(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,11 @@ use embedded_hal::{
|
||||||
|
|
||||||
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
/// The Connection Interface of all (?) Waveshare EPD-Devices
|
||||||
///
|
///
|
||||||
pub(crate) struct DisplayInterface<SPI, CS, BUSY, DC, RST> {
|
pub(crate) struct DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY> {
|
||||||
/// SPI
|
/// SPI
|
||||||
_spi: PhantomData<SPI>,
|
_spi: PhantomData<SPI>,
|
||||||
|
/// DELAY
|
||||||
|
_delay: PhantomData<DELAY>,
|
||||||
/// CS for SPI
|
/// CS for SPI
|
||||||
cs: CS,
|
cs: CS,
|
||||||
/// Low for busy, Wait until display is ready!
|
/// Low for busy, Wait until display is ready!
|
||||||
|
|
@ -20,17 +22,19 @@ pub(crate) struct DisplayInterface<SPI, CS, BUSY, DC, RST> {
|
||||||
rst: RST,
|
rst: RST,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, BUSY, DC, RST> DisplayInterface<SPI, CS, BUSY, DC, RST>
|
impl<SPI, CS, BUSY, DC, RST, DELAY> DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
pub fn new(cs: CS, busy: BUSY, dc: DC, rst: RST) -> Self {
|
pub fn new(cs: CS, busy: BUSY, dc: DC, rst: RST) -> Self {
|
||||||
DisplayInterface {
|
DisplayInterface {
|
||||||
_spi: PhantomData::default(),
|
_spi: PhantomData::default(),
|
||||||
|
_delay: PhantomData::default(),
|
||||||
cs,
|
cs,
|
||||||
busy,
|
busy,
|
||||||
dc,
|
dc,
|
||||||
|
|
@ -126,15 +130,32 @@ where
|
||||||
///
|
///
|
||||||
/// Most likely there was a mistake with the 2in9 busy connection
|
/// Most likely there was a mistake with the 2in9 busy connection
|
||||||
/// //TODO: use the #cfg feature to make this compile the right way for the certain types
|
/// //TODO: use the #cfg feature to make this compile the right way for the certain types
|
||||||
pub(crate) fn wait_until_idle(&mut self, is_busy_low: bool) {
|
pub(crate) fn wait_until_idle(
|
||||||
//tested: worked without the delay for all tested devices
|
&mut self,
|
||||||
//self.delay_ms(1);
|
is_busy_low: bool,
|
||||||
|
mut task: Option<(
|
||||||
|
&mut SPI,
|
||||||
|
&mut DELAY,
|
||||||
|
fn(&mut Self, &mut SPI, &mut DELAY) -> Result<(), SPI::Error>,
|
||||||
|
)>,
|
||||||
|
) -> Result<(), SPI::Error> {
|
||||||
|
// //tested: worked without the delay for all tested devices
|
||||||
|
// //self.delay_ms(1);
|
||||||
|
|
||||||
|
// Some displays need special treatment (Only 7.5"V2 known so far)
|
||||||
|
// In those cases, a "task" is provided and run here. If note, this
|
||||||
|
// just busy waits for the display.
|
||||||
while self.is_busy(is_busy_low) {
|
while self.is_busy(is_busy_low) {
|
||||||
//tested: REMOVAL of DELAY: it's only waiting for the signal anyway and should continue work asap
|
match task {
|
||||||
//old: shorten the time? it was 100 in the beginning
|
// TODO: Ignore this error?
|
||||||
//self.delay_ms(5);
|
Some((ref mut spi, ref mut delay, tcb)) => tcb(self, spi, delay)?,
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
|
// //tested: REMOVAL of DELAY: it's only waiting for the signal anyway and should continue work asap
|
||||||
|
// //old: shorten the time? it was 100 in the beginning
|
||||||
|
// //self.delay_ms(5);
|
||||||
}
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if device is still busy
|
/// Checks if device is still busy
|
||||||
|
|
@ -162,7 +183,7 @@ 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<DELAY: DelayMs<u8>>(&mut self, delay: &mut DELAY, duration: u8) {
|
pub(crate) fn reset(&mut self, delay: &mut DELAY, duration: u8) {
|
||||||
let _ = self.rst.set_high();
|
let _ = self.rst.set_high();
|
||||||
delay.delay_ms(10);
|
delay.delay_ms(10);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,14 @@ impl Default for RefreshLUT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST>
|
pub(crate) trait InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// This initialises the EPD and powers it up
|
/// This initialises the EPD and powers it up
|
||||||
///
|
///
|
||||||
|
|
@ -44,22 +45,19 @@ 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<DELAY: DelayMs<u8>>(
|
fn init(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Functions to interact with three color panels
|
/// Functions to interact with three color panels
|
||||||
pub trait WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>:
|
pub trait WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>:
|
||||||
WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// Transmit data to the SRAM of the EPD
|
/// Transmit data to the SRAM of the EPD
|
||||||
///
|
///
|
||||||
|
|
@ -127,20 +125,21 @@ where
|
||||||
///# Ok(())
|
///# Ok(())
|
||||||
///# }
|
///# }
|
||||||
///```
|
///```
|
||||||
pub trait WaveshareDisplay<SPI, CS, BUSY, DC, RST>
|
pub trait WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// The Color Type used by the Display
|
/// The Color Type used by the Display
|
||||||
type DisplayColor;
|
type DisplayColor;
|
||||||
/// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
|
/// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
|
||||||
///
|
///
|
||||||
/// This already initialises the device.
|
/// This already initialises the device.
|
||||||
fn new<DELAY: DelayMs<u8>>(
|
fn new(
|
||||||
spi: &mut SPI,
|
spi: &mut SPI,
|
||||||
cs: CS,
|
cs: CS,
|
||||||
busy: BUSY,
|
busy: BUSY,
|
||||||
|
|
@ -154,16 +153,12 @@ where
|
||||||
/// 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) -> Result<(), SPI::Error>;
|
fn sleep(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::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<DELAY: DelayMs<u8>>(
|
fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;
|
||||||
&mut self,
|
|
||||||
spi: &mut SPI,
|
|
||||||
delay: &mut DELAY,
|
|
||||||
) -> Result<(), SPI::Error>;
|
|
||||||
|
|
||||||
/// 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);
|
||||||
|
|
@ -178,7 +173,12 @@ where
|
||||||
fn height(&self) -> u32;
|
fn height(&self) -> u32;
|
||||||
|
|
||||||
/// Transmit a full frame to the SRAM of the EPD
|
/// Transmit a full frame to the SRAM of the EPD
|
||||||
fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error>;
|
fn update_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::Error>;
|
||||||
|
|
||||||
/// Transmits partial data to the SRAM of the EPD
|
/// Transmits partial data to the SRAM of the EPD
|
||||||
///
|
///
|
||||||
|
|
@ -198,15 +198,20 @@ where
|
||||||
/// 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) -> Result<(), SPI::Error>;
|
fn display_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::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(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error>;
|
fn update_and_display_frame(
|
||||||
|
&mut self,
|
||||||
|
spi: &mut SPI,
|
||||||
|
buffer: &[u8],
|
||||||
|
delay: &mut DELAY,
|
||||||
|
) -> Result<(), SPI::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) -> Result<(), SPI::Error>;
|
fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::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
|
||||||
|
|
@ -275,13 +280,14 @@ where
|
||||||
///# Ok(())
|
///# Ok(())
|
||||||
///# }
|
///# }
|
||||||
///```
|
///```
|
||||||
pub trait QuickRefresh<SPI, CS, BUSY, DC, RST>
|
pub trait QuickRefresh<SPI, CS, BUSY, DC, RST, DELAY>
|
||||||
where
|
where
|
||||||
SPI: Write<u8>,
|
SPI: Write<u8>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
BUSY: InputPin,
|
BUSY: InputPin,
|
||||||
DC: OutputPin,
|
DC: OutputPin,
|
||||||
RST: OutputPin,
|
RST: OutputPin,
|
||||||
|
DELAY: DelayMs<u8>,
|
||||||
{
|
{
|
||||||
/// Updates the old frame.
|
/// Updates the old frame.
|
||||||
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error>;
|
fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue