diff --git a/examples/stm32f3discovery/src/main.rs b/examples/stm32f3discovery/src/main.rs index c4614f4..1a00c40 100644 --- a/examples/stm32f3discovery/src/main.rs +++ b/examples/stm32f3discovery/src/main.rs @@ -29,8 +29,7 @@ use eink_waveshare_rs::{ epd1in54::EPD1in54, SPI_MODE, //drawing_old::{Graphics}, - color::Color, - WaveshareDisplay, + prelude::*, }; diff --git a/src/color.rs b/src/color.rs index 7f2f8f9..611965e 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,13 +1,17 @@ +//! B/W Color for EPDs - -/// Only for the B/W Displays atm +/// Only for the Black/White-Displays #[derive(Clone, Copy, PartialEq, Debug)] pub enum Color { + /// Black color Black, + /// White color White, } +//TODO: Rename get_bit_value to bit() and get_byte_value to byte() ? + impl Color { /// Get the color encoding of the color for one bit pub fn get_bit_value(&self) -> u8 { @@ -25,7 +29,7 @@ impl Color { } } - /// Parses + /// Parses from u8 to Color fn from_u8(val: u8) -> Self { match val { 0 => Color::Black, diff --git a/src/graphics.rs b/src/graphics.rs index 2cbd3ff..5f42e6a 100644 --- a/src/graphics.rs +++ b/src/graphics.rs @@ -1,3 +1,5 @@ +//! Graphics Support for EPDs + use color::Color; use embedded_graphics::prelude::*; diff --git a/src/lib.rs b/src/lib.rs index a115add..1d5ea1f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,7 +48,6 @@ extern crate embedded_graphics; pub mod graphics; mod traits; -pub use traits::{WaveshareDisplay}; pub mod color; @@ -67,10 +66,18 @@ pub mod epd2in9; #[cfg(any(feature = "epd1in54", feature = "epd2in9"))] pub(crate) mod type_a; -/// SPI mode - -/// For more infos see [Requirements: SPI](index.html#spi) +pub mod prelude { + pub use traits::{WaveshareDisplay}; + pub use color::Color; + pub use SPI_MODE; +} + + extern crate embedded_hal as hal; use hal::spi::{Mode, Phase, Polarity}; + +/// SPI mode - +/// For more infos see [Requirements: SPI](index.html#spi) pub const SPI_MODE: Mode = Mode { phase: Phase::CaptureOnFirstTransition, polarity: Polarity::IdleLow, diff --git a/src/traits.rs b/src/traits.rs index be64cb6..fb395e9 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -3,20 +3,15 @@ use hal::{ blocking::{delay::*, spi::Write}, digital::*, }; - use color::Color; - - - /// All commands need to have this trait which gives the address of the command /// which needs to be send via SPI with activated CommandsPin (Data/Command Pin in CommandMode) pub(crate) trait Command { fn address(self) -> u8; } - // Trait for using various Waveforms from different LUTs // E.g. for partial updates trait LUTSupport { @@ -25,7 +20,6 @@ trait LUTSupport { fn set_lut_manual(&mut self, data: &[u8]) -> Result<(), ERR>; } - pub(crate) trait InternalWiAdditions where SPI: Write, @@ -48,6 +42,9 @@ where } +/// All the functions to interact with the EPDs +/// +/// This trait includes all public functions to use the EPDS pub trait WaveshareDisplay where SPI: Write, @@ -73,6 +70,7 @@ where /// and initialising which already contains the reset fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error>; + /// Wakes the device up from sleep fn wake_up>(&mut self, spi: &mut SPI, delay: &mut DELAY) -> Result<(), SPI::Error>;