Browse Source

Further improvements around acronym lowercases,...

main
Caemor 5 years ago
parent
commit
15e557951f
  1. 4
      CHANGELOG.md
  2. 2
      README.md
  3. 6
      examples/epd1in54_no_graphics.rs
  4. 6
      examples/epd2in13_v2.rs
  5. 6
      examples/epd4in2.rs
  6. 4
      examples/epd4in2_variable_size.rs
  7. 28
      src/epd1in54/mod.rs
  8. 2
      src/epd1in54b/command.rs
  9. 20
      src/epd1in54b/mod.rs
  10. 2
      src/epd1in54c/command.rs
  11. 18
      src/epd1in54c/mod.rs
  12. 40
      src/epd2in13_v2/command.rs
  13. 58
      src/epd2in13_v2/mod.rs
  14. 2
      src/epd2in7b/command.rs
  15. 18
      src/epd2in7b/mod.rs
  16. 26
      src/epd2in9/mod.rs
  17. 2
      src/epd2in9bc/command.rs
  18. 20
      src/epd2in9bc/mod.rs
  19. 4
      src/epd4in2/command.rs
  20. 28
      src/epd4in2/mod.rs
  21. 6
      src/epd5in65f/command.rs
  22. 18
      src/epd5in65f/mod.rs
  23. 8
      src/epd7in5/command.rs
  24. 18
      src/epd7in5/mod.rs
  25. 8
      src/epd7in5_v2/command.rs
  26. 16
      src/epd7in5_v2/mod.rs
  27. 4
      src/interface.rs
  28. 4
      src/lib.rs
  29. 16
      src/traits.rs
  30. 6
      src/type_a/command.rs

4
CHANGELOG.md

