From 409676423de7465b95db6d4ce67793bc7eb6e582 Mon Sep 17 00:00:00 2001
From: Caemor <11088935+caemor@users.noreply.github.com>
Date: Thu, 26 Mar 2020 19:55:17 +0100
Subject: [PATCH] Mainly improved Documenation
---
CHANGELOG.md | 2 +
README.md | 6 +--
src/epd1in54/mod.rs | 58 +++++++++++++++---------
src/epd1in54b/graphics.rs | 3 ++
src/epd1in54b/mod.rs | 3 ++
src/epd2in9/mod.rs | 61 ++++++++++++++-----------
src/epd4in2/mod.rs | 79 +++++++++++++++-----------------
src/epd7in5/mod.rs | 21 ++-------
src/epd7in5_v2/mod.rs | 21 ++-------
src/graphics.rs | 9 ++++
src/lib.rs | 95 +++++++++++++++++++++------------------
src/traits.rs | 57 +++++++++++++++++++----
12 files changed, 230 insertions(+), 185 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b06b281..873d235 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Update and integrate a few important examples and remove the others
- Add update_and_display_frame to the main trait, fixes #38
- Also improve position of busy_wait (#30) once more
+ - Fixed all doc tests
+ - Some more documentation improvements
diff --git a/README.md b/README.md
index 2771eb9..5ac5ce0 100644
--- a/README.md
+++ b/README.md
@@ -45,7 +45,7 @@ epd.display_frame(&mut spi)?;
| [4.2 Inch B/W (A)](https://www.waveshare.com/product/4.2inch-e-paper-module.htm) | Black, White | ✕ | Not officially [[2](#2-42-inch-e-ink-blackwhite---partial-refresh)] | ✔ | ✔ |
| [1.54 Inch B/W (A)](https://www.waveshare.com/1.54inch-e-Paper-Module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ |
| [2.13 Inch B/W (A)](https://www.waveshare.com/product/2.13inch-e-paper-hat.htm) | Black, White | ✕ | ✔ | | |
-| [2.9 Inch B/W (A)](https://www.waveshare.com/product/2.9inch-e-paper-module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ [[3](#3-29-inch-e-ink-blackwhite---tests)] |
+| [2.9 Inch B/W (A)](https://www.waveshare.com/product/2.9inch-e-paper-module.htm) | Black, White | ✕ | ✔ | ✔ | ✔ |
| [1.54 Inch B/W/R (B)](https://www.waveshare.com/product/modules/oleds-lcds/e-paper/1.54inch-e-paper-module-b.htm) | Black, White, Red | ✕ | ✕ | ✔ | ✔ |
### [1]: 7.5 Inch B/W V2 (A)
@@ -62,10 +62,6 @@ Out of the Box the original driver from Waveshare only supports full updates.
That means: Be careful with the quick refresh updates:
It's possible with this driver but might lead to ghosting / burn-in effects therefore it's hidden behind a feature.
-### [3]: 2.9 Inch E-Ink Black/White - Tests
-
-Since my 2.9 Inch Display has some blurring issues I am not absolutly sure if everything was working correctly as it should :-)
-
### Interface
| Interface | Description |
diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs
index 2927730..bc5cd5b 100644
--- a/src/epd1in54/mod.rs
+++ b/src/epd1in54/mod.rs
@@ -2,37 +2,51 @@
//!
//! # Example for the 1.54 in E-Ink Display
//!
-//! ```rust,no_run
-//! use epd_waveshare::{
-//! epd1in54::{EPD1in54, Display1in54},
-//! graphics::{Display, DisplayRotation},
-//! prelude::*,
-//! };
-//! use embedded_graphics::Drawing;
+//!```rust, no_run
+//!# use embedded_hal_mock::*;
+//!# fn main() -> Result<(), MockError> {
+//!use embedded_graphics::{
+//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
+//!};
+//!use epd_waveshare::{epd1in54::*, prelude::*};
+//!#
+//!# let expectations = [];
+//!# let mut spi = spi::Mock::new(&expectations);
+//!# let expectations = [];
+//!# let cs_pin = pin::Mock::new(&expectations);
+//!# let busy_in = pin::Mock::new(&expectations);
+//!# let dc = pin::Mock::new(&expectations);
+//!# let rst = pin::Mock::new(&expectations);
+//!# let mut delay = delay::MockNoop::new();
//!
-//! // Setup EPD
-//! let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay).unwrap();
+//!// Setup EPD
+//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//!
-//! // Use display graphics
-//! let mut display = Display1in54::default();
+//!// Use display graphics from embedded-graphics
+//!let mut display = Display1in54::default();
//!
-//! // Write some hello world in the screenbuffer
-//! let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
-//! .into_styled(PrimitiveStyle::with_stroke(BinaryColor::On, 1))
-//! .draw(&mut display);
+//!// Use embedded graphics for drawing a line
+//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
+//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
+//! .draw(&mut display);
//!
-//! // Display updated frame
-//! epd.update_frame(&mut spi, &display.buffer()).unwrap();
-//! epd.display_frame(&mut spi).expect("display frame new graphics");
+//! // Display updated frame
+//!epd.update_frame(&mut spi, &display.buffer())?;
+//!epd.display_frame(&mut spi)?;
//!
-//! // Set the EPD to sleep
-//! epd.sleep(&mut spi).expect("sleep");
-//! ```
+//!// Set the EPD to sleep
+//!epd.sleep(&mut spi)?;
+//!# Ok(())
+//!# }
+//!```
+/// Width of the display
pub const WIDTH: u32 = 200;
+/// Height of the display
pub const HEIGHT: u32 = 200;
-//const DPI: u16 = 184;
+/// Default Background Color
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
+//const DPI: u16 = 184;
const IS_BUSY_LOW: bool = false;
use embedded_hal::{
diff --git a/src/epd1in54b/graphics.rs b/src/epd1in54b/graphics.rs
index a1e83e1..617d697 100644
--- a/src/epd1in54b/graphics.rs
+++ b/src/epd1in54b/graphics.rs
@@ -3,6 +3,9 @@ use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
+/// Full size buffer for use with the 1in54 EPD
+///
+/// Can also be manually constructed and be used together with VarDisplay
pub struct Display1in54b {
buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
rotation: DisplayRotation,
diff --git a/src/epd1in54b/mod.rs b/src/epd1in54b/mod.rs
index 52d402f..9244093 100644
--- a/src/epd1in54b/mod.rs
+++ b/src/epd1in54b/mod.rs
@@ -14,8 +14,11 @@ use crate::traits::{
mod constants;
use crate::epd1in54b::constants::*;
+/// Width of epd1in54 in pixels
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;
diff --git a/src/epd2in9/mod.rs b/src/epd2in9/mod.rs
index 28c283b..6ccd551 100644
--- a/src/epd2in9/mod.rs
+++ b/src/epd2in9/mod.rs
@@ -1,42 +1,51 @@
//! A simple Driver for the Waveshare 2.9" E-Ink Display via SPI
//!
-//! Untested!
//!
//! # Example for the 2.9 in E-Ink Display
//!
-//! ```rust,ignore
-//! use epd_waveshare::{
-//! epd2in9::{EPD2in9, Display2in9},
-//! graphics::{Display, DisplayRotation},
-//! prelude::*,
-//! };
-//! use embedded_graphics::Drawing;
+//!```rust, no_run
+//!# use embedded_hal_mock::*;
+//!# fn main() -> Result<(), MockError> {
+//!use embedded_graphics::{
+//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
+//!};
+//!use epd_waveshare::{epd2in9::*, prelude::*};
+//!#
+//!# let expectations = [];
+//!# let mut spi = spi::Mock::new(&expectations);
+//!# let expectations = [];
+//!# let cs_pin = pin::Mock::new(&expectations);
+//!# let busy_in = pin::Mock::new(&expectations);
+//!# let dc = pin::Mock::new(&expectations);
+//!# let rst = pin::Mock::new(&expectations);
+//!# let mut delay = delay::MockNoop::new();
//!
-//! // Setup EPD
-//! let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay).unwrap();
+//!// Setup EPD
+//!let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//!
-//! // Use display graphics
-//! let mut display = Display2in9::default();
+//!// Use display graphics from embedded-graphics
+//!let mut display = Display2in9::default();
//!
-//! // Write some hello world in the screenbuffer
-//! display.draw(
-//! Font6x8::render_str("Hello World!")
-//! .stroke(Some(Color::Black))
-//! .fill(Some(Color::White))
-//! .translate(Point::new(5, 50))
-//! .into_iter(),
-//! );
+//!// Use embedded graphics for drawing a line
+//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
+//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
+//! .draw(&mut display);
//!
-//! // Display updated frame
-//! epd.update_frame(&mut spi, &display.buffer()).unwrap();
-//! epd.display_frame(&mut spi).expect("display frame new graphics");
+//! // Display updated frame
+//!epd.update_frame(&mut spi, &display.buffer())?;
+//!epd.display_frame(&mut spi)?;
//!
-//! // Set the EPD to sleep
-//! epd.sleep(&mut spi).expect("sleep");
-//! ```
+//!// Set the EPD to sleep
+//!epd.sleep(&mut spi)?;
+//!# Ok(())
+//!# }
+//!```
+/// Width of epd2in9 in pixels
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;
diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs
index 7772ad4..582b409 100644
--- a/src/epd4in2/mod.rs
+++ b/src/epd4in2/mod.rs
@@ -1,46 +1,49 @@
//! A simple Driver for the Waveshare 4.2" E-Ink Display via SPI
//!
-//! The other Waveshare E-Ink Displays should be added later on
//!
//! Build with the help of documentation/code from [Waveshare](https://www.waveshare.com/wiki/4.2inch_e-Paper_Module),
//! [Ben Krasnows partial Refresh tips](https://benkrasnow.blogspot.de/2017/10/fast-partial-refresh-on-42-e-paper.html) and
//! the driver documents in the `pdfs`-folder as orientation.
//!
-//! This driver was built using [`embedded-hal`] traits.
-//!
-//! [`embedded-hal`]: https://docs.rs/embedded-hal/~0.1
-//!
-//! # Requirements
-//!
-//! ### SPI
-//!
-//! - MISO is not connected/available
-//! - SPI_MODE_0 is used (CPHL = 0, CPOL = 0)
-//! - 8 bits per word, MSB first
-//! - Max. Speed tested was 8Mhz but more should be possible
-//!
-//! ### Other....
-//!
-//! - Buffersize: Wherever a buffer is used it always needs to be of the size: `width / 8 * length`,
-//! where width and length being either the full e-ink size or the partial update window size
-//!
//! # Examples
//!
-//! ```ignore
-//! let mut epd4in2 = EPD4in2::new(spi, cs, busy, dc, rst, delay).unwrap();
-//!
-//! let mut buffer = [0u8, epd4in2.get_width() / 8 * epd4in2.get_height()];
+//!```rust, no_run
+//!# use embedded_hal_mock::*;
+//!# fn main() -> Result<(), MockError> {
+//!use embedded_graphics::{
+//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
+//!};
+//!use epd_waveshare::{epd4in2::*, prelude::*};
+//!#
+//!# let expectations = [];
+//!# let mut spi = spi::Mock::new(&expectations);
+//!# let expectations = [];
+//!# let cs_pin = pin::Mock::new(&expectations);
+//!# let busy_in = pin::Mock::new(&expectations);
+//!# let dc = pin::Mock::new(&expectations);
+//!# let rst = pin::Mock::new(&expectations);
+//!# let mut delay = delay::MockNoop::new();
//!
-//! // draw something into the buffer
+//!// Setup EPD
+//!let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//!
-//! epd4in2.display_and_transfer_buffer(buffer, None);
+//!// Use display graphics from embedded-graphics
+//!let mut display = Display4in2::default();
//!
-//! // wait and look at the image
+//!// Use embedded graphics for drawing a line
+//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
+//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
+//! .draw(&mut display);
//!
-//! epd4in2.clear_frame(None);
+//! // Display updated frame
+//!epd.update_frame(&mut spi, &display.buffer())?;
+//!epd.display_frame(&mut spi)?;
//!
-//! epd4in2.sleep();
-//! ```
+//!// Set the EPD to sleep
+//!epd.sleep(&mut spi)?;
+//!# Ok(())
+//!# }
+//!```
//!
//!
//!
@@ -58,8 +61,11 @@ use crate::traits::{InternalWiAdditions, RefreshLUT, WaveshareDisplay};
mod constants;
use crate::epd4in2::constants::*;
+/// Width of the display
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;
@@ -142,21 +148,6 @@ where
DC: OutputPin,
RST: OutputPin,
{
- /// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
- ///
- /// This already initialises the device. That means [init()](init()) isn't needed directly afterwards
- ///
- /// # Example
- ///
- /// ```ignore
- /// //buffer = some image data;
- ///
- /// let mut epd4in2 = EPD4in2::new(spi, cs, busy, dc, rst, delay);
- ///
- /// epd4in2.display_and_transfer_frame(buffer, None);
- ///
- /// epd4in2.sleep();
- /// ```
fn new>(
spi: &mut SPI,
cs: CS,
diff --git a/src/epd7in5/mod.rs b/src/epd7in5/mod.rs
index f30c396..2c6e76b 100644
--- a/src/epd7in5/mod.rs
+++ b/src/epd7in5/mod.rs
@@ -23,8 +23,11 @@ mod graphics;
#[cfg(feature = "graphics")]
pub use self::graphics::Display7in5;
+/// Width of the 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;
@@ -105,24 +108,6 @@ where
DC: OutputPin,
RST: OutputPin,
{
- /// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
- ///
- /// This already initialises the device. That means [init()] isn't needed
- /// directly afterwards.
- ///
- /// [init()]: InternalWiAdditions::init
- ///
- /// # Example
- ///
- /// ```ignore
- /// //buffer = some image data;
- ///
- /// let mut epd7in5 = EPD7in5::new(spi, cs, busy, dc, rst, delay);
- ///
- /// epd7in5.display_and_transfer_frame(buffer, None);
- ///
- /// epd7in5.sleep();
- /// ```
fn new>(
spi: &mut SPI,
cs: CS,
diff --git a/src/epd7in5_v2/mod.rs b/src/epd7in5_v2/mod.rs
index 68c9a46..89d5614 100644
--- a/src/epd7in5_v2/mod.rs
+++ b/src/epd7in5_v2/mod.rs
@@ -27,8 +27,11 @@ mod graphics;
#[cfg(feature = "graphics")]
pub use self::graphics::Display7in5;
+/// Width of the 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;
@@ -87,24 +90,6 @@ where
DC: OutputPin,
RST: OutputPin,
{
- /// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
- ///
- /// This already initialises the device. That means [init()] isn't needed
- /// directly afterwards.
- ///
- /// [init()]: InternalWiAdditions::init
- ///
- /// # Example
- ///
- /// ```rust,ignore
- /// //buffer = some image data;
- ///
- /// let mut epd7in5 = EPD7in5::new(spi, cs, busy, dc, rst, delay);
- ///
- /// epd7in5.update_and_display_frame(&mut spi, &buffer);
- ///
- /// epd7in5.sleep();
- /// ```
fn new>(
spi: &mut SPI,
cs: CS,
diff --git a/src/graphics.rs b/src/graphics.rs
index 49758d3..e8ff524 100644
--- a/src/graphics.rs
+++ b/src/graphics.rs
@@ -22,6 +22,12 @@ impl Default for DisplayRotation {
}
}
+/// Necessary traits for all displays to implement for drawing
+///
+/// Adds support for:
+/// - Drawing (With the help of DrawTarget/Embedded Graphics)
+/// - Rotations
+/// - Clearing
pub trait Display: DrawTarget {
/// Clears the buffer of the display with the chosen background color
fn clear_buffer(&mut self, background_color: Color) {
@@ -112,6 +118,9 @@ pub struct VarDisplay<'a> {
}
impl<'a> VarDisplay<'a> {
+ /// Create a new variable sized display.
+ ///
+ /// Buffersize must be at least width / 8 * height bytes.
pub fn new(width: u32, height: u32, buffer: &'a mut [u8]) -> VarDisplay<'a> {
let len = buffer.len() as u32;
assert!(width / 8 * height >= len);
diff --git a/src/lib.rs b/src/lib.rs
index 5d8c9d8..754c790 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,58 +1,66 @@
-//! A simple Driver for the Waveshare E-Ink Displays via SPI
+//! A simple Driver for the [Waveshare](https://github.com/waveshare/e-Paper) E-Ink Displays via SPI
//!
-//! This driver was built using [`embedded-hal`] traits.
+//! - Built using [`embedded-hal`] traits.
+//! - Graphics support is added through [`embedded-graphics`]
//!
-//! [`embedded-hal`]: https://docs.rs/embedded-hal/~0.1
+//! [`embedded-graphics`]: https://docs.rs/embedded-graphics/
+//! [`embedded-hal`]: https://docs.rs/embedded-hal
//!
-//! # Requirements
-//!
-//! ### SPI
-//!
-//! - MISO is not connected/available
-//! - SPI_MODE_0 is used (CPHL = 0, CPOL = 0)
-//! - 8 bits per word, MSB first
-//! - Max. Speed tested by myself was 8Mhz but more should be possible (Ben Krasnow used 18Mhz with his implemenation)
+
//!
-//! ### Other....
+//! # Example
+//!
+//!```rust, no_run
+//!# use embedded_hal_mock::*;
+//!# fn main() -> Result<(), MockError> {
+//!use embedded_graphics::{
+//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
+//!};
+//!use epd_waveshare::{epd1in54::*, prelude::*};
+//!#
+//!# let expectations = [];
+//!# let mut spi = spi::Mock::new(&expectations);
+//!# let expectations = [];
+//!# let cs_pin = pin::Mock::new(&expectations);
+//!# let busy_in = pin::Mock::new(&expectations);
+//!# let dc = pin::Mock::new(&expectations);
+//!# let rst = pin::Mock::new(&expectations);
+//!# let mut delay = delay::MockNoop::new();
+//!
+//!// Setup EPD
+//!let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
+//!
+//!// Use display graphics from embedded-graphics
+//!let mut display = Display1in54::default();
+//!
+//!// Use embedded graphics for drawing a line
+//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
+//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
+//! .draw(&mut display);
+//!
+//! // Display updated frame
+//!epd.update_frame(&mut spi, &display.buffer())?;
+//!epd.display_frame(&mut spi)?;
+//!
+//!// Set the EPD to sleep
+//!epd.sleep(&mut spi)?;
+//!# Ok(())
+//!# }
+//!```
+//!
+//! # Other information and requirements
//!
//! - Buffersize: Wherever a buffer is used it always needs to be of the size: `width / 8 * length`,
//! where width and length being either the full e-ink size or the partial update window size
//!
-//! # Examples
-//!
-//! ```rust,ignore
-//! use epd_waveshare::{
-//! epd2in9::{EPD2in9, Display2in9},
-//! graphics::{Display, DisplayRotation},
-//! prelude::*,
-//! };
-//! use embedded_graphics::Drawing;
-//!
-//! // Setup EPD
-//! let mut epd = EPD2in9::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay).unwrap();
-//!
-//! // Use display graphics
-//! let mut display = Display2in9::default();
-//!
-//! // Write some hello world in the screenbuffer
-//! display.draw(
-//! Font6x8::render_str("Hello World!")
-//! .stroke(Some(Color::Black))
-//! .fill(Some(Color::White))
-//! .translate(Point::new(5, 50))
-//! .into_iter(),
-//! );
-//!
-//! // Display updated frame
-//! epd.update_frame(&mut spi, &display.buffer()).unwrap();
-//! epd.display_frame(&mut spi).expect("display frame new graphics");
+//! ### SPI
//!
-//! // Set the EPD to sleep
-//! epd.sleep(&mut spi).expect("sleep");
-//! ```
+//! MISO is not connected/available. SPI_MODE_0 is used (CPHL = 0, CPOL = 0) with 8 bits per word, MSB first.
//!
+//! Maximum speed tested by myself was 8Mhz but more should be possible (Ben Krasnow used 18Mhz with his implemenation)
//!
#![no_std]
+#![deny(missing_docs)]
#[cfg(feature = "graphics")]
pub mod graphics;
@@ -72,6 +80,7 @@ pub mod epd7in5;
pub mod epd7in5_v2;
pub(crate) mod type_a;
+/// Includes everything important besides the chosen Display
pub mod prelude {
pub use crate::color::Color;
pub use crate::traits::{RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay};
diff --git a/src/traits.rs b/src/traits.rs
index 91352ee..eed2672 100644
--- a/src/traits.rs
+++ b/src/traits.rs
@@ -38,11 +38,11 @@ where
/// This initialises the EPD and powers it up
///
/// This function is already called from
- /// - [new()](WaveshareInterface::new())
+ /// - [new()](WaveshareDisplay::new())
/// - [`wake_up`]
///
///
- /// This function calls [reset()](WaveshareInterface::reset()),
+ /// This function calls [reset](WaveshareDisplay::reset),
/// so you don't need to call reset your self when trying to wake your device up
/// after setting it to sleep.
fn init>(
@@ -75,7 +75,47 @@ where
/// All the functions to interact with the EPDs
///
-/// This trait includes all public functions to use the EPDS
+/// This trait includes all public functions to use the EPDs
+///
+/// # Example
+///
+///```rust, no_run
+///# use embedded_hal_mock::*;
+///# fn main() -> Result<(), MockError> {
+///use embedded_graphics::{
+/// pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
+///};
+///use epd_waveshare::{epd4in2::*, prelude::*};
+///#
+///# let expectations = [];
+///# let mut spi = spi::Mock::new(&expectations);
+///# let expectations = [];
+///# let cs_pin = pin::Mock::new(&expectations);
+///# let busy_in = pin::Mock::new(&expectations);
+///# let dc = pin::Mock::new(&expectations);
+///# let rst = pin::Mock::new(&expectations);
+///# let mut delay = delay::MockNoop::new();
+///
+///// Setup EPD
+///let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
+///
+///// Use display graphics from embedded-graphics
+///let mut display = Display4in2::default();
+///
+///// Use embedded graphics for drawing a line
+///let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
+/// .into_styled(PrimitiveStyle::with_stroke(Black, 1))
+/// .draw(&mut display);
+///
+/// // Display updated frame
+///epd.update_frame(&mut spi, &display.buffer())?;
+///epd.display_frame(&mut spi)?;
+///
+///// Set the EPD to sleep
+///epd.sleep(&mut spi)?;
+///# Ok(())
+///# }
+///```
pub trait WaveshareDisplay
where
SPI: Write,
@@ -86,7 +126,7 @@ where
{
/// Creates a new driver from a SPI peripheral, CS Pin, Busy InputPin, DC
///
- /// This already initialises the device. That means [init()](WaveshareInterface::init()) isn't needed directly afterwards
+ /// This already initialises the device.
fn new>(
spi: &mut SPI,
cs: CS,
@@ -101,19 +141,18 @@ where
/// Let the device enter deep-sleep mode to save power.
///
/// The deep sleep mode returns to standby with a hardware reset.
- /// But you can also use [wake_up()](WaveshareInterface::wake_up()) to awaken.
- /// But as you need to power it up once more anyway you can also just directly use [new()](WaveshareInterface::new()) for resetting
- /// and initialising which already contains the reset
fn sleep(&mut self, spi: &mut SPI) -> Result<(), SPI::Error>;
/// Wakes the device up from sleep
+ ///
+ /// 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()](WaveshareInterface::clear_frame())
+ /// Sets the backgroundcolor for various commands like [clear_frame](WaveshareDisplay::clear_frame)
fn set_background_color(&mut self, color: Color);
/// Get current background color
@@ -153,7 +192,7 @@ where
/// Clears the frame buffer on the EPD with the declared background color
///
- /// The background color can be changed with [`set_background_color`]
+ /// The background color can be changed with [`WaveshareDisplay::set_background_color`]
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error>;
/// Trait for using various Waveforms from different LUTs