mirror of
https://github.com/Anshorei/epd-waveshare.git
synced 2026-10-03 22:06:43 +00:00
migrate minimum set of drivers to make tests pass
This commit is contained in:
+41
-10
@@ -1,7 +1,7 @@
|
||||
use crate::epd1in54::{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
|
||||
///
|
||||
@@ -22,13 +22,21 @@ impl Default for Display1in54 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display1in54 {
|
||||
impl DrawTarget for Display1in54 {
|
||||
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 Display1in54 {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
@@ -57,7 +65,10 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::color::{Black, Color};
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||
use embedded_graphics::{
|
||||
prelude::*,
|
||||
primitives::{Line, PrimitiveStyleBuilder},
|
||||
};
|
||||
|
||||
// test buffer length
|
||||
#[test]
|
||||
@@ -79,7 +90,12 @@ mod tests {
|
||||
fn graphics_rotation_0() {
|
||||
let mut display = Display1in54::default();
|
||||
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -96,7 +112,12 @@ mod tests {
|
||||
let mut display = Display1in54::default();
|
||||
display.set_rotation(DisplayRotation::Rotate90);
|
||||
let _ = Line::new(Point::new(0, 192), Point::new(0, 199))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -113,7 +134,12 @@ mod tests {
|
||||
let mut display = Display1in54::default();
|
||||
display.set_rotation(DisplayRotation::Rotate180);
|
||||
let _ = Line::new(Point::new(192, 199), Point::new(199, 199))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -133,7 +159,12 @@ mod tests {
|
||||
let mut display = Display1in54::default();
|
||||
display.set_rotation(DisplayRotation::Rotate270);
|
||||
let _ = Line::new(Point::new(199, 0), Point::new(199, 7))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
|
||||
+6
-2
@@ -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, PrimitiveStyleBuilder},
|
||||
//!};
|
||||
//!use epd_waveshare::{epd1in54::*, prelude::*};
|
||||
//!#
|
||||
@@ -26,8 +26,12 @@
|
||||
//!let mut display = Display1in54::default();
|
||||
//!
|
||||
//!// Use embedded graphics for drawing a line
|
||||
//!let style = PrimitiveStyleBuilder::new()
|
||||
//! .stroke_color(Black)
|
||||
//! .stroke_width(1)
|
||||
//! .build();
|
||||
//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
//! .into_styled(style)
|
||||
//! .draw(&mut display);
|
||||
//!
|
||||
//!// Display updated frame
|
||||
|
||||
@@ -21,7 +21,8 @@ impl Default for Display1in54b {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display1in54b {
|
||||
impl DrawTarget for Display1in54b {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -20,7 +20,8 @@ impl Default for Display1in54c {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display1in54c {
|
||||
impl DrawTarget for Display1in54c {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::buffer_len;
|
||||
use crate::epd2in13_v2::{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 2in13 v2 EPD
|
||||
///
|
||||
@@ -23,13 +23,22 @@ impl Default for Display2in13 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display2in13 {
|
||||
impl DrawTarget for Display2in13 {
|
||||
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 Display2in13 {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
@@ -59,7 +68,10 @@ mod tests {
|
||||
use crate::color::{Black, Color};
|
||||
use crate::epd2in13_v2;
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||
use embedded_graphics::{
|
||||
prelude::*,
|
||||
primitives::{Line, PrimitiveStyleBuilder},
|
||||
};
|
||||
|
||||
// test buffer length
|
||||
#[test]
|
||||
@@ -82,7 +94,12 @@ mod tests {
|
||||
let mut display = Display2in13::default();
|
||||
|
||||
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -103,7 +120,12 @@ mod tests {
|
||||
Point::new(0, (WIDTH - 8) as i32),
|
||||
Point::new(0, (WIDTH - 1) as i32),
|
||||
)
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -124,7 +146,12 @@ mod tests {
|
||||
Point::new((WIDTH - 8) as i32, (HEIGHT - 1) as i32),
|
||||
Point::new((WIDTH - 1) as i32, (HEIGHT - 1) as i32),
|
||||
)
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -145,7 +172,12 @@ mod tests {
|
||||
Point::new((HEIGHT - 1) as i32, 0),
|
||||
Point::new((HEIGHT - 1) as i32, 7),
|
||||
)
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::color::TriColor;
|
||||
use crate::epd2in13bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
|
||||
use crate::graphics::{DisplayRotation, TriDisplay};
|
||||
use embedded_graphics::prelude::*;
|
||||
use crate::graphics::{TriDisplay, DisplayRotation};
|
||||
use embedded_graphics_core::prelude::*;
|
||||
|
||||
/// Full size buffer for use with the 2.13" b/c EPD
|
||||
///
|
||||
@@ -23,13 +23,21 @@ impl Default for Display2in13bc {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<TriColor> for Display2in13bc {
|
||||
impl DrawTarget for Display2in13bc {
|
||||
type Color = TriColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<TriColor>) -> Result<(), Self::Error> {
|
||||
self.draw_helper_tri(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_tri(WIDTH, HEIGHT, pixel)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl OriginDimensions for Display2in13bc {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
//!```rust, no_run
|
||||
//!# use embedded_hal_mock::*;
|
||||
//!# fn main() -> Result<(), MockError> {
|
||||
//!use embedded_graphics::{prelude::*, primitives::Line, style::PrimitiveStyle};
|
||||
//!use epd_waveshare::{epd2in13bc::*, prelude::*, color::TriColor};
|
||||
//!use embedded_graphics::{prelude::*, primitives::{Line, PrimitiveStyle, PrimitiveStyleBuilder}};
|
||||
//!use epd_waveshare::{epd2in13bc::*, prelude::*};
|
||||
//!#
|
||||
//!# let expectations = [];
|
||||
//!# let mut spi = spi::Mock::new(&expectations);
|
||||
|
||||
@@ -22,7 +22,8 @@ impl Default for Display2in7b {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display2in7b {
|
||||
impl DrawTarget for Display2in7b {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
+13
-5
@@ -1,7 +1,7 @@
|
||||
use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::pixelcolor::BinaryColor;
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics_core::prelude::*;
|
||||
|
||||
/// Display with Fullsize buffer for use with the 2in9 EPD
|
||||
///
|
||||
@@ -22,13 +22,21 @@ impl Default for Display2in9 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display2in9 {
|
||||
impl DrawTarget for Display2in9 {
|
||||
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)
|
||||
}
|
||||
|
||||
+6
-2
@@ -7,7 +7,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, PrimitiveStyleBuilder},
|
||||
//!};
|
||||
//!use epd_waveshare::{epd2in9::*, prelude::*};
|
||||
//!#
|
||||
@@ -27,8 +27,12 @@
|
||||
//!let mut display = Display2in9::default();
|
||||
//!
|
||||
//!// Use embedded graphics for drawing a line
|
||||
//!let style = PrimitiveStyleBuilder::new()
|
||||
//! .stroke_color(Black)
|
||||
//! .stroke_width(1)
|
||||
//! .build();
|
||||
//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
//! .into_styled(style)
|
||||
//! .draw(&mut display);
|
||||
//!
|
||||
//! // Display updated frame
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::pixelcolor::BinaryColor;
|
||||
use embedded_graphics::prelude::*;
|
||||
|
||||
/// Display with Fullsize buffer for use with the 2in9 EPD V2
|
||||
@@ -22,7 +21,8 @@ impl Default for Display2in9 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display2in9 {
|
||||
impl DrawTarget for Display2in9 {
|
||||
type Color = BinaryColor
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use crate::epd2in9bc::{DEFAULT_BACKGROUND_COLOR, HEIGHT, NUM_DISPLAY_BITS, WIDTH};
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::pixelcolor::BinaryColor;
|
||||
use embedded_graphics::prelude::*;
|
||||
|
||||
/// Full size buffer for use with the 2in9b/c EPD
|
||||
@@ -20,7 +19,8 @@ impl Default for Display2in9bc {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display2in9bc {
|
||||
impl DrawTarget for Display2in9bc {
|
||||
type Color = BinaryColor
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
+41
-10
@@ -1,7 +1,7 @@
|
||||
use crate::epd4in2::{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 4in2 EPD
|
||||
///
|
||||
@@ -22,13 +22,21 @@ impl Default for Display4in2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display4in2 {
|
||||
impl DrawTarget for Display4in2 {
|
||||
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 Display4in2 {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
@@ -59,7 +67,10 @@ mod tests {
|
||||
use crate::color::Color;
|
||||
use crate::epd4in2;
|
||||
use crate::graphics::{Display, DisplayRotation};
|
||||
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||
use embedded_graphics::{
|
||||
prelude::*,
|
||||
primitives::{Line, PrimitiveStyleBuilder},
|
||||
};
|
||||
|
||||
// test buffer length
|
||||
#[test]
|
||||
@@ -81,7 +92,12 @@ mod tests {
|
||||
fn graphics_rotation_0() {
|
||||
let mut display = Display4in2::default();
|
||||
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -98,7 +114,12 @@ mod tests {
|
||||
let mut display = Display4in2::default();
|
||||
display.set_rotation(DisplayRotation::Rotate90);
|
||||
let _ = Line::new(Point::new(0, 392), Point::new(0, 399))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -116,7 +137,12 @@ mod tests {
|
||||
display.set_rotation(DisplayRotation::Rotate180);
|
||||
|
||||
let _ = Line::new(Point::new(392, 299), Point::new(399, 299))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -136,7 +162,12 @@ mod tests {
|
||||
let mut display = Display4in2::default();
|
||||
display.set_rotation(DisplayRotation::Rotate270);
|
||||
let _ = Line::new(Point::new(299, 0), Point::new(299, 7))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
|
||||
+6
-2
@@ -11,7 +11,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, PrimitiveStyleBuilder},
|
||||
//!};
|
||||
//!use epd_waveshare::{epd4in2::*, prelude::*};
|
||||
//!#
|
||||
@@ -31,8 +31,12 @@
|
||||
//!let mut display = Display4in2::default();
|
||||
//!
|
||||
//!// Use embedded graphics for drawing a line
|
||||
//!let style = PrimitiveStyleBuilder::new()
|
||||
//! .stroke_color(Black)
|
||||
//! .stroke_width(1)
|
||||
//! .build();
|
||||
//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
//! .into_styled(style)
|
||||
//! .draw(&mut display);
|
||||
//!
|
||||
//! // Display updated frame
|
||||
|
||||
@@ -22,7 +22,8 @@ impl Default for Display5in65f {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<OctColor> for Display5in65f {
|
||||
impl DrawTarget for Display5in65f {
|
||||
type Color = OctColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<OctColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -22,7 +22,8 @@ impl Default for Display7in5 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display7in5 {
|
||||
impl DrawTarget for Display7in5 {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -22,7 +22,8 @@ impl Default for Display7in5 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display7in5 {
|
||||
impl DrawTarget for Display7in5 {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
|
||||
@@ -2,6 +2,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;
|
||||
|
||||
/// Full size buffer for use with the 7in5 EPD
|
||||
///
|
||||
@@ -22,16 +23,17 @@ impl Default for Display7in5 {
|
||||
}
|
||||
}
|
||||
|
||||
impl DrawTarget<BinaryColor> for Display7in5 {
|
||||
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 size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
// fn size(&self) -> Size {
|
||||
// Size::new(WIDTH, HEIGHT)
|
||||
// }
|
||||
}
|
||||
|
||||
impl Display for Display7in5 {
|
||||
@@ -52,6 +54,12 @@ impl Display for Display7in5 {
|
||||
}
|
||||
}
|
||||
|
||||
impl OriginDimension for Display7in5 {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(WIDTH, HEIGHT)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
+40
-13
@@ -2,7 +2,8 @@
|
||||
|
||||
use crate::buffer_len;
|
||||
use crate::color::{Color, OctColor, TriColor};
|
||||
use embedded_graphics::{pixelcolor::BinaryColor, prelude::*};
|
||||
use embedded_graphics::pixelcolor::BinaryColor;
|
||||
use embedded_graphics_core::prelude::*;
|
||||
|
||||
/// Displayrotation
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -29,7 +30,7 @@ impl Default for DisplayRotation {
|
||||
/// - Drawing (With the help of DrawTarget/Embedded Graphics)
|
||||
/// - Rotations
|
||||
/// - Clearing
|
||||
pub trait Display: DrawTarget<BinaryColor> {
|
||||
pub trait Display: DrawTarget<Color = BinaryColor> {
|
||||
/// Clears the buffer of the display with the chosen background color
|
||||
fn clear_buffer(&mut self, background_color: Color) {
|
||||
for elem in self.get_mut_buffer().iter_mut() {
|
||||
@@ -91,7 +92,7 @@ pub trait Display: DrawTarget<BinaryColor> {
|
||||
/// - Drawing (With the help of DrawTarget/Embedded Graphics)
|
||||
/// - Rotations
|
||||
/// - Clearing
|
||||
pub trait TriDisplay: DrawTarget<TriColor> {
|
||||
pub trait TriDisplay: DrawTarget<Color = TriColor> {
|
||||
/// Clears the buffer of the display with the chosen background color
|
||||
fn clear_buffer(&mut self, background_color: TriColor) {
|
||||
for elem in self.get_mut_buffer().iter_mut() {
|
||||
@@ -174,7 +175,7 @@ pub trait TriDisplay: DrawTarget<TriColor> {
|
||||
/// - Drawing (With the help of DrawTarget/Embedded Graphics)
|
||||
/// - Rotations
|
||||
/// - Clearing
|
||||
pub trait OctDisplay: DrawTarget<OctColor> {
|
||||
pub trait OctDisplay: DrawTarget<Color = OctColor> {
|
||||
/// Clears the buffer of the display with the chosen background color
|
||||
fn clear_buffer(&mut self, background_color: OctColor) {
|
||||
for elem in self.get_mut_buffer().iter_mut() {
|
||||
@@ -240,8 +241,7 @@ pub trait OctDisplay: DrawTarget<OctColor> {
|
||||
/// # use epd_waveshare::graphics::VarDisplay;
|
||||
/// # use epd_waveshare::color::Black;
|
||||
/// # use embedded_graphics::prelude::*;
|
||||
/// # use embedded_graphics::primitives::{Circle, Line};
|
||||
/// # use embedded_graphics::style::PrimitiveStyle;
|
||||
/// # use embedded_graphics::primitives::{Circle, Line, PrimitiveStyleBuilder};
|
||||
/// let width = 128;
|
||||
/// let height = 296;
|
||||
///
|
||||
@@ -250,8 +250,13 @@ pub trait OctDisplay: DrawTarget<OctColor> {
|
||||
///
|
||||
/// display.set_rotation(DisplayRotation::Rotate90);
|
||||
///
|
||||
///let style = PrimitiveStyleBuilder::new()
|
||||
/// .stroke_color(Black)
|
||||
/// .stroke_width(1)
|
||||
/// .build();
|
||||
///
|
||||
/// let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
/// .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
/// .into_styled(style)
|
||||
/// .draw(&mut display);
|
||||
/// ```
|
||||
pub struct VarDisplay<'a> {
|
||||
@@ -277,13 +282,22 @@ impl<'a> VarDisplay<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DrawTarget<BinaryColor> for VarDisplay<'a> {
|
||||
impl<'a> DrawTarget for VarDisplay<'a> {
|
||||
type Color = BinaryColor;
|
||||
type Error = core::convert::Infallible;
|
||||
|
||||
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||
self.draw_helper(self.width, self.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(self.width, self.height, pixel)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> OriginDimensions for VarDisplay<'a> {
|
||||
fn size(&self) -> Size {
|
||||
Size::new(self.width, self.height)
|
||||
}
|
||||
@@ -379,7 +393,10 @@ mod tests {
|
||||
use super::{buffer_len, find_position, outside_display, Display, DisplayRotation, VarDisplay};
|
||||
use crate::color::Black;
|
||||
use crate::color::Color;
|
||||
use embedded_graphics::{prelude::*, primitives::Line, style::PrimitiveStyle};
|
||||
use embedded_graphics::{
|
||||
prelude::*,
|
||||
primitives::{Line, PrimitiveStyleBuilder},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn buffer_clear() {
|
||||
@@ -436,7 +453,12 @@ mod tests {
|
||||
let mut display = VarDisplay::new(width, height, &mut buffer);
|
||||
|
||||
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
@@ -460,7 +482,12 @@ mod tests {
|
||||
display.set_rotation(DisplayRotation::Rotate90);
|
||||
|
||||
let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
.into_styled(
|
||||
PrimitiveStyleBuilder::new()
|
||||
.stroke_color(Black)
|
||||
.stroke_width(1)
|
||||
.build(),
|
||||
)
|
||||
.draw(&mut display);
|
||||
|
||||
let buffer = display.buffer();
|
||||
|
||||
+17
-11
@@ -14,7 +14,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, PrimitiveStyleBuilder},
|
||||
//!};
|
||||
//!use epd_waveshare::{epd1in54::*, prelude::*};
|
||||
//!#
|
||||
@@ -34,8 +34,14 @@
|
||||
//!let mut display = Display1in54::default();
|
||||
//!
|
||||
//!// Use embedded graphics for drawing a line
|
||||
//!
|
||||
//!let style = PrimitiveStyleBuilder::new()
|
||||
//! .stroke_color(Black)
|
||||
//! .stroke_width(1)
|
||||
//! .build();
|
||||
//!
|
||||
//!let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
//! .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
//! .into_styled(style)
|
||||
//! .draw(&mut display);
|
||||
//!
|
||||
//! // Display updated frame
|
||||
@@ -73,19 +79,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;
|
||||
|
||||
|
||||
+9
-3
@@ -92,7 +92,7 @@ where
|
||||
///# 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, PrimitiveStyleBuilder},
|
||||
///};
|
||||
///use epd_waveshare::{epd4in2::*, prelude::*};
|
||||
///#
|
||||
@@ -112,8 +112,14 @@ where
|
||||
///let mut display = Display4in2::default();
|
||||
///
|
||||
///// Use embedded graphics for drawing a line
|
||||
///
|
||||
///let style = PrimitiveStyleBuilder::new()
|
||||
/// .stroke_color(Black)
|
||||
/// .stroke_width(1)
|
||||
/// .build();
|
||||
///
|
||||
///let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||
/// .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||
/// .into_styled(style)
|
||||
/// .draw(&mut display);
|
||||
///
|
||||
/// // Display updated frame
|
||||
@@ -248,7 +254,7 @@ where
|
||||
///# 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, PrimitiveStyleBuilder},
|
||||
///# };
|
||||
///# use epd_waveshare::{epd4in2::*, prelude::*};
|
||||
///# use epd_waveshare::graphics::VarDisplay;
|
||||
|
||||
Reference in New Issue
Block a user