more changes to the displaydimension trait

digi-v2-tests
Chris 5 years ago
parent a832ab9fed
commit a1adeb77a4

@ -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!")

@ -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

@ -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

@ -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