Update embedded-graphics and update epd4in2-blue-pill-exampleg

This commit is contained in:
Caemor
2020-03-18 14:30:40 +01:00
parent 8829f9a315
commit dcaed6fb3e
21 changed files with 290 additions and 328 deletions
+24 -29
View File
@@ -1,6 +1,6 @@
use crate::epd7in5::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
use crate::graphics::{Display, DisplayRotation};
use crate::prelude::*;
use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
/// Full size buffer for use with the 7in5 EPD
@@ -22,12 +22,15 @@ impl Default for Display7in5 {
}
}
impl Drawing<Color> for Display7in5 {
fn draw<T>(&mut self, item_pixels: T)
where
T: IntoIterator<Item = Pixel<Color>>,
{
self.draw_helper(WIDTH, HEIGHT, item_pixels);
impl DrawTarget<BinaryColor> for Display7in5 {
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)
}
}
@@ -52,11 +55,11 @@ impl Display for Display7in5 {
#[cfg(test)]
mod tests {
use super::*;
use crate::color::Black;
use crate::color::Color;
use crate::epd7in5;
use crate::graphics::{Display, DisplayRotation};
use embedded_graphics::coord::Coord;
use embedded_graphics::primitives::Line;
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
// test buffer length
#[test]
@@ -77,11 +80,9 @@ mod tests {
#[test]
fn graphics_rotation_0() {
let mut display = Display7in5::default();
display.draw(
Line::new(Coord::new(0, 0), Coord::new(7, 0))
.stroke(Some(Color::Black))
.into_iter(),
);
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
.draw(&mut display);
let buffer = display.buffer();
@@ -96,11 +97,9 @@ mod tests {
fn graphics_rotation_90() {
let mut display = Display7in5::default();
display.set_rotation(DisplayRotation::Rotate90);
display.draw(
Line::new(Coord::new(0, 632), Coord::new(0, 639))
.stroke(Some(Color::Black))
.into_iter(),
);
let _ = Line::new(Point::new(0, 632), Point::new(0, 639))
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
.draw(&mut display);
let buffer = display.buffer();
@@ -115,11 +114,9 @@ mod tests {
fn graphics_rotation_180() {
let mut display = Display7in5::default();
display.set_rotation(DisplayRotation::Rotate180);
display.draw(
Line::new(Coord::new(632, 383), Coord::new(639, 383))
.stroke(Some(Color::Black))
.into_iter(),
);
let _ = Line::new(Point::new(632, 383), Point::new(639, 383))
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
.draw(&mut display);
let buffer = display.buffer();
@@ -134,11 +131,9 @@ mod tests {
fn graphics_rotation_270() {
let mut display = Display7in5::default();
display.set_rotation(DisplayRotation::Rotate270);
display.draw(
Line::new(Coord::new(383, 0), Coord::new(383, 7))
.stroke(Some(Color::Black))
.into_iter(),
);
let _ = Line::new(Point::new(383, 0), Point::new(383, 7))
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
.draw(&mut display);
let buffer = display.buffer();