more changes to the displaydimension trait
parent
a832ab9fed
commit
a1adeb77a4
|
|
@ -8,7 +8,7 @@ extern crate eink_waveshare_rs;
|
||||||
use eink_waveshare_rs::{
|
use eink_waveshare_rs::{
|
||||||
EPD1in54,
|
EPD1in54,
|
||||||
Buffer1in54,
|
Buffer1in54,
|
||||||
graphics::{Display, DisplayRotation},
|
graphics::{Display, DisplayRotation, DisplayDimension},
|
||||||
color::Color,
|
color::Color,
|
||||||
WaveshareDisplay,
|
WaveshareDisplay,
|
||||||
};
|
};
|
||||||
|
|
@ -126,7 +126,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
println!("Test all the rotations");
|
println!("Test all the rotations");
|
||||||
let mut buffer = Buffer1in54::default();
|
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.set_rotation(DisplayRotation::Rotate0);
|
||||||
display.draw(
|
display.draw(
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use graphics::DisplayDimension;
|
||||||
pub struct DisplayEink1in54BlackWhite {
|
pub struct DisplayEink1in54BlackWhite {
|
||||||
width: u32,
|
width: u32,
|
||||||
height: 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 {
|
impl DisplayDimension for DisplayEink1in54BlackWhite {
|
||||||
fn buffer(&self) -> &[u8] {
|
fn buffer(&mut self) -> &mut [u8] {
|
||||||
&self.buffer
|
&mut self.buffer
|
||||||
}
|
}
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
self.width
|
self.width
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ impl Default for DisplayEink4in2BlackWhite {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DisplayDimension for DisplayEink4in2BlackWhite {
|
impl DisplayDimension for DisplayEink4in2BlackWhite {
|
||||||
fn buffer(&self) -> &[u8] {
|
fn buffer(&mut self) -> &mut [u8] {
|
||||||
&self.buffer
|
&mut self.buffer
|
||||||
}
|
}
|
||||||
fn width(&self) -> u32 {
|
fn width(&self) -> u32 {
|
||||||
self.width
|
self.width
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ impl Default for DisplayRotation {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DisplayDimension {
|
pub trait DisplayDimension {
|
||||||
fn buffer(&self) -> &[u8];
|
fn buffer(&mut self) -> &mut [u8];
|
||||||
fn width(&self) -> u32;
|
fn width(&self) -> u32;
|
||||||
fn height(&self) -> u32;
|
fn height(&self) -> u32;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue