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::epd2in9b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
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 {
|
pub struct Display2in9b {
|
||||||
buffer: [u8; NUM_DISPLAY_BITS as usize],
|
buffer: [u8; NUM_DISPLAY_BITS as usize],
|
||||||
rotation: DisplayRotation,
|
rotation: DisplayRotation,
|
||||||
|
|
@ -17,12 +20,15 @@ impl Default for Display2in9b {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display2in9b {
|
impl DrawTarget<BinaryColor> for Display2in9b {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,15 @@ use crate::traits::{
|
||||||
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay,
|
InternalWiAdditions, RefreshLUT, WaveshareDisplay, WaveshareThreeColorDisplay,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Width of epd2in9b in pixels
|
||||||
pub const WIDTH: u32 = 128;
|
pub const WIDTH: u32 = 128;
|
||||||
|
/// Height of epd2in9b in pixels
|
||||||
pub const HEIGHT: u32 = 296;
|
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;
|
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
|
||||||
|
|
||||||
|
const NUM_DISPLAY_BITS: u32 = WIDTH * HEIGHT / 8;
|
||||||
|
|
||||||
const IS_BUSY_LOW: bool = true;
|
const IS_BUSY_LOW: bool = true;
|
||||||
const VCOM_DATA_INTERVAL: u8 = 0x07;
|
const VCOM_DATA_INTERVAL: u8 = 0x07;
|
||||||
const WHITE_BORDER: u8 = 0x70;
|
const WHITE_BORDER: u8 = 0x70;
|
||||||
|
|
@ -32,7 +36,6 @@ mod graphics;
|
||||||
#[cfg(feature = "graphics")]
|
#[cfg(feature = "graphics")]
|
||||||
pub use self::graphics::Display2in9b;
|
pub use self::graphics::Display2in9b;
|
||||||
|
|
||||||
|
|
||||||
/// EPD2in9b driver
|
/// EPD2in9b driver
|
||||||
pub struct EPD2in9b<SPI, CS, BUSY, DC, RST> {
|
pub struct EPD2in9b<SPI, CS, BUSY, DC, RST> {
|
||||||
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
interface: DisplayInterface<SPI, CS, BUSY, DC, RST>,
|
||||||
|
|
@ -211,6 +214,12 @@ where
|
||||||
Ok(())
|
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> {
|
fn clear_frame(&mut self, spi: &mut SPI) -> Result<(), SPI::Error> {
|
||||||
self.send_resolution(spi)?;
|
self.send_resolution(spi)?;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue