Browse Source

Migrate remaining drivers

main
Reinier Balt 5 years ago
parent
commit
6a10e0cb96
  1. 4
      examples/epd2in13_v2.rs
  2. 6
      examples/epd4in2.rs
  3. 2
      examples/epd4in2_variable_size.rs
  4. 1
      src/epd1in54/graphics.rs
  5. 14
      src/epd1in54b/graphics.rs
  6. 14
      src/epd1in54c/graphics.rs
  7. 19
      src/epd2in7b/graphics.rs
  8. 1
      src/epd2in9/graphics.rs
  9. 17
      src/epd2in9_v2/graphics.rs
  10. 2
      src/epd2in9_v2/mod.rs
  11. 17
      src/epd2in9bc/graphics.rs
  12. 2
      src/epd2in9bc/mod.rs
  13. 19
      src/epd5in65f/graphics.rs
  14. 19
      src/epd7in5/graphics.rs
  15. 19
      src/epd7in5_hd/graphics.rs
  16. 30
      src/epd7in5_v2/graphics.rs
  17. 18
      src/lib.rs

4
examples/epd2in13_v2.rs

@ -89,7 +89,7 @@ fn main() -> Result<(), std::io::Error> {
display.clear_buffer(Color::White);
// draw a analog clock
let _ = Circle::new(Point::new(64, 64), 40)
let _ = Circle::with_center(Point::new(64, 64), 80)
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
.draw(&mut display);
let _ = Line::new(Point::new(64, 64), Point::new(30, 40))
@ -117,7 +117,7 @@ fn main() -> Result<(), std::io::Error> {
.background_color(Black)
.build();
let _ = Text::with_text_style("It's working-WoB!", Point::new(90, 40), style, text_style)
let _ = Text::with_text_style("It's working\nWoB!", Point::new(90, 40), style, text_style)
.draw(&mut display);
// Demonstrating how to use the partial refresh feature of the screen.

6
examples/epd4in2.rs

@ -64,7 +64,7 @@ fn main() -> Result<(), std::io::Error> {
let mut epd4in2 =
Epd4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
//println!("Test all the rotations");
println!("Test all the rotations");
let mut display = Display4in2::default();
display.set_rotation(DisplayRotation::Rotate0);
@ -85,7 +85,7 @@ fn main() -> Result<(), std::io::Error> {
.expect("display frame new graphics");
delay.delay_ms(5000u16);
//println!("Now test new graphics with default rotation and some special stuff:");
println!("Now test new graphics with default rotation and some special stuff");
display.clear_buffer(Color::White);
// draw a analog clock
@ -94,7 +94,7 @@ fn main() -> Result<(), std::io::Error> {
.stroke_width(1)
.build();
let _ = Circle::new(Point::new(64, 64), 40)
let _ = Circle::with_center(Point::new(64, 64), 80)
.into_styled(style)
.draw(&mut display);
let _ = Line::new(Point::new(64, 64), Point::new(0, 64))

2
examples/epd4in2_variable_size.rs

@ -101,7 +101,7 @@ fn main() -> Result<(), std::io::Error> {
.stroke_width(1)
.build();
let _ = Circle::new(Point::new(64, 64), 64)
let _ = Circle::with_center(Point::new(64, 64), 128)
.into_styled(style)
.draw(&mut display);
let _ = Line::new(Point::new(64, 64), Point::new(0, 64))

1
src/epd1in54/graphics.rs

@ -25,6 +25,7 @@ impl Default for Display1in54 {
impl DrawTarget for Display1in54 {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,

14
src/epd1in54b/graphics.rs

@ -1,7 +1,7 @@
use crate::epd1in54b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 1in54 EPD
///
@ -25,10 +25,18 @@ impl DrawTarget for Display1in54b {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display1in54b {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}

14
src/epd1in54c/graphics.rs

@ -1,7 +1,7 @@
use crate::epd1in54c::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 1in54c EPD
///
@ -24,10 +24,18 @@ impl DrawTarget for Display1in54c {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display1in54c {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}

19
src/epd2in7b/graphics.rs

@ -1,7 +1,7 @@
use crate::epd2in7b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 2in7B EPD
///
@ -26,10 +26,18 @@ impl DrawTarget for Display2in7b {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display2in7b {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
@ -61,7 +69,10 @@ mod tests {
use crate::epd2in7b;
use crate::epd2in7b::{HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
use embedded_graphics::{
prelude::*,
primitives::{Line, PrimitiveStyle},
};
// test buffer length
#[test]

1
src/epd2in9/graphics.rs

@ -36,6 +36,7 @@ impl DrawTarget for Display2in9 {
Ok(())
}
}
impl OriginDimensions for Display2in9 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)

17
src/epd2in9_v2/graphics.rs

@ -1,6 +1,7 @@
use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::prelude::*;
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics_core::prelude::*;
/// Display with Fullsize buffer for use with the 2in9 EPD V2
///
@ -22,13 +23,21 @@ impl Default for Display2in9 {
}
impl DrawTarget for Display2in9 {
type Color = BinaryColor
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display2in9 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}

2
src/epd2in9_v2/mod.rs

@ -8,7 +8,7 @@
//!# use embedded_hal_mock::*;
//!# fn main() -> Result<(), MockError> {
//!use embedded_graphics::{
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::{Line, PrimitiveStyle},
//!};
//!use epd_waveshare::{epd2in9_v2::*, prelude::*};
//!#

17
src/epd2in9bc/graphics.rs

@ -1,6 +1,7 @@
use crate::epd2in9bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::prelude::*;
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 2in9b/c EPD
///
@ -20,13 +21,21 @@ impl Default for Display2in9bc {
}
impl DrawTarget for Display2in9bc {
type Color = BinaryColor
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display2in9bc {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}

2
src/epd2in9bc/mod.rs

@ -6,7 +6,7 @@
//!# use embedded_hal_mock::*;
//!# fn main() -> Result<(), MockError> {
//!use embedded_graphics::{
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle,
//! pixelcolor::BinaryColor::On as Black, prelude::*, primitives::{Line, PrimitiveStyle},
//!};
//!use epd_waveshare::{epd2in9bc::*, prelude::*};
//!#

19
src/epd5in65f/graphics.rs

@ -1,7 +1,7 @@
use crate::color::OctColor;
use crate::epd5in65f::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{DisplayRotation, OctDisplay};
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 5in65f EPD
///
@ -26,10 +26,18 @@ impl DrawTarget for Display5in65f {
type Color = OctColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<OctColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display5in65f {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
@ -58,7 +66,10 @@ mod tests {
use super::*;
use crate::epd5in65f;
use crate::graphics::{DisplayRotation, OctDisplay};
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
use embedded_graphics::{
prelude::*,
primitives::{Line, PrimitiveStyle},
};
// test buffer length
#[test]

19
src/epd7in5/graphics.rs

@ -1,7 +1,7 @@
use crate::epd7in5::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 7in5 EPD
///
@ -26,10 +26,18 @@ impl DrawTarget for Display7in5 {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display7in5 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
@ -60,7 +68,10 @@ mod tests {
use crate::color::Color;
use crate::epd7in5;
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
use embedded_graphics::{
prelude::*,
primitives::{Line, PrimitiveStyle},
};
// test buffer length
#[test]

19
src/epd7in5_hd/graphics.rs

@ -1,7 +1,7 @@
use crate::epd7in5_hd::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 7in5 EPD
///
@ -26,10 +26,18 @@ impl DrawTarget for Display7in5 {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display7in5 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
@ -59,7 +67,10 @@ mod tests {
use crate::color::{Black, Color};
use crate::epd7in5_hd;
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
use embedded_graphics::{
prelude::*,
primitives::{Line, PrimitiveStyle},
};
// test buffer length
#[test]

30
src/epd7in5_v2/graphics.rs

@ -1,8 +1,7 @@
use crate::epd7in5_v2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics_core::OriginDimension;
use embedded_graphics_core::prelude::*;
/// Full size buffer for use with the 7in5 EPD
///
@ -27,8 +26,20 @@ impl DrawTarget for Display7in5 {
type Color = BinaryColor;
type Error = core::convert::Infallible;
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
self.draw_helper(WIDTH, HEIGHT, pixel)
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
where
I: IntoIterator<Item = Pixel<Self::Color>>,
{
for pixel in pixels {
self.draw_helper(WIDTH, HEIGHT, pixel)?;
}
Ok(())
}
}
impl OriginDimensions for Display7in5 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
}
@ -50,19 +61,16 @@ impl Display for Display7in5 {
}
}
impl OriginDimension for Display7in5 {
fn size(&self) -> Size {
Size::new(WIDTH, HEIGHT)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::color::{Black, Color};
use crate::epd7in5_v2;
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
use embedded_graphics::{
prelude::*,
primitives::{Line, PrimitiveStyle},
};
// test buffer length
#[test]

18
src/lib.rs

@ -74,19 +74,19 @@ pub mod color;
mod interface;
pub mod epd1in54;
//pub mod epd1in54b;
//pub mod epd1in54c;
pub mod epd1in54b;
pub mod epd1in54c;
pub mod epd2in13_v2;
pub mod epd2in13bc;
//pub mod epd2in7b;
pub mod epd2in7b;
pub mod epd2in9;
//pub mod epd2in9_v2;
//pub mod epd2in9bc;
pub mod epd2in9_v2;
pub mod epd2in9bc;
pub mod epd4in2;
//pub mod epd5in65f;
//pub mod epd7in5;
//pub mod epd7in5_hd;
//pub mod epd7in5_v2;
pub mod epd5in65f;
pub mod epd7in5;
pub mod epd7in5_hd;
pub mod epd7in5_v2;
pub(crate) mod type_a;

Loading…
Cancel
Save