Update epd2in9b after embedded-graphics update
parent
71d539eeb7
commit
7a5472f73a
|
|
@ -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<Color> for Display2in9b {
|
||||
fn draw<T>(&mut self, item_pixels: T)
|
||||
where
|
||||
T: IntoIterator<Item = Pixel<Color>>,
|
||||
{
|
||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
||||
impl DrawTarget<BinaryColor> for Display2in9b {
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||
}
|
||||
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<SPI, CS, BUSY, DC, RST> {
|
||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
||||
|
|
@ -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)?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue