diff --git a/src/epd2in9b/graphics.rs b/src/epd2in9b/graphics.rs index cc7b761..f354e96 100644 --- a/src/epd2in9b/graphics.rs +++ b/src/epd2in9b/graphics.rs @@ -1,8 +1,11 @@ use crate::epd2in9b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH}; use crate::graphics::{Display, DisplayRotation}; -use crate::prelude::*; +use embedded_graphics::pixelcolor::BinaryColor; use embedded_graphics::prelude::*; +/// Full size buffer for use with the 2in9b EPD +/// +/// Can also be manually constructed and be used together with VarDisplay pub struct Display2in9b { buffer: [u8; NUM_DISPLAY_BITS as usize], rotation: DisplayRotation, @@ -17,12 +20,15 @@ impl Default for Display2in9b { } } -impl Drawing for Display2in9b { - fn draw(&mut self, item_pixels: T) - where - T: IntoIterator>, - { - self.draw_helper(WIDTH, HEIGHT, item_pixels); +impl DrawTarget for Display2in9b { + type Error = core::convert::Infallible; + + fn draw_pixel(&mut self, pixel: Pixel) -> Result<(), Self::Error> { + self.draw_helper(WIDTH, HEIGHT, pixel) + } + + fn size(&self) -> Size { + Size::new(WIDTH, HEIGHT) } } diff --git a/src/epd2in9b/mod.rs b/src/epd2in9b/mod.rs index a567ecc..6327530 100644 --- a/src/epd2in9b/mod.rs +++ b/src/epd2in9b/mod.rs @@ -10,11 +10,15 @@ use crate::traits::{ InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay, }; +/// Width of epd2in9b in pixels pub const WIDTH: u32 = 128; +/// Height of epd2in9b in pixels pub const HEIGHT: u32 = 296; -pub const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; +/// Default background color (white) of epd2in9b display pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; +const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8; + const IS_BUSY_LOW: bool = true; const VCOM_DATA_INTERVAL: u8 = 0x07; const WHITE_BORDER: u8 = 0x70; @@ -32,7 +36,6 @@ mod graphics; #[cfg(feature = "graphics")] pub use self::graphics::Display2in9b; - /// EPD2in9b driver pub struct EPD2in9b { interface: DisplayInterface, @@ -211,6 +214,12 @@ where Ok(()) } + fn update_and_display_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { + self.update_frame(spi, buffer)?; + self.display_frame(spi)?; + Ok(()) + } + fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> { self.send_resolution(spi)?;