You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
use crate::epd1in54b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; |
|
use crate::graphics::{Display, DisplayRotation}; |
|
use embedded_graphics::pixelcolor::BinaryColor; |
|
use embedded_graphics_core::prelude::*; |
|
|
|
/// Full size buffer for use with the 1in54 EPD |
|
/// |
|
/// Can also be manually constructed and be used together with VarDisplay |
|
pub struct Display1in54b { |
|
buffer: [u8; WIDTH as usize * HEIGHT as usize / 8], |
|
rotation: DisplayRotation, |
|
} |
|
|
|
impl Default for Display1in54b { |
|
fn default() -> Self { |
|
Display1in54b { |
|
buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); |
|
WIDTH as usize * HEIGHT as usize / 8], |
|
rotation: DisplayRotation::default(), |
|
} |
|
} |
|
} |
|
|
|
impl DrawTarget for Display1in54b { |
|
type Color = BinaryColor; |
|
type Error = core::convert::Infallible; |
|
|
|
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error> |
|
where |
|
I: IntoIterator<Item = Pixel<Self::Color>>, |
|
{ |
|
for pixel in pixels { |
|
self.draw_helper(WIDTH, HEIGHT, pixel)?; |
|
} |
|
Ok(()) |
|
} |
|
} |
|
|
|
impl OriginDimensions for Display1in54b { |
|
fn size(&self) -> Size { |
|
Size::new(WIDTH, HEIGHT) |
|
} |
|
} |
|
|
|
impl Display for Display1in54b { |
|
fn buffer(&self) -> &[u8] { |
|
&self.buffer |
|
} |
|
|
|
fn get_mut_buffer(&mut self) -> &mut [u8] { |
|
&mut self.buffer |
|
} |
|
|
|
fn set_rotation(&mut self, rotation: DisplayRotation) { |
|
self.rotation = rotation; |
|
} |
|
|
|
fn rotation(&self) -> DisplayRotation { |
|
self.rotation |
|
} |
|
}
|
|
|