Browse Source

more changes to the displaydimension trait

embedded-hal-1.0
Chris 7 years ago
parent
commit
a1adeb77a4
  1. 4
      examples/embedded_linux_epd1in54/src/main.rs
  2. 6
      src/epd1in54/graphics.rs
  3. 4
      src/epd4in2/graphics.rs
  4. 2
      src/graphics.rs

4
examples/embedded_linux_epd1in54/src/main.rs

@ -8,7 +8,7 @@ extern crate eink_waveshare_rs;
use eink_waveshare_rs::{
EPD1in54,
Buffer1in54,
graphics::{Display, DisplayRotation},
graphics::{Display, DisplayRotation, DisplayDimension},
color::Color,
WaveshareDisplay,
};
@ -126,7 +126,7 @@ fn run() -> Result<(), std::io::Error> {
println!("Test all the rotations");
let mut buffer = Buffer1in54::default();
let mut display = Display::new(buffer.width, buffer.height, &mut buffer.buffer);
let mut display = Display::new(buffer.width(), buffer.height(), &mut buffer.buffer);
display.set_rotation(DisplayRotation::Rotate0);
display.draw(
Font6x8::render_str("Rotate 0!")

6
src/epd1in54/graphics.rs

@ -4,7 +4,7 @@ use graphics::DisplayDimension;
pub struct DisplayEink1in54BlackWhite {
width: u32,
height: u32,
buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
pub buffer: [u8; WIDTH as usize * HEIGHT as usize / 8],
}
@ -23,8 +23,8 @@ impl Default for DisplayEink1in54BlackWhite {
}
impl DisplayDimension for DisplayEink1in54BlackWhite {
fn buffer(&self) -> &[u8] {
&self.buffer
fn buffer(&mut self) -> &mut [u8] {
&mut self.buffer
}
fn width(&self) -> u32 {
self.width

4
src/epd4in2/graphics.rs

@ -21,8 +21,8 @@ impl Default for DisplayEink4in2BlackWhite {
}
impl DisplayDimension for DisplayEink4in2BlackWhite {
fn buffer(&self) -> &[u8] {
&self.buffer
fn buffer(&mut self) -> &mut [u8] {
&mut self.buffer
}
fn width(&self) -> u32 {
self.width

2
src/graphics.rs

@ -21,7 +21,7 @@ impl Default for DisplayRotation {
}
pub trait DisplayDimension {
fn buffer(&self) -> &[u8];
fn buffer(&mut self) -> &mut [u8];
fn width(&self) -> u32;
fn height(&self) -> u32;
}

Loading…
Cancel
Save