From 80090d8df21b248a9908078d32fe0b9a5162c8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Gro=C3=9F?= Date: Tue, 9 Oct 2018 09:56:51 +0200 Subject: [PATCH] Added testcases for default size and color of the various displays --- src/color.rs | 2 +- src/epd1in54/mod.rs | 12 ++++++++++++ src/epd2in9/mod.rs | 13 +++++++++++++ src/epd4in2/constants.rs | 3 +++ src/epd4in2/mod.rs | 15 ++++++++++++++- 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/color.rs b/src/color.rs index 81d1aee..edee7e8 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,5 +1,5 @@ /// Only for the B/W Displays atm -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq, Debug)] pub enum Color { Black, White, diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 00d00b5..0f282ca 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -284,3 +284,15 @@ where self.interface.command_with_data(Command::WRITE_LUT_REGISTER, buffer) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn epd_size() { + assert_eq!(WIDTH, 200); + assert_eq!(HEIGHT, 200); + assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); + } +} \ No newline at end of file diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs index 080f795..90b5e02 100644 --- a/src/epd2in9/mod.rs +++ b/src/epd2in9/mod.rs @@ -286,3 +286,16 @@ where self.interface.command_with_data(Command::WRITE_LUT_REGISTER, buffer) } } + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn epd_size() { + assert_eq!(WIDTH, 128); + assert_eq!(HEIGHT, 296); + assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); + } +} \ No newline at end of file diff --git a/src/epd4in2/constants.rs b/src/epd4in2/constants.rs index 47ec396..2e484a4 100644 --- a/src/epd4in2/constants.rs +++ b/src/epd4in2/constants.rs @@ -1,5 +1,8 @@ +use color::Color; + pub(crate) const WIDTH: u16 = 400; pub(crate) const HEIGHT: u16 = 300; +pub(crate) const DEFAULT_BACKGROUND_COLOR: Color = Color::White; pub(crate) const LUT_VCOM0: [u8; 44] = [ 0x00, 0x17, 0x00, 0x00, 0x00, 0x02, diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index e7f0d2f..81ca731 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -161,7 +161,7 @@ where /// ``` fn new(spi: SPI, cs: CS, busy: BUSY, dc: DC, rst: RST, delay: Delay) -> Result { let interface = ConnectionInterface::new(spi, cs, busy, dc, rst, delay); - let color = Color::White; + let color = DEFAULT_BACKGROUND_COLOR; let mut epd = EPD4in2 { interface, @@ -393,3 +393,16 @@ where Ok(()) } } + + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn epd_size() { + assert_eq!(WIDTH, 400); + assert_eq!(HEIGHT, 300); + assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White); + } +} \ No newline at end of file