Browse Source

Fix error where pixel outside display lead to early return instead of just skipping that pixel

embedded-hal-1.0
Chris 7 years ago
parent
commit
824735fb64
  1. 12
      src/graphics.rs

12
src/graphics.rs

@ -20,22 +20,22 @@ impl Default for DisplayRotation {
} }
} }
pub struct Display<'a> { pub struct Display {
width: u32, width: u32,
height: u32, height: u32,
rotation: DisplayRotation, rotation: DisplayRotation,
buffer: &'a mut [u8], //buffer: Box<u8>//[u8; 15000] buffer: [u8; 15000], //buffer: Box<u8>//[u8; 15000]
} }
impl<'a> Display<'a> { impl Display {
pub fn new(width: u32, height: u32, buffer: &'a mut [u8]) -> Display<'a> { pub fn new(width: u32, height: u32, buffer: & mut [u8]) -> Display {
let len = buffer.len() as u32; let len = buffer.len() as u32;
assert!(width / 8 * height >= len); assert!(width / 8 * height >= len);
Display { Display {
width, width,
height, height,
rotation: DisplayRotation::default(), rotation: DisplayRotation::default(),
buffer, buffer: [0u8; 15000],
} }
} }
@ -59,7 +59,7 @@ impl<'a> Display<'a> {
} }
impl<'a> Drawing<Color> for Display<'a> { impl Drawing<Color> for Display {
fn draw<T>(&mut self, item_pixels: T) fn draw<T>(&mut self, item_pixels: T)
where where
T: Iterator<Item = Pixel<Color>> T: Iterator<Item = Pixel<Color>>

Loading…
Cancel
Save