diff --git a/Cargo.toml b/Cargo.toml index ffe9c4e..0e7779a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,8 +30,6 @@ epd4in2_fast_update = [] [dependencies.embedded-graphics] optional = true version = "0.4.3" -# embedded-graphics = {git = "https://github.com/caemor/embedded-graphics", branch = "master"} -# embedded-graphics = {git = "https://github.com/jamwaffles/embedded-graphics", branch = "master"} [dependencies.embedded-hal] features = ["unproven"] diff --git a/src/epd1in54/graphics.rs b/src/epd1in54/graphics.rs index 2604645..1a9d620 100644 --- a/src/epd1in54/graphics.rs +++ b/src/epd1in54/graphics.rs @@ -1,5 +1,9 @@ use epd1in54::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; +/// Full size buffer for use with the 1in54 EPD +/// +/// Can also be manuall constructed: +/// `buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); WIDTH / 8 * HEIGHT]` pub struct Buffer1in54BlackWhite { pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], } diff --git a/src/epd1in54/mod.rs b/src/epd1in54/mod.rs index 2bb8eea..80e1a3c 100644 --- a/src/epd1in54/mod.rs +++ b/src/epd1in54/mod.rs @@ -4,19 +4,34 @@ //! # Examples from the 4.2" Display. It should work the same for the 1.54" one. //! //! ```ignore -//! let mut epd4in2 = EPD4in2::new(spi, cs, busy, dc, rst, delay).unwrap(); +//! use eink_waveshare_rs::{ +//! epd1in54::{EPD1in54, Buffer1in54}, +//! graphics::{Display, DisplayRotation}, +//! prelude::*, +//! }; +//! +//! // Setup EPD +//! let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //! -//! let mut buffer = [0u8, epd4in2.get_width() / 8 * epd4in2.get_height()]; +//! // Use display graphics +//! let mut buffer = Buffer1in54::default(); +//! let mut display = Display::new(epd.width(), epd.height(), &mut buffer.buffer); +//! +//! // Write some hello world in the screenbuffer +//! display.draw( +//! Font6x8::render_str("Hello World!") +//! .with_stroke(Some(Color::Black)) +//! .with_fill(Some(Color::White)) +//! .translate(Coord::new(5, 50)) +//! .into_iter(), +//! ); //! -//! // draw something into the buffer -//! -//! epd4in2.display_and_transfer_buffer(buffer, None); -//! -//! // wait and look at the image -//! -//! epd4in2.clear_frame(None); -//! -//! epd4in2.sleep(); +//! // Display updated frame +//! epd.update_frame(&mut spi, &display.buffer()).unwrap(); +//! epd.display_frame(&mut spi).expect("display frame new graphics"); +//! +//! // Set the EPD to sleep +//! epd.sleep(&mut spi).expect("sleep"); //! ``` pub const WIDTH: u32 = 200; diff --git a/src/epd2in9/graphics.rs b/src/epd2in9/graphics.rs index 45e17d9..2e6c31d 100644 --- a/src/epd2in9/graphics.rs +++ b/src/epd2in9/graphics.rs @@ -1,5 +1,9 @@ use epd2in9::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; +/// Full size buffer for use with the 2in9 EPD +/// +/// Can also be manuall constructed: +/// `buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); WIDTH / 8 * HEIGHT]` pub struct Buffer2in9 { pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], } diff --git a/src/epd4in2/graphics.rs b/src/epd4in2/graphics.rs index 586234d..601459a 100644 --- a/src/epd4in2/graphics.rs +++ b/src/epd4in2/graphics.rs @@ -1,5 +1,9 @@ use epd4in2::constants::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; +/// Full size buffer for use with the 4in2 EPD +/// +/// Can also be manuall constructed: +/// `buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); WIDTH / 8 * HEIGHT]` pub struct Buffer4in2 { pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], }