diff --git a/examples/epd1in54_no_graphics.rs b/examples/epd1in54_no_graphics.rs index e6ab75bb..88f01ad7 100644 --- a/examples/epd1in54_no_graphics.rs +++ b/examples/epd1in54_no_graphics.rs @@ -61,7 +61,7 @@ fn main() -> Result<(), std::io::Error> { let mut epd = Epd1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay, Some(5))?; // Clear the full screen - epd.clear_frame(&mut spi, &mut delay)?; + epd.clear_frame(&mut spi, &mut delay, Color::White)?; epd.display_frame(&mut spi, &mut delay)?; // Speeddemo @@ -83,7 +83,7 @@ fn main() -> Result<(), std::io::Error> { } // Clear the full screen - epd.clear_frame(&mut spi, &mut delay)?; + epd.clear_frame(&mut spi, &mut delay, Color::White)?; epd.display_frame(&mut spi, &mut delay)?; // Draw some squares diff --git a/examples/epd2in13_v2.rs b/examples/epd2in13_v2.rs index 3815a0d2..0fd0f6dc 100644 --- a/examples/epd2in13_v2.rs +++ b/examples/epd2in13_v2.rs @@ -126,7 +126,7 @@ fn main() -> Result<(), std::io::Error> { epd2in13 .set_refresh(&mut spi, &mut delay, RefreshLut::Quick) .unwrap(); - epd2in13.clear_frame(&mut spi, &mut delay).unwrap(); + epd2in13.clear_frame(&mut spi, &mut delay, Color::White).unwrap(); // a moving `Hello World!` let limit = 10; diff --git a/examples/epd4in2.rs b/examples/epd4in2.rs index c09115cd..35497456 100644 --- a/examples/epd4in2.rs +++ b/examples/epd4in2.rs @@ -130,7 +130,7 @@ fn main() -> Result<(), std::io::Error> { epd4in2 .set_lut(&mut spi, &mut delay, Some(RefreshLut::Quick)) .unwrap(); - epd4in2.clear_frame(&mut spi, &mut delay).unwrap(); + epd4in2.clear_frame(&mut spi, &mut delay, Color::White).unwrap(); for i in 0..limit { //println!("Moving Hello World. Loop {} from {}", (i + 1), limit); diff --git a/examples/epd4in2_variable_size.rs b/examples/epd4in2_variable_size.rs index 6da2b427..bf2f9c1b 100644 --- a/examples/epd4in2_variable_size.rs +++ b/examples/epd4in2_variable_size.rs @@ -10,7 +10,7 @@ use embedded_graphics::{ use embedded_hal::prelude::*; use epd_waveshare::{ color::*, - epd4in2::{self, Epd4in2}, + epd4in2::Epd4in2, graphics::{DisplayRotation, VarDisplay}, prelude::*, }; @@ -69,7 +69,7 @@ fn main() -> Result<(), std::io::Error> { let (x, y, width, height) = (50, 50, 250, 250); - let mut buffer = [epd4in2::DEFAULT_BACKGROUND_COLOR.get_byte_value(); 62500]; //250*250 + let mut buffer = [Color::White.get_byte_value(); 62500]; //250*250 let mut display = VarDisplay::new(width, height, &mut buffer, false).unwrap(); display.set_rotation(DisplayRotation::Rotate0); draw_text(&mut display, "Rotate 0!", 5, 50); diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index be6a430b..b3211d3d 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -48,8 +48,6 @@ pub const WIDTH: u32 = 200; /// Height of the display pub const HEIGHT: u32 = 200; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; //const DPI: u16 = 184; const IS_BUSY_LOW: bool = false; @@ -84,8 +82,6 @@ pub type Display1in54 = crate::graphics::Display< pub struct Epd1in54 { /// SPI interface: DisplayInterface, - /// Color - background_color: Color, /// Refresh LUT refresh: RefreshLut, } @@ -177,7 +173,6 @@ where let mut epd = Epd1in54 { interface, - background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLut::Full, }; @@ -257,12 +252,17 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.use_full_frame(spi, delay)?; // clear the ram with the background color - let color = self.background_color.get_byte_value(); + let color = color.get_byte_value(); self.interface.cmd(spi, Command::WriteRam)?; self.interface @@ -270,14 +270,6 @@ where Ok(()) } - fn set_background_color(&mut self, background_color: Color) { - self.background_color = background_color; - } - - fn background_color(&self) -> &Color { - &self.background_color - } - fn set_lut( &mut self, spi: &mut SPI, @@ -400,6 +392,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 200); assert_eq!(HEIGHT, 200); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd1in54_v2/mod.rs b/src/epd1in54_v2/mod.rs index 85f9283a..ee705b0e 100644 --- a/src/epd1in54_v2/mod.rs +++ b/src/epd1in54_v2/mod.rs @@ -6,8 +6,6 @@ pub const WIDTH: u32 = 200; /// Height of the display pub const HEIGHT: u32 = 200; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = false; use embedded_hal::{ @@ -33,8 +31,6 @@ pub use crate::epd1in54::Display1in54; pub struct Epd1in54 { /// SPI interface: DisplayInterface, - /// Color - background_color: Color, /// Refresh LUT refresh: RefreshLut, @@ -122,7 +118,6 @@ where let mut epd = Epd1in54 { interface, - background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLut::Full, }; @@ -205,12 +200,17 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.use_full_frame(spi, delay)?; // clear the ram with the background color - let color = self.background_color.get_byte_value(); + let color = color.get_byte_value(); self.interface.cmd(spi, Command::WriteRam)?; self.interface @@ -221,14 +221,6 @@ where Ok(()) } - fn set_background_color(&mut self, background_color: Color) { - self.background_color = background_color; - } - - fn background_color(&self) -> &Color { - &self.background_color - } - fn set_lut( &mut self, spi: &mut SPI, @@ -386,6 +378,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 200); assert_eq!(HEIGHT, 200); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs index ce8c4fb4..a81dd78f 100644 --- a/src/epd1in54b/mod.rs +++ b/src/epd1in54b/mod.rs @@ -18,8 +18,6 @@ use crate::epd1in54b::constants::*; pub const WIDTH: u32 = 200; /// Height of epd1in54 in pixels pub const HEIGHT: u32 = 200; -/// Default Background Color (white) -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; use crate::color::Color; @@ -42,7 +40,6 @@ pub type Display1in54b = crate::graphics::Display< /// Epd1in54b driver pub struct Epd1in54b { interface: DisplayInterface, - color: Color, } impl InternalWiAdditions @@ -164,9 +161,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd1in54b { interface, color }; + let mut epd = Epd1in54b { interface }; epd.init(spi, delay)?; @@ -197,14 +193,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -233,7 +221,7 @@ where //NOTE: Example code has a delay here // Clear the read layer - let color = self.color.get_byte_value(); + let color = Color::White.get_byte_value(); let nbits = WIDTH * (HEIGHT / 8); self.interface.cmd(spi, Command::DataStartTransmission2)?; @@ -274,11 +262,16 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; - let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); + let color = color.get_byte_value(); // Clear the black self.interface.cmd(spi, Command::DataStartTransmission1)?; @@ -381,6 +374,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 200); assert_eq!(HEIGHT, 200); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd1in54c/mod.rs b/src/epd1in54c/mod.rs index 2934a827..565066b8 100644 --- a/src/epd1in54c/mod.rs +++ b/src/epd1in54c/mod.rs @@ -14,8 +14,6 @@ use crate::traits::{ pub const WIDTH: u32 = 152; /// Height of epd1in54 in pixels pub const HEIGHT: u32 = 152; -/// Default Background Color (white) -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; @@ -39,7 +37,6 @@ pub type Display1in54c = crate::graphics::Display< /// Epd1in54c driver pub struct Epd1in54c { interface: DisplayInterface, - color: Color, } impl InternalWiAdditions @@ -146,9 +143,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd1in54c { interface, color }; + let mut epd = Epd1in54c { interface }; epd.init(spi, delay)?; @@ -169,14 +165,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -194,7 +182,7 @@ where self.update_achromatic_frame(spi, delay, buffer)?; // Clear the chromatic layer - let color = self.color.get_byte_value(); + let color = Color::White.get_byte_value(); self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; @@ -235,9 +223,14 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; - let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); + let color = color.get_byte_value(); // Clear the black self.command(spi, Command::DataStartTransmission1)?; diff --git a/src/epd2in13_v2/mod.rs b/src/epd2in13_v2/mod.rs index 0efad684..ccd9c6ab 100644 --- a/src/epd2in13_v2/mod.rs +++ b/src/epd2in13_v2/mod.rs @@ -44,8 +44,6 @@ pub const WIDTH: u32 = 122; /// Height of the display pub const HEIGHT: u32 = 250; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = false; /// Epd2in13 (V2) driver @@ -56,8 +54,6 @@ pub struct Epd2in13 { sleep_mode: DeepSleepMode, - /// Background Color - background_color: Color, refresh: RefreshLut, } @@ -178,7 +174,6 @@ where let mut epd = Epd2in13 { interface: DisplayInterface::new(cs, busy, dc, rst, delay_us), sleep_mode: DeepSleepMode::Mode1, - background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLut::Full, }; @@ -306,8 +301,13 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - let color = self.background_color.get_byte_value(); + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { + let color = color.get_byte_value(); self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?; self.set_ram_address_counters(spi, delay, 0, 0)?; @@ -334,14 +334,6 @@ where Ok(()) } - fn set_background_color(&mut self, background_color: Color) { - self.background_color = background_color; - } - - fn background_color(&self) -> &Color { - &self.background_color - } - fn width(&self) -> u32 { WIDTH } @@ -579,6 +571,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 122); assert_eq!(HEIGHT, 250); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd2in13bc/mod.rs b/src/epd2in13bc/mod.rs index e009f315..910c8854 100644 --- a/src/epd2in13bc/mod.rs +++ b/src/epd2in13bc/mod.rs @@ -64,8 +64,6 @@ use crate::traits::{ pub const WIDTH: u32 = 104; /// Height of epd2in13bc in pixels pub const HEIGHT: u32 = 212; -/// Default background color (white) of epd2in13bc display -pub const DEFAULT_BACKGROUND_COLOR: TriColor = TriColor::White; /// Number of bits for b/w buffer and same for chromatic buffer const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; @@ -96,7 +94,6 @@ pub type Display2in13bc = crate::graphics::Display< /// Epd2in13bc driver pub struct Epd2in13bc { interface: DisplayInterface, - color: TriColor, } impl InternalWiAdditions @@ -216,9 +213,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd2in13bc { interface, color }; + let mut epd = Epd2in13bc { interface }; epd.init(spi, delay)?; @@ -246,14 +242,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: TriColor) { - self.color = color; - } - - fn background_color(&self) -> &TriColor { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -273,7 +261,7 @@ where self.interface.data(spi, buffer)?; // Clear the chromatic layer - let color = self.color.get_byte_value(); + let color = TriColor::White.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; @@ -314,10 +302,15 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.send_resolution(spi)?; - let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); + let color = color.get_byte_value(); // Clear the black self.interface.cmd(spi, Command::DataStartTransmission1)?; diff --git a/src/epd2in7b/mod.rs b/src/epd2in7b/mod.rs index 6c3a49c5..b0dfb1e9 100644 --- a/src/epd2in7b/mod.rs +++ b/src/epd2in7b/mod.rs @@ -20,8 +20,6 @@ use crate::epd2in7b::constants::*; pub const WIDTH: u32 = 176; /// Height of the display pub const HEIGHT: u32 = 264; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; use crate::color::Color; @@ -45,8 +43,6 @@ pub type Display2in7b = crate::graphics::Display< pub struct Epd2in7b { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, } impl InternalWiAdditions @@ -136,9 +132,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd2in7b { interface, color }; + let mut epd = Epd2in7b { interface }; epd.init(spi, delay)?; @@ -173,7 +168,7 @@ where // Clear chromatic layer since we won't be using it here self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface - .data_x_times(spi, !self.color.get_byte_value(), WIDTH * HEIGHT / 8)?; + .data_x_times(spi, !Color::White.get_byte_value(), WIDTH * HEIGHT / 8)?; self.interface.cmd(spi, Command::DataStop)?; Ok(()) @@ -224,10 +219,15 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; - let color_value = self.color.get_byte_value(); + let color_value = color.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface .data_x_times(spi, color_value, WIDTH * HEIGHT / 8)?; @@ -241,14 +241,6 @@ where Ok(()) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -466,6 +458,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 176); assert_eq!(HEIGHT, 264); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index 6a3ee1d0..9e17a403 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -45,8 +45,6 @@ pub const WIDTH: u32 = 128; /// Height of epd2in9 in pixels pub const HEIGHT: u32 = 296; -/// Default Background Color (white) -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = false; use embedded_hal::{ @@ -81,8 +79,6 @@ pub type Display2in9 = crate::graphics::Display< pub struct Epd2in9 { /// SPI interface: DisplayInterface, - /// Color - background_color: Color, /// Refresh LUT refresh: RefreshLut, } @@ -170,7 +166,6 @@ where let mut epd = Epd2in9 { interface, - background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLut::Full, }; @@ -253,12 +248,17 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.use_full_frame(spi, delay)?; // clear the ram with the background color - let color = self.background_color.get_byte_value(); + let color = color.get_byte_value(); self.interface.cmd(spi, Command::WriteRam)?; self.interface @@ -266,14 +266,6 @@ where Ok(()) } - fn set_background_color(&mut self, background_color: Color) { - self.background_color = background_color; - } - - fn background_color(&self) -> &Color { - &self.background_color - } - fn set_lut( &mut self, spi: &mut SPI, @@ -389,6 +381,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 128); assert_eq!(HEIGHT, 296); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd2in9_v2/mod.rs b/src/epd2in9_v2/mod.rs index a2d8caf2..91fa704b 100644 --- a/src/epd2in9_v2/mod.rs +++ b/src/epd2in9_v2/mod.rs @@ -58,8 +58,6 @@ pub const WIDTH: u32 = 128; /// Height of epd2in9 in pixels pub const HEIGHT: u32 = 296; -/// Default Background Color (white) -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = false; const LUT_PARTIAL_2IN9: [u8; 159] = [ @@ -104,8 +102,6 @@ pub type Display2in9 = crate::graphics::Display< pub struct Epd2in9 { /// SPI interface: DisplayInterface, - /// Color - background_color: Color, /// Refresh LUT refresh: RefreshLut, } @@ -183,7 +179,6 @@ where let mut epd = Epd2in9 { interface, - background_color: DEFAULT_BACKGROUND_COLOR, refresh: RefreshLut::Full, }; @@ -257,11 +252,16 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; // clear the ram with the background color - let color = self.background_color.get_byte_value(); + let color = color.get_byte_value(); self.interface.cmd(spi, Command::WriteRam)?; self.interface @@ -270,14 +270,6 @@ where self.interface.data_x_times(spi, color, WIDTH / 8 * HEIGHT) } - fn set_background_color(&mut self, background_color: Color) { - self.background_color = background_color; - } - - fn background_color(&self) -> &Color { - &self.background_color - } - fn set_lut( &mut self, _spi: &mut SPI, @@ -513,6 +505,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 128); assert_eq!(HEIGHT, 296); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd2in9bc/mod.rs b/src/epd2in9bc/mod.rs index 4eb980fc..77111b35 100644 --- a/src/epd2in9bc/mod.rs +++ b/src/epd2in9bc/mod.rs @@ -68,8 +68,6 @@ use crate::traits::{ pub const WIDTH: u32 = 128; /// Height of epd2in9bc in pixels pub const HEIGHT: u32 = 296; -/// Default background color (white) of epd2in9bc display -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; @@ -100,7 +98,6 @@ pub type Display2in9bc = crate::graphics::Display< /// Epd2in9bc driver pub struct Epd2in9bc { interface: DisplayInterface, - color: Color, } impl InternalWiAdditions @@ -220,9 +217,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd2in9bc { interface, color }; + let mut epd = Epd2in9bc { interface }; epd.init(spi, delay)?; @@ -250,14 +246,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -277,7 +265,7 @@ where self.interface.data(spi, buffer)?; // Clear the chromatic layer - let color = self.color.get_byte_value(); + let color = Color::White.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; @@ -318,10 +306,15 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.send_resolution(spi)?; - let color = DEFAULT_BACKGROUND_COLOR.get_byte_value(); + let color = color.get_byte_value(); // Clear the black self.interface.cmd(spi, Command::DataStartTransmission1)?; diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index a5e52a8e..eef8af86 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -65,8 +65,6 @@ use crate::epd4in2::constants::*; pub const WIDTH: u32 = 400; /// Height of the display pub const HEIGHT: u32 = 300; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; use crate::color::Color; @@ -90,8 +88,6 @@ pub type Display4in2 = crate::graphics::Display< pub struct Epd4in2 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, /// Refresh LUT refresh: RefreshLut, } @@ -172,11 +168,9 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; let mut epd = Epd4in2 { interface, - color, refresh: RefreshLut::Full, }; @@ -208,14 +202,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -231,7 +217,7 @@ where delay: &mut DELAY, ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; - let color_value = self.color.get_byte_value(); + let color_value = Color::White.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface @@ -306,11 +292,16 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; - let color_value = self.color.get_byte_value(); + let color_value = color.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission1)?; self.interface @@ -580,7 +571,8 @@ where self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; - let color_value = self.color.get_byte_value(); + // TODO should the color be a parameter here ? + let color_value = Color::White.get_byte_value(); self.interface.cmd(spi, Command::PartialIn)?; self.interface.cmd(spi, Command::PartialWindow)?; @@ -608,6 +600,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 400); assert_eq!(HEIGHT, 300); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd5in65f/mod.rs b/src/epd5in65f/mod.rs index fde52050..3c2135d8 100644 --- a/src/epd5in65f/mod.rs +++ b/src/epd5in65f/mod.rs @@ -33,16 +33,12 @@ pub type Display5in65f = crate::graphics::Display< pub const WIDTH: u32 = 600; /// Height of the display pub const HEIGHT: u32 = 448; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: OctColor = OctColor::White; /// Epd5in65f driver /// pub struct Epd5in65f { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: OctColor, } impl InternalWiAdditions @@ -99,9 +95,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd5in65f { interface, color }; + let mut epd = Epd5in65f { interface }; epd.init(spi, delay)?; @@ -165,8 +160,13 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { - let bg = OctColor::colors_byte(self.color, self.color); + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { + let bg = OctColor::colors_byte(color, color); self.wait_until_idle(spi, delay)?; self.update_vcom(spi)?; self.send_resolution(spi)?; @@ -176,14 +176,6 @@ where Ok(()) } - fn set_background_color(&mut self, color: OctColor) { - self.color = color; - } - - fn background_color(&self) -> &OctColor { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -248,7 +240,7 @@ where } fn update_vcom(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { - let bg_color = (self.color.get_nibble() & 0b111) << 5; + let bg_color = (OctColor::White.get_nibble() & 0b111) << 5; self.cmd_with_data(spi, Command::VcomAndDataIntervalSetting, &[0x17 | bg_color])?; Ok(()) } @@ -262,6 +254,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 600); assert_eq!(HEIGHT, 448); - assert_eq!(DEFAULT_BACKGROUND_COLOR, OctColor::White); } } diff --git a/src/epd5in83b_v2/mod.rs b/src/epd5in83b_v2/mod.rs index 0a9ac8a5..a8c43010 100644 --- a/src/epd5in83b_v2/mod.rs +++ b/src/epd5in83b_v2/mod.rs @@ -34,8 +34,6 @@ pub type Display5in83 = crate::graphics::Display< pub const WIDTH: u32 = 648; /// Height of the display pub const HEIGHT: u32 = 480; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; @@ -44,8 +42,6 @@ const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; pub struct Epd5in83 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, } impl InternalWiAdditions @@ -159,9 +155,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd5in83 { interface, color }; + let mut epd = Epd5in83 { interface }; epd.init(spi, delay)?; @@ -180,14 +175,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -204,7 +191,7 @@ where ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.update_achromatic_frame(spi, delay, buffer)?; - let color = self.color.get_byte_value(); + let color = Color::White.get_byte_value(); self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; Ok(()) @@ -276,12 +263,22 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; + let color_byte = match color { + Color::White => 0xFF, + Color::Black => 0x00, + }; // The Waveshare controllers all implement clear using 0x33 self.command(spi, Command::DataStartTransmission1)?; - self.interface.data_x_times(spi, 0xFF, NUM_DISPLAY_BITS)?; + self.interface + .data_x_times(spi, color_byte, NUM_DISPLAY_BITS)?; self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, 0x00, NUM_DISPLAY_BITS)?; @@ -350,6 +347,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 648); assert_eq!(HEIGHT, 480); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs index 52237e6e..637bac6c 100644 --- a/src/epd7in5/mod.rs +++ b/src/epd7in5/mod.rs @@ -33,8 +33,6 @@ pub type Display7in5 = crate::graphics::Display< pub const WIDTH: u32 = 640; /// Height of the display pub const HEIGHT: u32 = 384; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; /// Epd7in5 driver @@ -42,8 +40,6 @@ const IS_BUSY_LOW: bool = true; pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, } impl InternalWiAdditions @@ -123,9 +119,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd7in5 { interface, color }; + let mut epd = Epd7in5 { interface }; epd.init(spi, delay)?; @@ -144,14 +139,6 @@ where self.init(spi, delay) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -212,14 +199,23 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; - // The Waveshare controllers all implement clear using 0x33 + // The Waveshare driver implement clear using 0x33 + let color_byte = match color { + Color::White => 0x33, + Color::Black => 0x00, + }; self.command(spi, Command::DataStartTransmission1)?; self.interface - .data_x_times(spi, 0x33, WIDTH / 8 * HEIGHT * 4)?; + .data_x_times(spi, color_byte, WIDTH / 8 * HEIGHT * 4)?; Ok(()) } @@ -284,6 +280,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 640); assert_eq!(HEIGHT, 384); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd7in5_hd/mod.rs b/src/epd7in5_hd/mod.rs index c29d723e..b0822d96 100644 --- a/src/epd7in5_hd/mod.rs +++ b/src/epd7in5_hd/mod.rs @@ -36,8 +36,6 @@ pub type Display7in5 = crate::graphics::Display< pub const WIDTH: u32 = 880; /// Height of the display pub const HEIGHT: u32 = 528; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; // Inverted for HD as compared to 7in5 v2 (HD: 0xFF = White) const IS_BUSY_LOW: bool = false; /// EPD7in5 (HD) driver @@ -45,8 +43,6 @@ const IS_BUSY_LOW: bool = false; pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, } impl InternalWiAdditions @@ -123,9 +119,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd7in5 { interface, color }; + let mut epd = Epd7in5 { interface }; epd.init(spi, delay)?; @@ -185,9 +180,14 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { let pixel_count = WIDTH * HEIGHT / 8; - let background_color_byte = self.color.get_byte_value(); + let background_color_byte = color.get_byte_value(); self.wait_until_idle(spi, delay)?; self.cmd_with_data(spi, Command::SetRamYAc, &[0x00, 0x00])?; @@ -204,14 +204,6 @@ where Ok(()) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -266,6 +258,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 880); assert_eq!(HEIGHT, 528); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs index fe6867dd..d485363c 100644 --- a/src/epd7in5_v2/mod.rs +++ b/src/epd7in5_v2/mod.rs @@ -37,8 +37,6 @@ pub type Display7in5 = crate::graphics::Display< pub const WIDTH: u32 = 800; /// Height of the display pub const HEIGHT: u32 = 480; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; const IS_BUSY_LOW: bool = true; /// Epd7in5 (V2) driver @@ -46,8 +44,6 @@ const IS_BUSY_LOW: bool = true; pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: Color, } impl InternalWiAdditions @@ -105,9 +101,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd7in5 { interface, color }; + let mut epd = Epd7in5 { interface }; epd.init(spi, delay)?; @@ -167,28 +162,31 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; + let byte_color = match color { + Color::White => 0x00, + Color::Black => 0xFF, + }; self.command(spi, Command::DataStartTransmission1)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; + self.interface + .data_x_times(spi, byte_color, WIDTH * HEIGHT / 8)?; self.command(spi, Command::DataStartTransmission2)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; + self.interface + .data_x_times(spi, byte_color, WIDTH * HEIGHT / 8)?; self.command(spi, Command::DisplayRefresh)?; Ok(()) } - fn set_background_color(&mut self, color: Color) { - self.color = color; - } - - fn background_color(&self) -> &Color { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -258,6 +256,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 800); assert_eq!(HEIGHT, 480); - assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); } } diff --git a/src/epd7in5_v3/mod.rs b/src/epd7in5_v3/mod.rs index 675ee048..bcf7d59a 100644 --- a/src/epd7in5_v3/mod.rs +++ b/src/epd7in5_v3/mod.rs @@ -2,9 +2,9 @@ //! //! # References //! -//! - [Datasheet](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT) -//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5_V2.c) -//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py) +//! - [Datasheet](Not found) +//! - [Waveshare C driver](Not found) +//! - [Waveshare Python driver](Not found) //! use embedded_hal::{ @@ -23,6 +23,8 @@ use self::command::Command; use crate::buffer_len; /// Full size buffer for use with the 7in5 v3 EPD +// Note v2 is bicolor, cannot find v3 on the website +// 7in5B v3 exists and is tricolor, but it doesn't work wit this driver #[cfg(feature = "graphics")] pub type Display7in5 = crate::graphics::Display< WIDTH, @@ -36,10 +38,6 @@ pub type Display7in5 = crate::graphics::Display< pub const WIDTH: u32 = 800; /// Height of the display pub const HEIGHT: u32 = 480; -/// Default Background Color -//pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; - -pub const DEFAULT_BACKGROUND_COLOR: TriColor = TriColor::White; /// Number of bits for b/w buffer and same for chromatic buffer const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; @@ -50,8 +48,6 @@ const IS_BUSY_LOW: bool = true; pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: TriColor, } impl InternalWiAdditions @@ -162,9 +158,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd7in5 { interface, color }; + let mut epd = Epd7in5 { interface }; epd.init(spi, delay)?; @@ -195,7 +190,7 @@ where self.interface.data(spi, buffer)?; // Clear the chromatic layer - let color = self.color.get_byte_value(); + let color = TriColor::White.get_byte_value(); self.interface.cmd(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, color, NUM_DISPLAY_BITS)?; @@ -235,12 +230,25 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; + let byte_color = match color { + TriColor::White => 0x00, + TriColor::Black => 0xFF, + // What is chromatic on a bicolor display ? + // What is chromatic on a bicolor display ? + TriColor::Chromatic => 0x00, + }; self.command(spi, Command::DataStartTransmission1)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; + self.interface + .data_x_times(spi, byte_color, WIDTH * HEIGHT / 8)?; self.command(spi, Command::DataStartTransmission2)?; self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; @@ -249,14 +257,6 @@ where Ok(()) } - fn set_background_color(&mut self, color: TriColor) { - self.color = color; - } - - fn background_color(&self) -> &TriColor { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -326,6 +326,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 800); assert_eq!(HEIGHT, 480); - assert_eq!(DEFAULT_BACKGROUND_COLOR, TriColor::White); } } diff --git a/src/epd7in5b_v2/mod.rs b/src/epd7in5b_v2/mod.rs index cdf0186b..9e3395b9 100644 --- a/src/epd7in5b_v2/mod.rs +++ b/src/epd7in5b_v2/mod.rs @@ -2,9 +2,9 @@ //! //! # References //! -//! - [Datasheet](https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT) -//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5_V2.c) -//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def0/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5_V2.py) +//! - [Datasheet](https://www.waveshare.com/product/7.5inch-e-paper-b.htm) +//! - [Waveshare C driver](https://github.com/waveshare/e-Paper/blob/702def06bc/RaspberryPi%26JetsonNano/c/lib/e-Paper/EPD_7in5b_V2.c) +//! - [Waveshare Python driver](https://github.com/waveshare/e-Paper/blob/702def06bc/RaspberryPi%26JetsonNano/python/lib/waveshare_epd/epd7in5bc_V2.py) //! //! Important note for V2: //! Revision V2 has been released on 2019.11, the resolution is upgraded to 800×480, from 640×384 of V1. @@ -37,8 +37,6 @@ pub type Display7in5 = crate::graphics::Display< pub const WIDTH: u32 = 800; /// Height of the display pub const HEIGHT: u32 = 480; -/// Default Background Color -pub const DEFAULT_BACKGROUND_COLOR: TriColor = TriColor::White; const NUM_DISPLAY_BYTES: usize = WIDTH as usize * HEIGHT as usize / 8; const IS_BUSY_LOW: bool = true; @@ -48,8 +46,6 @@ const IS_BUSY_LOW: bool = true; pub struct Epd7in5 { /// Connection Interface interface: DisplayInterface, - /// Background Color - color: TriColor, } impl InternalWiAdditions @@ -123,9 +119,8 @@ where delay_us: Option, ) -> Result { let interface = DisplayInterface::new(cs, busy, dc, rst, delay_us); - let color = DEFAULT_BACKGROUND_COLOR; - let mut epd = Epd7in5 { interface, color }; + let mut epd = Epd7in5 { interface }; epd.init(spi, delay)?; @@ -195,29 +190,31 @@ where Ok(()) } - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error> { + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error> { self.wait_until_idle(spi, delay)?; self.send_resolution(spi)?; + let (bw, chr) = match color { + TriColor::White => (0xFF, 0x00), + TriColor::Black => (0x00, 00), + TriColor::Chromatic => (0xFF, 00), + }; self.command(spi, Command::DataStartTransmission1)?; - self.interface.data_x_times(spi, 0xFF, WIDTH * HEIGHT / 8)?; + self.interface.data_x_times(spi, bw, WIDTH * HEIGHT / 8)?; self.command(spi, Command::DataStartTransmission2)?; - self.interface.data_x_times(spi, 0x00, WIDTH * HEIGHT / 8)?; + self.interface.data_x_times(spi, chr, WIDTH * HEIGHT / 8)?; self.command(spi, Command::DisplayRefresh)?; Ok(()) } - fn set_background_color(&mut self, color: Self::DisplayColor) { - self.color = color; - } - - fn background_color(&self) -> &Self::DisplayColor { - &self.color - } - fn width(&self) -> u32 { WIDTH } @@ -335,6 +332,5 @@ mod tests { fn epd_size() { assert_eq!(WIDTH, 800); assert_eq!(HEIGHT, 480); - assert_eq!(DEFAULT_BACKGROUND_COLOR, TriColor::White); } } diff --git a/src/traits.rs b/src/traits.rs index 00cceb6a..c76d92c5 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -176,12 +176,6 @@ where /// Also reintialises the device if necessary. fn wake_up(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>; - /// Sets the backgroundcolor for various commands like [clear_frame](WaveshareDisplay::clear_frame) - fn set_background_color(&mut self, color: Self::DisplayColor); - - /// Get current background color - fn background_color(&self) -> &Self::DisplayColor; - /// Get the width of the display fn width(&self) -> u32; @@ -226,10 +220,13 @@ where delay: &mut DELAY, ) -> Result<(), SPI::Error>; - /// Clears the frame buffer on the EPD with the declared background color - /// - /// The background color can be changed with [`WaveshareDisplay::set_background_color`] - fn clear_frame(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>; + /// Clears the frame buffer on the EPD with the given background color + fn clear_frame( + &mut self, + spi: &mut SPI, + delay: &mut DELAY, + color: Self::DisplayColor, + ) -> Result<(), SPI::Error>; /// Trait for using various Waveforms from different LUTs /// E.g. for partial refreshes @@ -283,7 +280,7 @@ where ///# let mut epd = Epd4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay, None)?; ///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 = [Color::White.get_byte_value(); 80 / 8 * 80]; ///let mut display = VarDisplay::new(frame_width, frame_height, &mut buffer,false).unwrap(); /// ///epd.update_partial_old_frame(&mut spi, &mut delay, display.buffer(), x, y, frame_width, frame_height) @@ -359,8 +356,7 @@ where height: u32, ) -> Result<(), SPI::Error>; - /// Clears the partial frame buffer on the EPD with the declared background color - /// The background color can be changed with [`WaveshareDisplay::set_background_color`] + /// Clears the partial frame buffer on the EPD with the given background color fn clear_partial_frame( &mut self, spi: &mut SPI,