Browse Source

Update example to use TriColor

main
Reinier Balt 5 years ago
parent
commit
076b3a2d07
  1. 1
      src/color.rs
  2. 30
      src/epd2in13bc/mod.rs
  3. 2
      src/lib.rs

1
src/color.rs

@ -187,6 +187,7 @@ impl TriColor {
} }
} }
#[cfg(feature = "graphics")]
impl PixelColor for TriColor { impl PixelColor for TriColor {
type Raw = (); type Raw = ();
} }

30
src/epd2in13bc/mod.rs

@ -7,10 +7,8 @@
//!```rust, no_run //!```rust, no_run
//!# use embedded_hal_mock::*; //!# use embedded_hal_mock::*;
//!# fn main() -> Result<(), MockError> { //!# fn main() -> Result<(), MockError> {
//!use embedded_graphics::{ //!use embedded_graphics::{prelude::*, primitives::Line, style::PrimitiveStyle};
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle, //!use epd_waveshare::{epd2in13bc::*, prelude::*, color::TriColor};
//!};
//!use epd_waveshare::{epd2in13bc::*, prelude::*};
//!# //!#
//!# let expectations = []; //!# let expectations = [];
//!# let mut spi = spi::Mock::new(&expectations); //!# let mut spi = spi::Mock::new(&expectations);
@ -25,28 +23,24 @@
//!let mut epd = Epd2in13bc::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/chromatic pixels
//!let mut mono_display = Display2in13bc::default(); //!let mut tricolor_display = Display2in13bc::default();
//! //!
//!// Use embedded graphics for drawing //!// Use embedded graphics for drawing a black line
//!// A black line
//!let _ = Line::new(Point::new(0, 120), Point::new(0, 200)) //!let _ = Line::new(Point::new(0, 120), Point::new(0, 200))
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1)) //! .into_styled(PrimitiveStyle::with_stroke(TriColor::Black, 1))
//! .draw(&mut mono_display); //! .draw(&mut tricolor_display);
//! //!
//!// Use a second display for red/yellow //!// We use `chromatic` but it will be shown as red/yellow
//!let mut chromatic_display = Display2in13bc::default();
//!
//!// 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))
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1)) //! .into_styled(PrimitiveStyle::with_stroke(TriColor::Chromatic, 1))
//! .draw(&mut chromatic_display); //! .draw(&mut tricolor_display);
//! //!
//!// Display updated frame //!// Display updated frame
//!epd.update_color_frame( //!epd.update_color_frame(
//! &mut spi, //! &mut spi,
//! &mono_display.buffer(), //! &tricolor_display.bw_buffer(),
//! &chromatic_display.buffer() //! &tricolor_display.chromatic_buffer()
//!)?; //!)?;
//!epd.display_frame(&mut spi, &mut delay)?; //!epd.display_frame(&mut spi, &mut delay)?;
//! //!

2
src/lib.rs

@ -99,7 +99,7 @@ pub mod prelude {
pub use crate::SPI_MODE; pub use crate::SPI_MODE;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
pub use crate::graphics::{Display, DisplayRotation, OctDisplay}; pub use crate::graphics::{Display, TriDisplay, DisplayRotation, OctDisplay};
} }
/// Computes the needed buffer length. Takes care of rounding up in case width /// Computes the needed buffer length. Takes care of rounding up in case width

Loading…
Cancel
Save