@ -9,13 +9,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) - Added QuickRefresh Trait and implemented it for Epd4in2 in #62 (thanks to @David-OConnor)
- Added Epd 2in7 (B) support in #60 (thanks to @pjsier) - Added Epd 2in7 (B) support in #60 (thanks to @pjsier)
### Changed ### Changed
- Use specific ParseColorError instead of () - Use specific ParseColorError instead of ()
- EPD4in2: Don't set the resolution (and some more) over and over again (#48) - Epd4in2: Don't set the resolution (and some more) over and over again (#48)
- Removed `#[allow(non_camel_case_types)]` to fix various issues around it - Removed `#[allow(non_camel_case_types)]` to fix various issues around it
### Fixed ### Fixed

2
README.md

@ -16,7 +16,7 @@ There are multiple examples in the examples folder. Use `cargo run --example exa
```Rust ```Rust
// Setup the epd // Setup the epd
let mut epd = EPD4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?; let mut epd = Epd4in2::new( & mut spi, cs, busy, dc, rst, & mut delay) ?;
// Setup the graphics // Setup the graphics
let mut display = Display4in2::default (); let mut display = Display4in2::default ();

6
examples/epd1in54_no_graphics.rs

@ -1,7 +1,7 @@
#![deny(warnings)] #![deny(warnings)]
use embedded_hal::prelude::*; use embedded_hal::prelude::*;
use epd_waveshare::{epd1in54::EPD1in54, prelude::*}; use epd_waveshare::{epd1in54::Epd1in54, prelude::*};
use linux_embedded_hal::{ use linux_embedded_hal::{
spidev::{self, SpidevOptions}, spidev::{self, SpidevOptions},
sysfs_gpio::Direction, sysfs_gpio::Direction,
@ -58,14 +58,14 @@ fn main() -> Result<(), std::io::Error> {
// Setup of the needed pins is finished here // Setup of the needed pins is finished here
// Now the "real" usage of the eink-waveshare-rs crate begins // Now the "real" usage of the eink-waveshare-rs crate begins
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)?;
epd.display_frame(&mut spi)?; epd.display_frame(&mut spi)?;
// Speeddemo // Speeddemo
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))?; epd.set_lut(&mut spi, Some(RefreshLut::Quick))?;
let small_buffer = [Color::Black.get_byte_value(); 32]; //16x16 let small_buffer = [Color::Black.get_byte_value(); 32]; //16x16
let number_of_runs = 1; let number_of_runs = 1;
for i in 0..number_of_runs { for i in 0..number_of_runs {

6
examples/epd2in13_v2.rs

@ -10,7 +10,7 @@ use embedded_graphics::{
use embedded_hal::prelude::*; use embedded_hal::prelude::*;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd2in13_v2::{Display2in13, EPD2in13}, epd2in13_v2::{Display2in13, Epd2in13},
graphics::{Display, DisplayRotation}, graphics::{Display, DisplayRotation},
prelude::*, prelude::*,
}; };
@ -63,7 +63,7 @@ fn main() -> Result<(), std::io::Error> {
let mut delay = Delay {}; let mut delay = Delay {};
let mut epd2in13 = let mut epd2in13 =
EPD2in13::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); Epd2in13::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
//println!("Test all the rotations"); //println!("Test all the rotations");
let mut display = Display2in13::default(); let mut display = Display2in13::default();
@ -121,7 +121,7 @@ fn main() -> Result<(), std::io::Error> {
// Demonstrating how to use the partial refresh feature of the screen. // Demonstrating how to use the partial refresh feature of the screen.
// Real animations can be used. // Real animations can be used.
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).unwrap();

6
examples/epd4in2.rs

@ -10,7 +10,7 @@ use embedded_graphics::{
use embedded_hal::prelude::*; use embedded_hal::prelude::*;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd4in2::{Display4in2, EPD4in2}, epd4in2::{Display4in2, Epd4in2},
graphics::{Display, DisplayRotation}, graphics::{Display, DisplayRotation},
prelude::*, prelude::*,
}; };
@ -63,7 +63,7 @@ fn main() -> Result<(), std::io::Error> {
let mut delay = Delay {}; let mut delay = Delay {};
let mut epd4in2 = let mut epd4in2 =
EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
//println!("Test all the rotations"); //println!("Test all the rotations");
let mut display = Display4in2::default(); let mut display = Display4in2::default();
@ -120,7 +120,7 @@ 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).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);

4
examples/epd4in2_variable_size.rs

@ -11,7 +11,7 @@ use embedded_graphics::{
use embedded_hal::prelude::*; use embedded_hal::prelude::*;
use epd_waveshare::{ use epd_waveshare::{
color::*, color::*,
epd4in2::{self, EPD4in2}, epd4in2::{self, Epd4in2},
graphics::{Display, DisplayRotation, VarDisplay}, graphics::{Display, DisplayRotation, VarDisplay},
prelude::*, prelude::*,
}; };
@ -64,7 +64,7 @@ fn main() -> Result<(), std::io::Error> {
let mut delay = Delay {}; let mut delay = Delay {};
let mut epd4in2 = let mut epd4in2 =
EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error"); Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
println!("Test all the rotations"); println!("Test all the rotations");

28
src/epd1in54/mod.rs

@ -20,7 +20,7 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!let mut display = Display1in54::default(); //!let mut display = Display1in54::default();
@ -61,7 +61,7 @@ use crate::type_a::{
use crate::color::Color; use crate::color::Color;
use crate::traits::{RefreshLUT, WaveshareDisplay}; use crate::traits::{RefreshLut, WaveshareDisplay};
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
@ -70,18 +70,18 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
pub use crate::epd1in54::graphics::Display1in54; 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> {
/// SPI /// SPI
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// 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> Epd1in54<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -140,7 +140,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST, E> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD1in54<SPI, CS, BUSY, DC, RST> for Epd1in54<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8, Error = E>, SPI: Write<u8, Error = E>,
CS: OutputPin, CS: OutputPin,
@ -167,10 +167,10 @@ where
) -> Result<Self, SPI::Error> { ) -> Result<Self, SPI::Error> {
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let mut epd = EPD1in54 { let mut epd = Epd1in54 {
interface, interface,
background_color: DEFAULT_BACKGROUND_COLOR, background_color: DEFAULT_BACKGROUND_COLOR,
refresh: RefreshLUT::FULL, refresh: RefreshLut::Full,
}; };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -232,7 +232,7 @@ where
self.interface.cmd(spi, Command::MasterActivation)?; self.interface.cmd(spi, Command::MasterActivation)?;
// MASTER Activation should not be interupted to avoid currption of panel images // MASTER Activation should not be interupted to avoid currption of panel images
// therefore a terminate command is send // therefore a terminate command is send
self.interface.cmd(spi, Command::NOP)?; self.interface.cmd(spi, Command::Nop)?;
Ok(()) Ok(())
} }
@ -266,14 +266,14 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
refresh_rate: Option<RefreshLUT>, refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
if let Some(refresh_lut) = refresh_rate { if let Some(refresh_lut) = refresh_rate {
self.refresh = refresh_lut; self.refresh = refresh_lut;
} }
match self.refresh { match self.refresh {
RefreshLUT::FULL => self.set_lut_helper(spi, &LUT_FULL_UPDATE), RefreshLut::Full => self.set_lut_helper(spi, &LUT_FULL_UPDATE),
RefreshLUT::QUICK => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), RefreshLut::Quick => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE),
} }
} }
@ -282,7 +282,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD1in54<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd1in54<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

2
src/epd1in54b/command.rs

@ -24,7 +24,7 @@ pub(crate) enum Command {
LutRed1 = 0x27, LutRed1 = 0x27,
PllControl = 0x30, PllControl = 0x30,
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
TemperatureSensorSelection = 0x41, TemperatureSensorSelection = 0x41,
VcomAndDataIntervalSetting = 0x50, VcomAndDataIntervalSetting = 0x50,
ResolutionSetting = 0x61, ResolutionSetting = 0x61,

20
src/epd1in54b/mod.rs

@ -7,7 +7,7 @@ use embedded_hal::{
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{ use crate::traits::{
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
//The Lookup Tables for the Display //The Lookup Tables for the Display
@ -32,14 +32,14 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "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> {
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
color: Color, color: Color,
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD1in54b<SPI, CS, BUSY, DC, RST> for Epd1in54b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -89,7 +89,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
for EPD1in54b<SPI, CS, BUSY, DC, RST> for Epd1in54b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -132,7 +132,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD1in54b<SPI, CS, BUSY, DC, RST> for Epd1in54b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -152,7 +152,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD1in54b { interface, color }; let mut epd = Epd1in54b { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -165,7 +165,7 @@ where
.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating .cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17])?; //border floating
self.interface self.interface
.cmd_with_data(spi, Command::VcmDcSetting, &[0x00])?; // VCOM to 0V .cmd_with_data(spi, Command::VcmDcSetting, &[0x00])?; // Vcom to 0V
self.interface self.interface
.cmd_with_data(spi, Command::PowerSetting, &[0x02, 0x00, 0x00, 0x00])?; //VG&VS to 0V fast .cmd_with_data(spi, Command::PowerSetting, &[0x02, 0x00, 0x00, 0x00])?; //VG&VS to 0V fast
@ -276,7 +276,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
self.interface self.interface
.cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?; .cmd_with_data(spi, Command::LutForVcom, LUT_VCOM0)?;
@ -301,7 +301,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD1in54b<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd1in54b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

2
src/epd1in54c/command.rs

@ -22,7 +22,7 @@ pub(crate) enum Command {
LutBlackToBlack = 0x24, LutBlackToBlack = 0x24,
PllControl = 0x30, PllControl = 0x30,
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
TemperatureSensorSelection = 0x41, TemperatureSensorSelection = 0x41,
VcomAndDataIntervalSetting = 0x50, VcomAndDataIntervalSetting = 0x50,
ResolutionSetting = 0x61, ResolutionSetting = 0x61,

18
src/epd1in54c/mod.rs

@ -7,7 +7,7 @@ use embedded_hal::{
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{ use crate::traits::{
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
/// Width of epd1in54 in pixels /// Width of epd1in54 in pixels
@ -30,14 +30,14 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "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> {
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
color: Color, color: Color,
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD1in54c<SPI, CS, BUSY, DC, RST> for Epd1in54c<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -77,7 +77,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
for EPD1in54c<SPI, CS, BUSY, DC, RST> for Epd1in54c<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -115,7 +115,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD1in54c<SPI, CS, BUSY, DC, RST> for Epd1in54c<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -135,7 +135,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD1in54c { interface, color }; let mut epd = Epd1in54c { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -233,7 +233,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
_spi: &mut SPI, _spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
Ok(()) Ok(())
} }
@ -243,7 +243,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD1in54c<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd1in54c<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

40
src/epd2in13_v2/command.rs

@ -5,7 +5,7 @@ use crate::traits;
extern crate bit_field; extern crate bit_field;
use bit_field::BitField; use bit_field::BitField;
/// EPD2in13 v2 /// Epd2in13 v2
/// ///
/// For more infos about the addresses and what they are doing look into the pdfs /// For more infos about the addresses and what they are doing look into the pdfs
#[allow(dead_code)] #[allow(dead_code)]
@ -54,7 +54,7 @@ pub(crate) enum Command {
SetAnalogBlockControl = 0x74, SetAnalogBlockControl = 0x74,
SetDigitalBlockControl = 0x7E, SetDigitalBlockControl = 0x7E,
NOP = 0x7F, Nop = 0x7F,
} }
pub(crate) struct DriverOutput { pub(crate) struct DriverOutput {
@ -151,34 +151,34 @@ pub(crate) enum DataEntryModeDir {
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub(crate) enum BorderWaveFormVBD { pub(crate) enum BorderWaveFormVbd {
GS = 0x0, Gs = 0x0,
FixLevel = 0x1, FixLevel = 0x1,
VCOM = 0x2, Vcom = 0x2,
} }
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub(crate) enum BorderWaveFormFixLevel { pub(crate) enum BorderWaveFormFixLevel {
VSS = 0x0, Vss = 0x0,
VSH1 = 0x1, Vsh1 = 0x1,
VSL = 0x2, Vsl = 0x2,
VSH2 = 0x3, Vsh2 = 0x3,
} }
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub(crate) enum BorderWaveFormGS { pub(crate) enum BorderWaveFormGs {
LUT0 = 0x0, Lut0 = 0x0,
LUT1 = 0x1, Lut1 = 0x1,
LUT2 = 0x2, Lut2 = 0x2,
LUT3 = 0x3, Lut3 = 0x3,
} }
pub(crate) struct BorderWaveForm { pub(crate) struct BorderWaveForm {
pub vbd: BorderWaveFormVBD, pub vbd: BorderWaveFormVbd,
pub fix_level: BorderWaveFormFixLevel, pub fix_level: BorderWaveFormFixLevel,
pub gs_trans: BorderWaveFormGS, pub gs_trans: BorderWaveFormGs,
} }
impl BorderWaveForm { impl BorderWaveForm {
@ -204,10 +204,10 @@ pub enum DeepSleepMode {
pub(crate) struct GateDrivingVoltage(pub u8); pub(crate) struct GateDrivingVoltage(pub u8);
pub(crate) struct SourceDrivingVoltage(pub u8); pub(crate) struct SourceDrivingVoltage(pub u8);
pub(crate) struct VCOM(pub u8); pub(crate) struct Vcom(pub u8);
pub(crate) trait I32Ext { pub(crate) trait I32Ext {
fn vcom(self) -> VCOM; fn vcom(self) -> Vcom;
fn gate_driving_decivolt(self) -> GateDrivingVoltage; fn gate_driving_decivolt(self) -> GateDrivingVoltage;
fn source_driving_decivolt(self) -> SourceDrivingVoltage; fn source_driving_decivolt(self) -> SourceDrivingVoltage;
} }
@ -215,7 +215,7 @@ pub(crate) trait I32Ext {
impl I32Ext for i32 { impl I32Ext for i32 {
// This is really not very nice. Until I find something better, this will be // This is really not very nice. Until I find something better, this will be
// a placeholder. // a placeholder.
fn vcom(self) -> VCOM { fn vcom(self) -> Vcom {
assert!((-30..=-2).contains(&self)); assert!((-30..=-2).contains(&self));
let u = match -self { let u = match -self {
2 => 0x08, 2 => 0x08,
@ -249,7 +249,7 @@ impl I32Ext for i32 {
30 => 0x78, 30 => 0x78,
_ => 0, _ => 0,
}; };
VCOM(u) Vcom(u)
} }
fn gate_driving_decivolt(self) -> GateDrivingVoltage { fn gate_driving_decivolt(self) -> GateDrivingVoltage {

58
src/epd2in13_v2/mod.rs

@ -16,13 +16,13 @@ use embedded_hal::{
use crate::buffer_len; use crate::buffer_len;
use crate::color::Color; use crate::color::Color;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
pub(crate) mod command; pub(crate) mod command;
use self::command::{ use self::command::{
BorderWaveForm, BorderWaveFormFixLevel, BorderWaveFormGS, BorderWaveFormVBD, Command, BorderWaveForm, BorderWaveFormFixLevel, BorderWaveFormGs, BorderWaveFormVbd, Command,
DataEntryModeDir, DataEntryModeIncr, DeepSleepMode, DisplayUpdateControl2, DriverOutput, DataEntryModeDir, DataEntryModeIncr, DeepSleepMode, DisplayUpdateControl2, DriverOutput,
GateDrivingVoltage, I32Ext, SourceDrivingVoltage, VCOM, GateDrivingVoltage, I32Ext, SourceDrivingVoltage, Vcom,
}; };
pub(crate) mod constants; pub(crate) mod constants;
@ -43,9 +43,9 @@ pub const HEIGHT: u32 = 250;
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
const IS_BUSY_LOW: bool = false; const IS_BUSY_LOW: bool = false;
/// EPD2in13 (V2) driver /// Epd2in13 (V2) driver
/// ///
pub struct EPD2in13<SPI, CS, BUSY, DC, RST> { pub struct Epd2in13<SPI, CS, BUSY, DC, RST> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
@ -53,11 +53,11 @@ pub struct EPD2in13<SPI, CS, BUSY, DC, RST> {
/// Background Color /// Background Color
background_color: Color, background_color: Color,
refresh: RefreshLUT, refresh: RefreshLut,
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD2in13<SPI, CS, BUSY, DC, RST> for Epd2in13<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -73,7 +73,7 @@ where
// HW reset // HW reset
self.interface.reset(delay, 10); self.interface.reset(delay, 10);
if self.refresh == RefreshLUT::QUICK { if self.refresh == RefreshLut::Quick {
self.set_vcom_register(spi, (-9).vcom())?; self.set_vcom_register(spi, (-9).vcom())?;
self.wait_until_idle(); self.wait_until_idle();
@ -94,9 +94,9 @@ where
self.set_border_waveform( self.set_border_waveform(
spi, spi,
BorderWaveForm { BorderWaveForm {
vbd: BorderWaveFormVBD::GS, vbd: BorderWaveFormVbd::Gs,
fix_level: BorderWaveFormFixLevel::VSS, fix_level: BorderWaveFormFixLevel::Vss,
gs_trans: BorderWaveFormGS::LUT1, gs_trans: BorderWaveFormGs::Lut1,
}, },
)?; )?;
} else { } else {
@ -127,9 +127,9 @@ where
self.set_border_waveform( self.set_border_waveform(
spi, spi,
BorderWaveForm { BorderWaveForm {
vbd: BorderWaveFormVBD::GS, vbd: BorderWaveFormVbd::Gs,
fix_level: BorderWaveFormFixLevel::VSS, fix_level: BorderWaveFormFixLevel::Vss,
gs_trans: BorderWaveFormGS::LUT3, gs_trans: BorderWaveFormGs::Lut3,
}, },
)?; )?;
@ -154,7 +154,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in13<SPI, CS, BUSY, DC, RST> for Epd2in13<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -171,11 +171,11 @@ where
rst: RST, rst: RST,
delay: &mut DELAY, delay: &mut DELAY,
) -> Result<Self, SPI::Error> { ) -> Result<Self, SPI::Error> {
let mut epd = EPD2in13 { let mut epd = Epd2in13 {
interface: DisplayInterface::new(cs, busy, dc, rst), interface: DisplayInterface::new(cs, busy, dc, rst),
sleep_mode: DeepSleepMode::Mode1, sleep_mode: DeepSleepMode::Mode1,
background_color: DEFAULT_BACKGROUND_COLOR, background_color: DEFAULT_BACKGROUND_COLOR,
refresh: RefreshLUT::FULL, refresh: RefreshLut::Full,
}; };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -215,7 +215,7 @@ where
self.cmd_with_data(spi, Command::WriteRam, buffer)?; self.cmd_with_data(spi, Command::WriteRam, buffer)?;
if self.refresh == RefreshLUT::FULL { if self.refresh == RefreshLut::Full {
// Always keep the base buffer equal to current if not doing partial refresh. // Always keep the base buffer equal to current if not doing partial refresh.
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)?;
@ -245,14 +245,14 @@ where
// RAM content). Using this function will most probably make the actual // RAM content). Using this function will most probably make the actual
// display incorrect as the controler will compare with something // display incorrect as the controler will compare with something
// incorrect. // incorrect.
assert!(self.refresh == RefreshLUT::FULL); assert!(self.refresh == RefreshLut::Full);
self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_area(spi, x, y, x + width, y + height)?;
self.set_ram_address_counters(spi, x, y)?; self.set_ram_address_counters(spi, x, y)?;
self.cmd_with_data(spi, Command::WriteRam, buffer)?; self.cmd_with_data(spi, Command::WriteRam, buffer)?;
if self.refresh == RefreshLUT::FULL { if self.refresh == RefreshLut::Full {
// Always keep the base buffer equals to current if not doing partial refresh. // Always keep the base buffer equals to current if not doing partial refresh.
self.set_ram_area(spi, x, y, x + width, y + height)?; self.set_ram_area(spi, x, y, x + width, y + height)?;
self.set_ram_address_counters(spi, x, y)?; self.set_ram_address_counters(spi, x, y)?;
@ -266,7 +266,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) -> 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,
DisplayUpdateControl2::new() DisplayUpdateControl2::new()
@ -289,7 +289,7 @@ where
self.update_frame(spi, buffer)?; self.update_frame(spi, buffer)?;
self.display_frame(spi)?; self.display_frame(spi)?;
if self.refresh == RefreshLUT::QUICK { if self.refresh == RefreshLut::Quick {
self.set_partial_base_buffer(spi, buffer)?; self.set_partial_base_buffer(spi, buffer)?;
} }
Ok(()) Ok(())
@ -309,7 +309,7 @@ where
)?; )?;
// Always keep the base buffer equals to current if not doing partial refresh. // Always keep the base buffer equals to current if not doing partial refresh.
if self.refresh == RefreshLUT::FULL { if self.refresh == RefreshLut::Full {
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)?;
@ -342,11 +342,11 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
refresh_rate: Option<RefreshLUT>, refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
let buffer = match refresh_rate { let buffer = match refresh_rate {
Some(RefreshLUT::FULL) | None => &LUT_FULL_UPDATE, Some(RefreshLut::Full) | None => &LUT_FULL_UPDATE,
Some(RefreshLUT::QUICK) => &LUT_PARTIAL_UPDATE, Some(RefreshLut::Quick) => &LUT_PARTIAL_UPDATE,
}; };
self.cmd_with_data(spi, Command::WriteLutRegister, buffer) self.cmd_with_data(spi, Command::WriteLutRegister, buffer)
@ -357,7 +357,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD2in13<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd2in13<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -391,7 +391,7 @@ where
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
delay: &mut DELAY, delay: &mut DELAY,
refresh: RefreshLUT, refresh: RefreshLut,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
if self.refresh != refresh { if self.refresh != refresh {
self.refresh = refresh; self.refresh = refresh;
@ -425,7 +425,7 @@ where
) )
} }
fn set_vcom_register(&mut self, spi: &mut SPI, vcom: VCOM) -> Result<(), SPI::Error> { fn set_vcom_register(&mut self, spi: &mut SPI, vcom: Vcom) -> Result<(), SPI::Error> {
self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0]) self.cmd_with_data(spi, Command::WriteVcomRegister, &[vcom.0])
} }

2
src/epd2in7b/command.rs

@ -71,7 +71,7 @@ pub(crate) enum Command {
/// This command reads the temperature sensed by the temperature sensor. /// This command reads the temperature sensed by the temperature sensor.
/// ///
/// Doesn't work! Waveshare doesn't connect the read pin /// Doesn't work! Waveshare doesn't connect the read pin
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
/// This command selects Internal or External temperature sensor. /// This command selects Internal or External temperature sensor.
TemperatureSensorCalibration = 0x41, TemperatureSensorCalibration = 0x41,
/// Write External Temperature Sensor /// Write External Temperature Sensor

18
src/epd2in7b/mod.rs

@ -9,7 +9,7 @@ use embedded_hal::{
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{ use crate::traits::{
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
// The Lookup Tables for the Display // The Lookup Tables for the Display
@ -34,8 +34,8 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "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> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// Background Color /// Background Color
@ -43,7 +43,7 @@ pub struct EPD2in7b<SPI, CS, BUSY, DC, RST> {
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD2in7b<SPI, CS, BUSY, DC, RST> for Epd2in7b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -112,7 +112,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in7b<SPI, CS, BUSY, DC, RST> for Epd2in7b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -132,7 +132,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD2in7b { interface, color }; let mut epd = Epd2in7b { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -247,7 +247,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
self.wait_until_idle(); self.wait_until_idle();
self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?; self.cmd_with_data(spi, Command::LutForVcom, &LUT_VCOM_DC)?;
@ -264,7 +264,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in7b<SPI, CS, BUSY, DC, RST> for Epd2in7b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -316,7 +316,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD2in7b<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd2in7b<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

26
src/epd2in9/mod.rs

@ -21,7 +21,7 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!let mut display = Display2in9::default(); //!let mut display = Display2in9::default();
@ -70,18 +70,18 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
pub use crate::epd2in9::graphics::Display2in9; 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> {
/// SPI /// SPI
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// 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> Epd2in9<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -136,7 +136,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in9<SPI, CS, BUSY, DC, RST> for Epd2in9<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -163,10 +163,10 @@ where
) -> Result<Self, SPI::Error> { ) -> Result<Self, SPI::Error> {
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let mut epd = EPD2in9 { let mut epd = Epd2in9 {
interface, interface,
background_color: DEFAULT_BACKGROUND_COLOR, background_color: DEFAULT_BACKGROUND_COLOR,
refresh: RefreshLUT::FULL, refresh: RefreshLut::Full,
}; };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -231,7 +231,7 @@ where
self.interface.cmd(spi, Command::MasterActivation)?; self.interface.cmd(spi, Command::MasterActivation)?;
// MASTER Activation should not be interupted to avoid currption of panel images // MASTER Activation should not be interupted to avoid currption of panel images
// therefore a terminate command is send // therefore a terminate command is send
self.interface.cmd(spi, Command::NOP)?; self.interface.cmd(spi, Command::Nop)?;
Ok(()) Ok(())
} }
@ -265,14 +265,14 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
refresh_rate: Option<RefreshLUT>, refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
if let Some(refresh_lut) = refresh_rate { if let Some(refresh_lut) = refresh_rate {
self.refresh = refresh_lut; self.refresh = refresh_lut;
} }
match self.refresh { match self.refresh {
RefreshLUT::FULL => self.set_lut_helper(spi, &LUT_FULL_UPDATE), RefreshLut::Full => self.set_lut_helper(spi, &LUT_FULL_UPDATE),
RefreshLUT::QUICK => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE), RefreshLut::Quick => self.set_lut_helper(spi, &LUT_PARTIAL_UPDATE),
} }
} }
@ -281,7 +281,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD2in9<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd2in9<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

2
src/epd2in9bc/command.rs

@ -22,7 +22,7 @@ pub(crate) enum Command {
LutBlackToBlack = 0x24, LutBlackToBlack = 0x24,
PllControl = 0x30, PllControl = 0x30,
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
TemperatureSensorSelection = 0x41, TemperatureSensorSelection = 0x41,
VcomAndDataIntervalSetting = 0x50, VcomAndDataIntervalSetting = 0x50,
ResolutionSetting = 0x61, ResolutionSetting = 0x61,

20
src/epd2in9bc/mod.rs

@ -20,7 +20,7 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = EPD2in9bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd2in9bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!// This display is for the black/white pixels //!// This display is for the black/white pixels
@ -60,7 +60,7 @@ use embedded_hal::{
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{ use crate::traits::{
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
/// Width of epd2in9bc in pixels /// Width of epd2in9bc in pixels
@ -89,14 +89,14 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "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> {
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
color: Color, color: Color,
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD2in9bc<SPI, CS, BUSY, DC, RST> for Epd2in9bc<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -143,7 +143,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in9bc<SPI, CS, BUSY, DC, RST> for Epd2in9bc<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -187,7 +187,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD2in9bc<SPI, CS, BUSY, DC, RST> for Epd2in9bc<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -207,7 +207,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD2in9bc { interface, color }; let mut epd = Epd2in9bc { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -317,7 +317,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
_spi: &mut SPI, _spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
Ok(()) Ok(())
} }
@ -327,7 +327,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD2in9bc<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd2in9bc<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

4
src/epd4in2/command.rs

@ -92,7 +92,7 @@ pub(crate) enum Command {
/// This command reads the temperature sensed by the temperature sensor. /// This command reads the temperature sensed by the temperature sensor.
/// ///
/// Doesn't work! Waveshare doesn't connect the read pin /// Doesn't work! Waveshare doesn't connect the read pin
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
/// Selects the Internal or External temperature sensor and offset /// Selects the Internal or External temperature sensor and offset
TemperatureSensorSelection = 0x41, TemperatureSensorSelection = 0x41,
/// Write External Temperature Sensor /// Write External Temperature Sensor
@ -114,7 +114,7 @@ pub(crate) enum Command {
/// The LUT_REV / Chip Revision is read from OTP address = 0x001. /// The LUT_REV / Chip Revision is read from OTP address = 0x001.
/// ///
/// Doesn't work! Waveshare doesn't connect the read pin /// Doesn't work! Waveshare doesn't connect the read pin
REVISION = 0x70, Revision = 0x70,
/// Read Flags. This command reads the IC status /// Read Flags. This command reads the IC status
/// PTL, I2C_ERR, I2C_BUSY, DATA, PON, POF, BUSY /// PTL, I2C_ERR, I2C_BUSY, DATA, PON, POF, BUSY
/// ///

28
src/epd4in2/mod.rs

@ -25,7 +25,7 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!let mut display = Display4in2::default(); //!let mut display = Display4in2::default();
@ -55,7 +55,7 @@ use embedded_hal::{
}; };
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLUT, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, QuickRefresh, RefreshLut, WaveshareDisplay};
//The Lookup Tables for the Display //The Lookup Tables for the Display
mod constants; mod constants;
@ -79,19 +79,19 @@ mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
pub use self::graphics::Display4in2; 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> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// 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> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD4in2<SPI, CS, BUSY, DC, RST> for Epd4in2<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -149,7 +149,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD4in2<SPI, CS, BUSY, DC, RST> for Epd4in2<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -169,10 +169,10 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD4in2 { let mut epd = Epd4in2 {
interface, interface,
color, color,
refresh: RefreshLUT::FULL, refresh: RefreshLut::Full,
}; };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -313,16 +313,16 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
refresh_rate: Option<RefreshLUT>, refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
if let Some(refresh_lut) = refresh_rate { if let Some(refresh_lut) = refresh_rate {
self.refresh = refresh_lut; self.refresh = refresh_lut;
} }
match self.refresh { match self.refresh {
RefreshLUT::FULL => { RefreshLut::Full => {
self.set_lut_helper(spi, &LUT_VCOM0, &LUT_WW, &LUT_BW, &LUT_WB, &LUT_BB) self.set_lut_helper(spi, &LUT_VCOM0, &LUT_WW, &LUT_BW, &LUT_WB, &LUT_BB)
} }
RefreshLUT::QUICK => self.set_lut_helper( RefreshLut::Quick => self.set_lut_helper(
spi, spi,
&LUT_VCOM0_QUICK, &LUT_VCOM0_QUICK,
&LUT_WW_QUICK, &LUT_WW_QUICK,
@ -338,7 +338,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD4in2<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd4in2<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -435,7 +435,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> QuickRefresh<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> QuickRefresh<SPI, CS, BUSY, DC, RST>
for EPD4in2<SPI, CS, BUSY, DC, RST> for Epd4in2<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

6
src/epd5in65f/command.rs

@ -64,7 +64,7 @@ pub(crate) enum Command {
DisplayRefresh = 0x12, DisplayRefresh = 0x12,
/// Image Process Command /// Image Process Command
ImageProcessCommand = 0x13, ImageProcess = 0x13,
/// This command builds the VCOM Look-Up Table (LUTC). /// This command builds the VCOM Look-Up Table (LUTC).
LutForVcom = 0x20, LutForVcom = 0x20,
@ -91,7 +91,7 @@ pub(crate) enum Command {
PllControl = 0x30, PllControl = 0x30,
/// This command reads the temperature sensed by the temperature sensor. /// This command reads the temperature sensed by the temperature sensor.
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
/// This command selects the Internal or External temperature sensor. /// This command selects the Internal or External temperature sensor.
TemperatureCalibration = 0x41, TemperatureCalibration = 0x41,
/// This command could write data to the external temperature sensor. /// This command could write data to the external temperature sensor.
@ -115,7 +115,7 @@ pub(crate) enum Command {
//SpiFlashControl = 0x65, //SpiFlashControl = 0x65,
/// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000.
//REVISION = 0x70, //Revision = 0x70,
/// This command reads the IC status. /// This command reads the IC status.
GetStatus = 0x71, GetStatus = 0x71,

18
src/epd5in65f/mod.rs

@ -13,7 +13,7 @@ use embedded_hal::{
use crate::color::OctColor; use crate::color::OctColor;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
pub(crate) mod command; pub(crate) mod command;
use self::command::Command; use self::command::Command;
@ -31,9 +31,9 @@ pub const HEIGHT: u32 = 448;
pub const DEFAULT_BACKGROUND_COLOR: OctColor = OctColor::White; pub const DEFAULT_BACKGROUND_COLOR: OctColor = OctColor::White;
const IS_BUSY_LOW: bool = true; 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> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// Background Color /// Background Color
@ -41,7 +41,7 @@ pub struct EPD5in65f<SPI, CS, BUSY, DC, RST> {
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD5in65f<SPI, CS, BUSY, DC, RST> for Epd5in65f<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -62,7 +62,7 @@ where
self.cmd_with_data(spi, Command::PowerOffSequenceSetting, &[0x00])?; self.cmd_with_data(spi, Command::PowerOffSequenceSetting, &[0x00])?;
self.cmd_with_data(spi, Command::BoosterSoftStart, &[0xC7, 0xC7, 0x1D])?; self.cmd_with_data(spi, Command::BoosterSoftStart, &[0xC7, 0xC7, 0x1D])?;
self.cmd_with_data(spi, Command::PllControl, &[0x3C])?; self.cmd_with_data(spi, Command::PllControl, &[0x3C])?;
self.cmd_with_data(spi, Command::TemperatureSensorCommand, &[0x00])?; self.cmd_with_data(spi, Command::TemperatureSensor, &[0x00])?;
self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?; self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x37])?;
self.cmd_with_data(spi, Command::TconSetting, &[0x22])?; self.cmd_with_data(spi, Command::TconSetting, &[0x22])?;
self.send_resolution(spi)?; self.send_resolution(spi)?;
@ -77,7 +77,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD5in65f<SPI, CS, BUSY, DC, RST> for Epd5in65f<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -97,7 +97,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD5in65f { interface, color }; let mut epd = Epd5in65f { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -182,7 +182,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
_spi: &mut SPI, _spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
unimplemented!(); unimplemented!();
} }
@ -192,7 +192,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD5in65f<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd5in65f<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

8
src/epd7in5/command.rs

@ -2,7 +2,7 @@
use crate::traits; use crate::traits;
/// EPD7in5 commands /// Epd7in5 commands
/// ///
/// Should rarely (never?) be needed directly. /// Should rarely (never?) be needed directly.
/// ///
@ -93,7 +93,7 @@ pub(crate) enum Command {
PllControl = 0x30, PllControl = 0x30,
/// This command reads the temperature sensed by the temperature sensor. /// This command reads the temperature sensed by the temperature sensor.
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
/// This command selects the Internal or External temperature sensor. /// This command selects the Internal or External temperature sensor.
TemperatureCalibration = 0x41, TemperatureCalibration = 0x41,
/// This command could write data to the external temperature sensor. /// This command could write data to the external temperature sensor.
@ -117,7 +117,7 @@ pub(crate) enum Command {
SpiFlashControl = 0x65, SpiFlashControl = 0x65,
/// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000.
REVISION = 0x70, Revision = 0x70,
/// This command reads the IC status. /// This command reads the IC status.
GetStatus = 0x71, GetStatus = 0x71,
@ -128,7 +128,7 @@ pub(crate) enum Command {
/// This command sets `VCOM_DC` value. /// This command sets `VCOM_DC` value.
VcmDcSetting = 0x82, VcmDcSetting = 0x82,
/// This is in all the Waveshare controllers for EPD7in5, but it's not documented /// This is in all the Waveshare controllers for Epd7in5, but it's not documented
/// anywhere in the datasheet `¯\_(ツ)_/¯` /// anywhere in the datasheet `¯\_(ツ)_/¯`
FlashMode = 0xE5, FlashMode = 0xE5,
} }

18
src/epd7in5/mod.rs

@ -13,7 +13,7 @@ use embedded_hal::{
use crate::color::Color; use crate::color::Color;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
pub(crate) mod command; pub(crate) mod command;
use self::command::Command; use self::command::Command;
@ -31,9 +31,9 @@ pub const HEIGHT: u32 = 384;
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
const IS_BUSY_LOW: bool = true; 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> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// Background Color /// Background Color
@ -41,7 +41,7 @@ pub struct EPD7in5<SPI, CS, BUSY, DC, RST> {
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD7in5<SPI, CS, BUSY, DC, RST> for Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -91,7 +91,7 @@ where
// Set VCOM_DC to -1.5V // Set VCOM_DC to -1.5V
self.cmd_with_data(spi, Command::VcmDcSetting, &[0x1E])?; self.cmd_with_data(spi, Command::VcmDcSetting, &[0x1E])?;
// This is in all the Waveshare controllers for EPD7in5 // This is in all the Waveshare controllers for Epd7in5
self.cmd_with_data(spi, Command::FlashMode, &[0x03])?; self.cmd_with_data(spi, Command::FlashMode, &[0x03])?;
self.wait_until_idle(); self.wait_until_idle();
@ -100,7 +100,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD7in5<SPI, CS, BUSY, DC, RST> for Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -120,7 +120,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD7in5 { interface, color }; let mut epd = Epd7in5 { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -214,7 +214,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
_spi: &mut SPI, _spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
unimplemented!(); unimplemented!();
} }
@ -224,7 +224,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD7in5<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

8
src/epd7in5_v2/command.rs

@ -2,7 +2,7 @@
use crate::traits; use crate::traits;
/// EPD7in5 commands /// Epd7in5 commands
/// ///
/// Should rarely (never?) be needed directly. /// Should rarely (never?) be needed directly.
/// ///
@ -94,7 +94,7 @@ pub(crate) enum Command {
PllControl = 0x30, PllControl = 0x30,
/// This command reads the temperature sensed by the temperature sensor. /// This command reads the temperature sensed by the temperature sensor.
TemperatureSensorCommand = 0x40, TemperatureSensor = 0x40,
/// This command selects the Internal or External temperature sensor. /// This command selects the Internal or External temperature sensor.
TemperatureCalibration = 0x41, TemperatureCalibration = 0x41,
/// This command could write data to the external temperature sensor. /// This command could write data to the external temperature sensor.
@ -118,7 +118,7 @@ pub(crate) enum Command {
SpiFlashControl = 0x65, SpiFlashControl = 0x65,
/// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000. /// The LUT_REV / Chip Revision is read from OTP address = 25001 and 25000.
REVISION = 0x70, Revision = 0x70,
/// This command reads the IC status. /// This command reads the IC status.
GetStatus = 0x71, GetStatus = 0x71,
@ -128,7 +128,7 @@ pub(crate) enum Command {
ReadVcomValue = 0x81, ReadVcomValue = 0x81,
/// This command sets `VCOM_DC` value. /// This command sets `VCOM_DC` value.
VcmDcSetting = 0x82, VcmDcSetting = 0x82,
// /// This is in all the Waveshare controllers for EPD7in5, but it's not documented // /// This is in all the Waveshare controllers for Epd7in5, but it's not documented
// /// anywhere in the datasheet `¯\_(ツ)_/¯` // /// anywhere in the datasheet `¯\_(ツ)_/¯`
// FlashMode = 0xE5, // FlashMode = 0xE5,
} }

16
src/epd7in5_v2/mod.rs

@ -17,7 +17,7 @@ use embedded_hal::{
use crate::color::Color; use crate::color::Color;
use crate::interface::DisplayInterface; use crate::interface::DisplayInterface;
use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay}; use crate::traits::{InternalWiAdditions, RefreshLut, WaveshareDisplay};
pub(crate) mod command; pub(crate) mod command;
use self::command::Command; use self::command::Command;
@ -35,9 +35,9 @@ pub const HEIGHT: u32 = 480;
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
const IS_BUSY_LOW: bool = true; 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> {
/// Connection Interface /// Connection Interface
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
/// Background Color /// Background Color
@ -45,7 +45,7 @@ pub struct EPD7in5<SPI, CS, BUSY, DC, RST> {
} }
impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> InternalWiAdditions<SPI, CS, BUSY, DC, RST>
for EPD7in5<SPI, CS, BUSY, DC, RST> for Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -82,7 +82,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> WaveshareDisplay<SPI, CS, BUSY, DC, RST>
for EPD7in5<SPI, CS, BUSY, DC, RST> for Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -102,7 +102,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = EPD7in5 { interface, color }; let mut epd = Epd7in5 { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -188,7 +188,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
_spi: &mut SPI, _spi: &mut SPI,
_refresh_rate: Option<RefreshLUT>, _refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error> { ) -> Result<(), SPI::Error> {
unimplemented!(); unimplemented!();
} }
@ -198,7 +198,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST> EPD7in5<SPI, CS, BUSY, DC, RST> impl<SPI, CS, BUSY, DC, RST> Epd7in5<SPI, CS, BUSY, DC, RST>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

4
src/interface.rs

@ -51,7 +51,7 @@ where
/// Basic function for sending an array of u8-values of data over spi /// Basic function for sending an array of u8-values of data over spi
/// ///
/// Enables direct interaction with the device with the help of [command()](EPD4in2::command()) /// Enables direct interaction with the device with the help of [command()](Epd4in2::command())
pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> { pub(crate) fn data(&mut self, spi: &mut SPI, data: &[u8]) -> Result<(), SPI::Error> {
// high for data // high for data
let _ = self.dc.set_high(); let _ = self.dc.set_high();
@ -157,7 +157,7 @@ where
/// Resets the device. /// Resets the device.
/// ///
/// Often used to awake the module from deep sleep. See [EPD4in2::sleep()](EPD4in2::sleep()) /// Often used to awake the module from deep sleep. See [Epd4in2::sleep()](Epd4in2::sleep())
/// ///
/// 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

4
src/lib.rs

@ -28,7 +28,7 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!let mut display = Display1in54::default(); //!let mut display = Display1in54::default();
@ -90,7 +90,7 @@ pub(crate) mod type_a;
pub mod prelude { pub mod prelude {
pub use crate::color::{Color, OctColor, TriColor}; pub use crate::color::{Color, OctColor, TriColor};
pub use crate::traits::{ pub use crate::traits::{
QuickRefresh, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, QuickRefresh, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
pub use crate::SPI_MODE; pub use crate::SPI_MODE;

16
src/traits.rs

@ -12,17 +12,17 @@ pub(crate) trait Command {
/// Seperates the different LUT for the Display Refresh process /// Seperates the different LUT for the Display Refresh process
#[derive(Debug, Clone, PartialEq, Eq, Copy)] #[derive(Debug, Clone, PartialEq, Eq, Copy)]
pub enum RefreshLUT { pub enum RefreshLut {
/// The "normal" full Lookuptable for the Refresh-Sequence /// The "normal" full Lookuptable for the Refresh-Sequence
FULL, Full,
/// The quick LUT where not the full refresh sequence is followed. /// The quick LUT where not the full refresh sequence is followed.
/// This might lead to some /// This might lead to some
QUICK, Quick,
} }
impl Default for RefreshLUT { impl Default for RefreshLut {
fn default() -> Self { fn default() -> Self {
RefreshLUT::FULL RefreshLut::Full
} }
} }
@ -108,7 +108,7 @@ where
///# let mut delay = delay::MockNoop::new(); ///# let mut delay = delay::MockNoop::new();
/// ///
///// Setup EPD ///// Setup EPD
///let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; ///let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
/// ///
///// Use display graphics from embedded-graphics ///// Use display graphics from embedded-graphics
///let mut display = Display4in2::default(); ///let mut display = Display4in2::default();
@ -219,7 +219,7 @@ where
fn set_lut( fn set_lut(
&mut self, &mut self,
spi: &mut SPI, spi: &mut SPI,
refresh_rate: Option<RefreshLUT>, refresh_rate: Option<RefreshLut>,
) -> Result<(), SPI::Error>; ) -> Result<(), SPI::Error>;
/// Checks if the display is busy transmitting data /// Checks if the display is busy transmitting data
@ -258,7 +258,7 @@ where
///# let mut delay = delay::MockNoop::new(); ///# let mut delay = delay::MockNoop::new();
///# ///#
///# // Setup EPD ///# // Setup EPD
///# let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; ///# let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
///let (x, y, frame_width, frame_height) = (20, 40, 80,80); ///let (x, y, frame_width, frame_height) = (20, 40, 80,80);
/// ///
///let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 80 / 8 * 80]; ///let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 80 / 8 * 80];

6
src/type_a/command.rs

@ -2,7 +2,7 @@
use crate::traits; use crate::traits;
/// EPD1in54 and EPD2IN9 commands /// Epd1in54 and EPD2IN9 commands
/// ///
/// Should rarely (never?) be needed directly. /// Should rarely (never?) be needed directly.
/// ///
@ -67,7 +67,7 @@ pub(crate) enum Command {
SetRamYAddressCounter = 0x4F, SetRamYAddressCounter = 0x4F,
NOP = 0xFF, Nop = 0xFF,
} }
impl traits::Command for Command { impl traits::Command for Command {
@ -88,6 +88,6 @@ mod tests {
assert_eq!(Command::SetRamXAddressCounter.address(), 0x4E); assert_eq!(Command::SetRamXAddressCounter.address(), 0x4E);
assert_eq!(Command::NOP.address(), 0xFF); assert_eq!(Command::Nop.address(), 0xFF);
} }
} }

Loading…
Cancel
Save