Browse Source

bring copy into 2in13bc namespace

main
Reinier Balt 5 years ago
parent
commit
9dedf76c57
  1. 2
      src/epd2in13bc/command.rs
  2. 12
      src/epd2in13bc/graphics.rs
  3. 30
      src/epd2in13bc/mod.rs
  4. 1
      src/lib.rs

2
src/epd2in13bc/command.rs

@ -1,4 +1,4 @@
//! SPI Commands for the Waveshare 2.9" (B/C) E-Ink Display //! SPI Commands for the Waveshare 2.13" (B/C) E-Ink Display
use crate::traits; use crate::traits;
#[allow(dead_code)] #[allow(dead_code)]

12
src/epd2in13bc/graphics.rs

@ -1,4 +1,4 @@
use crate::epd2in9bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH}; use crate::epd2in13bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
use crate::graphics::{Display, DisplayRotation}; use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor; use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*; use embedded_graphics::prelude::*;
@ -6,21 +6,21 @@ use embedded_graphics::prelude::*;
/// Full size buffer for use with the 2in9b/c EPD /// Full size buffer for use with the 2in9b/c EPD
/// ///
/// Can also be manually constructed and be used together with VarDisplay /// Can also be manually constructed and be used together with VarDisplay
pub struct Display2in9bc { pub struct Display2in13bc {
buffer: [u8; NUM_DISPLAY_BITS as usize], buffer: [u8; NUM_DISPLAY_BITS as usize],
rotation: DisplayRotation, rotation: DisplayRotation,
} }
impl Default for Display2in9bc { impl Default for Display2in13bc {
fn default() -> Self { fn default() -> Self {
Display2in9bc { Display2in13bc {
buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); NUM_DISPLAY_BITS as usize], buffer: [DEFAULT_BACKGROUND_COLOR.get_byte_value(); NUM_DISPLAY_BITS as usize],
rotation: DisplayRotation::default(), rotation: DisplayRotation::default(),
} }
} }
} }
impl DrawTarget<BinaryColor> for Display2in9bc { impl DrawTarget<BinaryColor> for Display2in13bc {
type Error = core::convert::Infallible; type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> { fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
@ -32,7 +32,7 @@ impl DrawTarget<BinaryColor> for Display2in9bc {
} }
} }
impl Display for Display2in9bc { impl Display for Display2in13bc {
fn buffer(&self) -> &[u8] { fn buffer(&self) -> &[u8] {
&self.buffer &self.buffer
} }

30
src/epd2in13bc/mod.rs

@ -1,6 +1,6 @@
//! A simple Driver for the Waveshare 2.9" (B/C) E-Ink Display via SPI //! A simple Driver for the Waveshare 2.13" (B/C) E-Ink Display via SPI
//! //!
//! # Example for the 2.9" E-Ink Display //! # Example for the 2.13" E-Ink Display
//! //!
//!```rust, no_run //!```rust, no_run
//!# use embedded_hal_mock::*; //!# use embedded_hal_mock::*;
@ -8,7 +8,7 @@
//!use embedded_graphics::{ //!use embedded_graphics::{
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle, //! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
//!}; //!};
//!use epd_waveshare::{epd2in9bc::*, prelude::*}; //!use epd_waveshare::{epd2in13bc::*, prelude::*};
//!# //!#
//!# let expectations = []; //!# let expectations = [];
//!# let mut spi = spi::Mock::new(&expectations); //!# let mut spi = spi::Mock::new(&expectations);
@ -20,11 +20,11 @@
//!# let mut delay = delay::MockNoop::new(); //!# let mut delay = delay::MockNoop::new();
//! //!
//!// Setup EPD //!// Setup EPD
//!let mut epd = Epd2in9bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; //!let mut epd = Epd2in13bc::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?;
//! //!
//!// Use display graphics from embedded-graphics //!// Use display graphics from embedded-graphics
//!// This display is for the black/white pixels //!// This display is for the black/white pixels
//!let mut mono_display = Display2in9bc::default(); //!let mut mono_display = Display2in13bc::default();
//! //!
//!// Use embedded graphics for drawing //!// Use embedded graphics for drawing
//!// A black line //!// A black line
@ -33,7 +33,7 @@
//! .draw(&mut mono_display); //! .draw(&mut mono_display);
//! //!
//!// Use a second display for red/yellow //!// Use a second display for red/yellow
//!let mut chromatic_display = Display2in9bc::default(); //!let mut chromatic_display = Display2in13bc::default();
//! //!
//!// We use `Black` but it will be shown as red/yellow //!// We use `Black` but it will be shown as red/yellow
//!let _ = Line::new(Point::new(15, 120), Point::new(15, 200)) //!let _ = Line::new(Point::new(15, 120), Point::new(15, 200))
@ -63,9 +63,9 @@ use crate::traits::{
InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay, InternalWiAdditions, RefreshLut, WaveshareDisplay, WaveshareThreeColorDisplay,
}; };
/// Width of epd2in9bc in pixels /// Width of epd2in13bc in pixels
pub const WIDTH: u32 = 128; pub const WIDTH: u32 = 128;
/// Height of epd2in9bc in pixels /// Height of epd2in13bc in pixels
pub const HEIGHT: u32 = 296; pub const HEIGHT: u32 = 296;
/// Default background color (white) of epd2in9bc display /// Default background color (white) of epd2in9bc display
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White; pub const DEFAULT_BACKGROUND_COLOR: Color = Color::White;
@ -87,16 +87,16 @@ use self::command::Command;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
mod graphics; mod graphics;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
pub use self::graphics::Display2in9bc; pub use self::graphics::Display2in13bc;
/// Epd2in9bc driver /// Epd2in9bc driver
pub struct Epd2in9bc<SPI, CS, BUSY, DC, RST, DELAY> { pub struct Epd2in13bc<SPI, CS, BUSY, DC, RST, DELAY> {
interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>, interface: DisplayInterface<SPI, CS, BUSY, DC, RST, DELAY>,
color: Color, color: Color,
} }
impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY> impl<SPI, CS, BUSY, DC, RST, DELAY> InternalWiAdditions<SPI, CS, BUSY, DC, RST, DELAY>
for Epd2in9bc<SPI, CS, BUSY, DC, RST, DELAY> for Epd2in13bc<SPI, CS, BUSY, DC, RST, DELAY>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -140,7 +140,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY> impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareThreeColorDisplay<SPI, CS, BUSY, DC, RST, DELAY>
for Epd2in9bc<SPI, CS, BUSY, DC, RST, DELAY> for Epd2in13bc<SPI, CS, BUSY, DC, RST, DELAY>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -185,7 +185,7 @@ where
} }
impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY> impl<SPI, CS, BUSY, DC, RST, DELAY> WaveshareDisplay<SPI, CS, BUSY, DC, RST, DELAY>
for Epd2in9bc<SPI, CS, BUSY, DC, RST, DELAY> for Epd2in13bc<SPI, CS, BUSY, DC, RST, DELAY>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,
@ -206,7 +206,7 @@ where
let interface = DisplayInterface::new(cs, busy, dc, rst); let interface = DisplayInterface::new(cs, busy, dc, rst);
let color = DEFAULT_BACKGROUND_COLOR; let color = DEFAULT_BACKGROUND_COLOR;
let mut epd = Epd2in9bc { interface, color }; let mut epd = Epd2in13bc { interface, color };
epd.init(spi, delay)?; epd.init(spi, delay)?;
@ -332,7 +332,7 @@ where
} }
} }
impl<SPI, CS, BUSY, DC, RST, DELAY> Epd2in9bc<SPI, CS, BUSY, DC, RST, DELAY> impl<SPI, CS, BUSY, DC, RST, DELAY> Epd2in13bc<SPI, CS, BUSY, DC, RST, DELAY>
where where
SPI: Write<u8>, SPI: Write<u8>,
CS: OutputPin, CS: OutputPin,

1
src/lib.rs

@ -76,6 +76,7 @@ pub mod epd1in54;
pub mod epd1in54b; pub mod epd1in54b;
pub mod epd1in54c; pub mod epd1in54c;
pub mod epd2in13_v2; pub mod epd2in13_v2;
pub mod epd2in13bc;
pub mod epd2in7b; pub mod epd2in7b;
pub mod epd2in9; pub mod epd2in9;
pub mod epd2in9_v2; pub mod epd2in9_v2;

Loading…
Cancel
Save