Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dkm committed Sep 22, 2020
1 parent 4ffc70a commit 4863836
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/epd2in13_v2/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ impl DriverOutput {
}
}


/// These are not directly documented, but the bitfield is easily reversed from
/// documentation and sample code
/// [7|6|5|4|3|2|1|0]
Expand Down
6 changes: 3 additions & 3 deletions src/epd2in13_v2/graphics.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::epd2in13_v2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use crate::graphics::{buffer_len, Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;

Expand All @@ -8,15 +8,15 @@ use embedded_graphics::prelude::*;
/// Can also be manually constructed:
/// `buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); WIDTH / 8 * HEIGHT]`
pub struct Display2in13 {
buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
buffer: [u8; buffer_len(WIDTH as usize, HEIGHT as usize)],
rotation: DisplayRotation,
}

impl Default for Display2in13 {
fn default() -> Self {
Display2in13 {
buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value();
WIDTH as usize * HEIGHT as usize / 8],
buffer_len(WIDTH as usize, HEIGHT as usize)],
rotation: DisplayRotation::default(),
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/epd2in13_v2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ mod graphics;
#[cfg(feature = "graphics")]
pub use self::graphics::Display2in13;

/// Width of the display. Beware the visible part is smaller (122)
pub const WIDTH: u32 = 128;
/// Width of the display.
pub const WIDTH: u32 = 122;

/// Height of the display
pub const HEIGHT: u32 = 250;
Expand Down Expand Up @@ -207,7 +207,7 @@ where
}

fn update_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> {
assert!(buffer.len() == (WIDTH * HEIGHT / 8) as usize);
assert!(buffer.len() == (WIDTH + 7) as usize / 8 * HEIGHT as usize);
self.set_ram_area(spi, 0, 0, WIDTH - 1, HEIGHT - 1)?;
self.set_ram_address_counters(spi, 0, 0)?;

Expand Down Expand Up @@ -555,7 +555,7 @@ mod tests {

#[test]
fn epd_size() {
assert_eq!(WIDTH, 128);
assert_eq!(WIDTH, 122);
assert_eq!(HEIGHT, 250);
assert_eq!(DEFAULT_BACKGROUND_COLOR, Color::White);
}
Expand Down

0 comments on commit 4863836

Please sign in to comment.