Browse Source

Improved Documentation

embedded-hal-1.0
Chris 7 years ago
parent
commit
3fc25d71e5
  1. 2
      Cargo.toml
  2. 4
      src/epd1in54/graphics.rs
  3. 31
      src/epd1in54/mod.rs
  4. 4
      src/epd2in9/graphics.rs
  5. 4
      src/epd4in2/graphics.rs

2
Cargo.toml

@ -30,8 +30,6 @@ epd4in2_fast_update = []
[dependencies.embedded-graphics] [dependencies.embedded-graphics]
optional = true optional = true
version = "0.4.3" 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] [dependencies.embedded-hal]
features = ["unproven"] features = ["unproven"]

4
src/epd1in54/graphics.rs

@ -1,5 +1,9 @@
use epd1in54::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; 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 struct Buffer1in54BlackWhite {
pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
} }

31
src/epd1in54/mod.rs

@ -4,19 +4,34 @@
//! # Examples from the 4.2" Display. It should work the same for the 1.54" one. //! # Examples from the 4.2" Display. It should work the same for the 1.54" one.
//! //!
//! ```ignore //! ```ignore
//! let mut epd4in2 = EPD4in2::new(spi, cs, busy, dc, rst, delay).unwrap(); //! use eink_waveshare_rs::{
//! epd1in54::{EPD1in54, Buffer1in54},
//! graphics::{Display, DisplayRotation},
//! prelude::*,
//! };
//! //!
//! let mut buffer = [0u8, epd4in2.get_width() / 8 * epd4in2.get_height()]; //! // Setup EPD
//! let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//! // draw something into the buffer //! // Use display graphics
//! let mut buffer = Buffer1in54::default();
//! let mut display = Display::new(epd.width(), epd.height(), &mut buffer.buffer);
//! //!
//! epd4in2.display_and_transfer_buffer(buffer, None); //! // 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(),
//! );
//! //!
//! // wait and look at the image //! // Display updated frame
//! epd.update_frame(&mut spi, &display.buffer()).unwrap();
//! epd.display_frame(&mut spi).expect("display frame new graphics");
//! //!
//! epd4in2.clear_frame(None); //! // Set the EPD to sleep
//! //! epd.sleep(&mut spi).expect("sleep");
//! epd4in2.sleep();
//! ``` //! ```
pub const WIDTH: u32 = 200; pub const WIDTH: u32 = 200;

4
src/epd2in9/graphics.rs

@ -1,5 +1,9 @@
use epd2in9::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; 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 struct Buffer2in9 {
pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
} }

4
src/epd4in2/graphics.rs

@ -1,5 +1,9 @@
use epd4in2::constants::{DEFAULT_BACKGROUND_COLOR, WIDTH, HEIGHT}; 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 struct Buffer4in2 {
pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
} }

Loading…
Cancel
Save