Update embedded-graphics and update epd4in2-blue-pill-exampleg
parent
8829f9a315
commit
dcaed6fb3e
|
|
@ -17,6 +17,9 @@ edition = "2018"
|
||||||
# `branch` is optional; default is `master`
|
# `branch` is optional; default is `master`
|
||||||
travis-ci = { repository = "caemor/epd-waveshare" }
|
travis-ci = { repository = "caemor/epd-waveshare" }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
embedded-graphics = { version = "0.6.0-beta.2", optional = true}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["epd1in54", "epd1in54b", "epd2in9", "epd4in2", "epd7in5", "epd7in5_v2", "graphics"]
|
default = ["epd1in54", "epd1in54b", "epd2in9", "epd4in2", "epd7in5", "epd7in5_v2", "graphics"]
|
||||||
|
|
||||||
|
|
@ -30,9 +33,7 @@ epd7in5_v2 = []
|
||||||
# offers an alternative fast full lut for type_a displays, but the refresh isnt as clean looking
|
# offers an alternative fast full lut for type_a displays, but the refresh isnt as clean looking
|
||||||
type_a_alternative_faster_lut = []
|
type_a_alternative_faster_lut = []
|
||||||
|
|
||||||
[dependencies.embedded-graphics]
|
|
||||||
optional = true
|
|
||||||
version = "0.5.2"
|
|
||||||
|
|
||||||
[dependencies.embedded-hal]
|
[dependencies.embedded-hal]
|
||||||
features = ["unproven"]
|
features = ["unproven"]
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ display.draw(
|
||||||
Font12x16::render_str("Hello Rust!")
|
Font12x16::render_str("Hello Rust!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{coord::Coord, fonts::Font6x8, prelude::*, Drawing};
|
use embedded_graphics::{fonts::Font6x8, prelude::*, Drawing, Point::Point};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
epd1in54::{Display1in54, EPD1in54},
|
epd1in54::{Display1in54, EPD1in54},
|
||||||
|
|
@ -82,7 +82,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -91,7 +91,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -100,7 +100,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -109,7 +109,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 6, 50))
|
.translate(Point::new(5 + i * 6, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{coord::Coord, fonts::Font6x8, prelude::*, Drawing};
|
use embedded_graphics::{fonts::Font6x8, prelude::*, Drawing, Point::Point};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
epd2in9::{Display2in9, EPD2in9},
|
epd2in9::{Display2in9, EPD2in9},
|
||||||
|
|
@ -86,7 +86,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -138,7 +138,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 6, 50))
|
.translate(Point::new(5 + i * 6, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
coord::Coord,
|
|
||||||
fonts::{Font12x16, Font6x8},
|
fonts::{Font12x16, Font6x8},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Circle, Line},
|
primitives::{Circle, Line},
|
||||||
Drawing,
|
Drawing,
|
||||||
|
Point::Point,
|
||||||
};
|
};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
|
|
@ -77,7 +77,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -95,7 +95,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -119,17 +119,17 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// draw a analog clock
|
// draw a analog clock
|
||||||
display.draw(
|
display.draw(
|
||||||
Circle::new(Coord::new(64, 64), 64)
|
Circle::new(Point::new(64, 64), 64)
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
let _ = Line::new(Point::new(64, 64), Point::new(0, 64))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
let _ = Line::new(Point::new(64, 64), Point::new(80, 80))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
@ -143,7 +143,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::White),
|
stroke_color: Some(Color::White),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(175, 250))
|
.translate(Point::new(175, 250))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(50, 200))
|
.translate(Point::new(50, 200))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 12, 50))
|
.translate(Point::new(5 + i * 12, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ edition = "2018"
|
||||||
#epd_waveshare = { path = "../../"}
|
#epd_waveshare = { path = "../../"}
|
||||||
epd-waveshare = { path = "../../", default-features = false, features = ["epd4in2", "graphics"]}
|
epd-waveshare = { path = "../../", default-features = false, features = ["epd4in2", "graphics"]}
|
||||||
|
|
||||||
embedded-graphics = "0.5.2"
|
embedded-graphics = "0.6.0-beta.2"
|
||||||
embedded-hal = { version = "0.2.2", features = ["unproven"] }
|
embedded-hal = { version = "0.2.3", features = ["unproven"] }
|
||||||
|
|
||||||
stm32f1xx-hal = { version = "0.2", features = ["rt", "stm32f103" ] }
|
stm32f1xx-hal = { version = "0.2", features = ["rt", "stm32f103" ] }
|
||||||
cortex-m = "0.5.0"
|
cortex-m = "0.5.0"
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,15 @@ use stm32f1xx_hal::prelude::*;
|
||||||
use stm32f1xx_hal::{delay, spi};
|
use stm32f1xx_hal::{delay, spi};
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
coord::Coord,
|
fonts::{Font12x16, Font6x8, Text},
|
||||||
fonts::{Font12x16, Font6x8},
|
pixelcolor::BinaryColor,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Circle, Line},
|
primitives::{Circle, Line},
|
||||||
Drawing,
|
style::{PrimitiveStyle, Styled},
|
||||||
|
text_style, DrawTarget,
|
||||||
};
|
};
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
|
color::*,
|
||||||
epd4in2::Display4in2,
|
epd4in2::Display4in2,
|
||||||
graphics::{Display, DisplayRotation},
|
graphics::{Display, DisplayRotation},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
|
@ -68,41 +70,18 @@ fn main() -> ! {
|
||||||
|
|
||||||
//println!("Test all the rotations");
|
//println!("Test all the rotations");
|
||||||
let mut display = Display4in2::default();
|
let mut display = Display4in2::default();
|
||||||
|
|
||||||
display.set_rotation(DisplayRotation::Rotate0);
|
display.set_rotation(DisplayRotation::Rotate0);
|
||||||
display.draw(
|
draw_text(&mut display, "Rotate 0!", 5, 50);
|
||||||
Font6x8::render_str("Rotate 0!")
|
|
||||||
.stroke(Some(Color::Black))
|
|
||||||
.fill(Some(Color::White))
|
|
||||||
.translate(Coord::new(5, 50))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
display.draw(
|
draw_text(&mut display, "Rotate 90!", 5, 50);
|
||||||
Font6x8::render_str("Rotate 90!")
|
|
||||||
.stroke(Some(Color::Black))
|
|
||||||
.fill(Some(Color::White))
|
|
||||||
.translate(Coord::new(5, 50))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
display.set_rotation(DisplayRotation::Rotate180);
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
display.draw(
|
draw_text(&mut display, "Rotate 180!", 5, 50);
|
||||||
Font6x8::render_str("Rotate 180!")
|
|
||||||
.stroke(Some(Color::Black))
|
|
||||||
.fill(Some(Color::White))
|
|
||||||
.translate(Coord::new(5, 50))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
display.draw(
|
draw_text(&mut display, "Rotate 270!", 5, 50);
|
||||||
Font6x8::render_str("Rotate 270!")
|
|
||||||
.stroke(Some(Color::Black))
|
|
||||||
.fill(Some(Color::White))
|
|
||||||
.translate(Coord::new(5, 50))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd4in2
|
epd4in2
|
||||||
|
|
@ -114,47 +93,33 @@ fn main() -> ! {
|
||||||
display.clear_buffer(Color::White);
|
display.clear_buffer(Color::White);
|
||||||
|
|
||||||
// draw a analog clock
|
// draw a analog clock
|
||||||
display.draw(
|
Circle::new(Point::new(64, 64), 64)
|
||||||
Circle::new(Coord::new(64, 64), 64)
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
Line::new(Point::new(64, 64), Point::new(0, 64))
|
||||||
);
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
display.draw(
|
.draw(&mut display);
|
||||||
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
Line::new(Point::new(64, 64), Point::new(80, 80))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
|
||||||
.stroke(Some(Color::Black))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// draw white on black background
|
// draw white on black background
|
||||||
display.draw(
|
let _ = Text::new("It's working-WoB!", Point::new(175, 250))
|
||||||
Font6x8::render_str("It's working-WoB!")
|
.into_styled(text_style!(
|
||||||
// Using Style here
|
font = Font6x8,
|
||||||
.style(Style {
|
text_color = White,
|
||||||
fill_color: Some(Color::Black),
|
background_color = Black
|
||||||
stroke_color: Some(Color::White),
|
))
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
.draw(&mut display);
|
||||||
})
|
|
||||||
.translate(Coord::new(175, 250))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// use bigger/different font
|
// use bigger/different font
|
||||||
display.draw(
|
let _ = Text::new("It's working-WoB!", Point::new(50, 200))
|
||||||
Font12x16::render_str("It's working-BoW!")
|
.into_styled(text_style!(
|
||||||
// Using Style here
|
font = Font12x16,
|
||||||
.style(Style {
|
text_color = White,
|
||||||
fill_color: Some(Color::White),
|
background_color = Black
|
||||||
stroke_color: Some(Color::Black),
|
))
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
.draw(&mut display);
|
||||||
})
|
|
||||||
.translate(Coord::new(50, 200))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// a moving `Hello World!`
|
// a moving `Hello World!`
|
||||||
let limit = 10;
|
let limit = 10;
|
||||||
|
|
@ -163,16 +128,7 @@ fn main() -> ! {
|
||||||
for i in 0..limit {
|
for i in 0..limit {
|
||||||
//println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
//println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
||||||
|
|
||||||
display.draw(
|
draw_text(&mut display, " Hello World! ", 5 + i * 12, 50);
|
||||||
Font6x8::render_str(" Hello World! ")
|
|
||||||
.style(Style {
|
|
||||||
fill_color: Some(Color::White),
|
|
||||||
stroke_color: Some(Color::Black),
|
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
|
||||||
})
|
|
||||||
.translate(Coord::new(5 + i * 12, 50))
|
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd4in2
|
epd4in2
|
||||||
|
|
@ -190,3 +146,13 @@ fn main() -> ! {
|
||||||
cortex_m::asm::wfi();
|
cortex_m::asm::wfi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_text(display: &mut Display4in2, text: &str, x: i32, y: i32) {
|
||||||
|
let _ = Text::new(text, Point::new(x, y))
|
||||||
|
.into_styled(text_style!(
|
||||||
|
font = Font6x8,
|
||||||
|
text_color = Black,
|
||||||
|
background_color = White
|
||||||
|
))
|
||||||
|
.draw(display);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
coord::Coord,
|
|
||||||
fonts::{Font12x16, Font6x8},
|
fonts::{Font12x16, Font6x8},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Circle, Line},
|
primitives::{Circle, Line},
|
||||||
Drawing,
|
Drawing,
|
||||||
|
Point::Point,
|
||||||
};
|
};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
|
|
@ -81,7 +81,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -125,17 +125,17 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// draw a analog clock
|
// draw a analog clock
|
||||||
display.draw(
|
display.draw(
|
||||||
Circle::new(Coord::new(64, 64), 64)
|
Circle::new(Point::new(64, 64), 64)
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
let _ = Line::new(Point::new(64, 64), Point::new(0, 64))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
let _ = Line::new(Point::new(64, 64), Point::new(80, 80))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
@ -149,7 +149,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::White),
|
stroke_color: Some(Color::White),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(175, 250))
|
.translate(Point::new(175, 250))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(50, 200))
|
.translate(Point::new(50, 200))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 12, 50))
|
.translate(Point::new(5 + i * 12, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
coord::Coord,
|
|
||||||
fonts::{Font12x16, Font6x8},
|
fonts::{Font12x16, Font6x8},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Circle, Line},
|
primitives::{Circle, Line},
|
||||||
Drawing,
|
Drawing,
|
||||||
|
Point::Point,
|
||||||
};
|
};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
|
|
@ -76,7 +76,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -118,17 +118,17 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// draw a analog clock
|
// draw a analog clock
|
||||||
display.draw(
|
display.draw(
|
||||||
Circle::new(Coord::new(64, 64), 64)
|
Circle::new(Point::new(64, 64), 64)
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
let _ = Line::new(Point::new(64, 64), Point::new(0, 64))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
let _ = Line::new(Point::new(64, 64), Point::new(80, 80))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
@ -142,7 +142,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::White),
|
stroke_color: Some(Color::White),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(175, 250))
|
.translate(Point::new(175, 250))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(50, 200))
|
.translate(Point::new(50, 200))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 12, 50))
|
.translate(Point::new(5 + i * 12, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
|
|
||||||
use embedded_graphics::{
|
use embedded_graphics::{
|
||||||
coord::Coord,
|
|
||||||
fonts::{Font12x16, Font6x8},
|
fonts::{Font12x16, Font6x8},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
primitives::{Circle, Line},
|
primitives::{Circle, Line},
|
||||||
Drawing,
|
Drawing,
|
||||||
|
Point::Point,
|
||||||
};
|
};
|
||||||
use embedded_hal::prelude::*;
|
use embedded_hal::prelude::*;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
|
|
@ -76,7 +76,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 0!")
|
Font6x8::render_str("Rotate 0!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 90!")
|
Font6x8::render_str("Rotate 90!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 180!")
|
Font6x8::render_str("Rotate 180!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -103,7 +103,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
Font6x8::render_str("Rotate 270!")
|
Font6x8::render_str("Rotate 270!")
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.fill(Some(Color::White))
|
.fill(Some(Color::White))
|
||||||
.translate(Coord::new(5, 50))
|
.translate(Point::new(5, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -118,17 +118,17 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// draw a analog clock
|
// draw a analog clock
|
||||||
display.draw(
|
display.draw(
|
||||||
Circle::new(Coord::new(64, 64), 64)
|
Circle::new(Point::new(64, 64), 64)
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(0, 64))
|
Line::new(Point::new(64, 64), Point::new(0, 64))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
display.draw(
|
display.draw(
|
||||||
Line::new(Coord::new(64, 64), Coord::new(80, 80))
|
Line::new(Point::new(64, 64), Point::new(80, 80))
|
||||||
.stroke(Some(Color::Black))
|
.stroke(Some(Color::Black))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
@ -142,7 +142,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::White),
|
stroke_color: Some(Color::White),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(175, 250))
|
.translate(Point::new(175, 250))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(50, 200))
|
.translate(Point::new(50, 200))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -171,7 +171,7 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
stroke_color: Some(Color::Black),
|
stroke_color: Some(Color::Black),
|
||||||
stroke_width: 0u8, // Has no effect on fonts
|
stroke_width: 0u8, // Has no effect on fonts
|
||||||
})
|
})
|
||||||
.translate(Coord::new(5 + i * 12, 50))
|
.translate(Point::new(5 + i * 12, 50))
|
||||||
.into_iter(),
|
.into_iter(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
//! B/W Color for EPDs
|
//! B/W Color for EPDs
|
||||||
|
|
||||||
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
|
|
||||||
|
pub use BinaryColor::Off as White;
|
||||||
|
pub use BinaryColor::On as Black;
|
||||||
/// Only for the Black/White-Displays
|
/// Only for the Black/White-Displays
|
||||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||||
pub enum Color {
|
pub enum Color {
|
||||||
|
|
@ -51,11 +55,6 @@ impl Color {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "graphics")]
|
|
||||||
use embedded_graphics::prelude::*;
|
|
||||||
#[cfg(feature = "graphics")]
|
|
||||||
impl PixelColor for Color {}
|
|
||||||
|
|
||||||
impl From<u8> for Color {
|
impl From<u8> for Color {
|
||||||
fn from(value: u8) -> Self {
|
fn from(value: u8) -> Self {
|
||||||
Color::from_u8(value)
|
Color::from_u8(value)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd1in54::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd1in54::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
/// Full size buffer for use with the 1in54 EPD
|
/// Full size buffer for use with the 1in54 EPD
|
||||||
|
|
@ -22,12 +22,15 @@ impl Default for Display1in54 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display1in54 {
|
impl DrawTarget<BinaryColor> for Display1in54 {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,10 +55,9 @@ impl Display for Display1in54 {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::color::Color;
|
use crate::color::{Black, Color};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||||
use embedded_graphics::primitives::Line;
|
|
||||||
|
|
||||||
// test buffer length
|
// test buffer length
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -76,11 +78,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn graphics_rotation_0() {
|
fn graphics_rotation_0() {
|
||||||
let mut display = Display1in54::default();
|
let mut display = Display1in54::default();
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||||
Line::new(Coord::new(0, 0), Coord::new(7, 0))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -95,11 +95,9 @@ mod tests {
|
||||||
fn graphics_rotation_90() {
|
fn graphics_rotation_90() {
|
||||||
let mut display = Display1in54::default();
|
let mut display = Display1in54::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 192), Point::new(0, 199))
|
||||||
Line::new(Coord::new(0, 192), Coord::new(0, 199))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -114,11 +112,9 @@ mod tests {
|
||||||
fn graphics_rotation_180() {
|
fn graphics_rotation_180() {
|
||||||
let mut display = Display1in54::default();
|
let mut display = Display1in54::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate180);
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(192, 199), Point::new(199, 199))
|
||||||
Line::new(Coord::new(192, 199), Coord::new(199, 199))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -136,11 +132,9 @@ mod tests {
|
||||||
fn graphics_rotation_270() {
|
fn graphics_rotation_270() {
|
||||||
let mut display = Display1in54::default();
|
let mut display = Display1in54::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(199, 0), Point::new(199, 7))
|
||||||
Line::new(Coord::new(199, 0), Coord::new(199, 7))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
//! Font6x8::render_str("Hello World!")
|
//! Font6x8::render_str("Hello World!")
|
||||||
//! .stroke(Some(Color::Black))
|
//! .stroke(Some(Color::Black))
|
||||||
//! .fill(Some(Color::White))
|
//! .fill(Some(Color::White))
|
||||||
//! .translate(Coord::new(5, 50))
|
//! .translate(Point::new(5, 50))
|
||||||
//! .into_iter(),
|
//! .into_iter(),
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd1in54b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd1in54b::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
pub struct Display1in54b {
|
pub struct Display1in54b {
|
||||||
|
|
@ -18,12 +18,15 @@ impl Default for Display1in54b {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display1in54b {
|
impl DrawTarget<BinaryColor> for Display1in54b {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd2in9::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
/// Display with Fullsize buffer for use with the 2in9 EPD
|
/// Display with Fullsize buffer for use with the 2in9 EPD
|
||||||
|
|
@ -22,12 +22,15 @@ impl Default for Display2in9 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display2in9 {
|
impl DrawTarget<BinaryColor> for Display2in9 {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
//! Font6x8::render_str("Hello World!")
|
//! Font6x8::render_str("Hello World!")
|
||||||
//! .stroke(Some(Color::Black))
|
//! .stroke(Some(Color::Black))
|
||||||
//! .fill(Some(Color::White))
|
//! .fill(Some(Color::White))
|
||||||
//! .translate(Coord::new(5, 50))
|
//! .translate(Point::new(5, 50))
|
||||||
//! .into_iter(),
|
//! .into_iter(),
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd4in2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd4in2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
/// Full size buffer for use with the 4in2 EPD
|
/// Full size buffer for use with the 4in2 EPD
|
||||||
|
|
@ -22,12 +22,15 @@ impl Default for Display4in2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display4in2 {
|
impl DrawTarget<BinaryColor> for Display4in2 {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,11 +55,11 @@ impl Display for Display4in2 {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::color::Black;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::epd4in2;
|
use crate::epd4in2;
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||||
use embedded_graphics::primitives::Line;
|
|
||||||
|
|
||||||
// test buffer length
|
// test buffer length
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -77,11 +80,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn graphics_rotation_0() {
|
fn graphics_rotation_0() {
|
||||||
let mut display = Display4in2::default();
|
let mut display = Display4in2::default();
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||||
Line::new(Coord::new(0, 0), Coord::new(7, 0))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -96,11 +97,9 @@ mod tests {
|
||||||
fn graphics_rotation_90() {
|
fn graphics_rotation_90() {
|
||||||
let mut display = Display4in2::default();
|
let mut display = Display4in2::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 392), Point::new(0, 399))
|
||||||
Line::new(Coord::new(0, 392), Coord::new(0, 399))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -115,11 +114,10 @@ mod tests {
|
||||||
fn graphics_rotation_180() {
|
fn graphics_rotation_180() {
|
||||||
let mut display = Display4in2::default();
|
let mut display = Display4in2::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate180);
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(392, 299), Coord::new(399, 299))
|
let _ = Line::new(Point::new(392, 299), Point::new(399, 299))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -137,11 +135,9 @@ mod tests {
|
||||||
fn graphics_rotation_270() {
|
fn graphics_rotation_270() {
|
||||||
let mut display = Display4in2::default();
|
let mut display = Display4in2::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(299, 0), Point::new(299, 7))
|
||||||
Line::new(Coord::new(299, 0), Coord::new(299, 7))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd7in5::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd7in5::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
/// Full size buffer for use with the 7in5 EPD
|
/// Full size buffer for use with the 7in5 EPD
|
||||||
|
|
@ -22,12 +22,15 @@ impl Default for Display7in5 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display7in5 {
|
impl DrawTarget<BinaryColor> for Display7in5 {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,11 +55,11 @@ impl Display for Display7in5 {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::color::Black;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::epd7in5;
|
use crate::epd7in5;
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||||
use embedded_graphics::primitives::Line;
|
|
||||||
|
|
||||||
// test buffer length
|
// test buffer length
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -77,11 +80,9 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn graphics_rotation_0() {
|
fn graphics_rotation_0() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||||
Line::new(Coord::new(0, 0), Coord::new(7, 0))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -96,11 +97,9 @@ mod tests {
|
||||||
fn graphics_rotation_90() {
|
fn graphics_rotation_90() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 632), Point::new(0, 639))
|
||||||
Line::new(Coord::new(0, 632), Coord::new(0, 639))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -115,11 +114,9 @@ mod tests {
|
||||||
fn graphics_rotation_180() {
|
fn graphics_rotation_180() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate180);
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(632, 383), Point::new(639, 383))
|
||||||
Line::new(Coord::new(632, 383), Coord::new(639, 383))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -134,11 +131,9 @@ mod tests {
|
||||||
fn graphics_rotation_270() {
|
fn graphics_rotation_270() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
display.draw(
|
let _ = Line::new(Point::new(383, 0), Point::new(383, 7))
|
||||||
Line::new(Coord::new(383, 0), Coord::new(383, 7))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::epd7in5_v2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
use crate::epd7in5_v2::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH};
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use crate::prelude::*;
|
use embedded_graphics::pixelcolor::BinaryColor;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
|
|
||||||
/// Full size buffer for use with the 7in5 EPD
|
/// Full size buffer for use with the 7in5 EPD
|
||||||
|
|
@ -22,12 +22,15 @@ impl Default for Display7in5 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drawing<Color> for Display7in5 {
|
impl DrawTarget<BinaryColor> for Display7in5 {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(WIDTH, HEIGHT, pixel)
|
||||||
self.draw_helper(WIDTH, HEIGHT, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(WIDTH, HEIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,11 +55,10 @@ impl Display for Display7in5 {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::color::Color;
|
use crate::color::{Black, Color};
|
||||||
use crate::epd7in5_v2;
|
use crate::epd7in5_v2;
|
||||||
use crate::graphics::{Display, DisplayRotation};
|
use crate::graphics::{Display, DisplayRotation};
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle};
|
||||||
use embedded_graphics::primitives::Line;
|
|
||||||
|
|
||||||
// test buffer length
|
// test buffer length
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -77,11 +79,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn graphics_rotation_0() {
|
fn graphics_rotation_0() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(0, 0), Coord::new(7, 0))
|
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -96,11 +97,10 @@ mod tests {
|
||||||
fn graphics_rotation_90() {
|
fn graphics_rotation_90() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(0, 792), Coord::new(0, 799))
|
let _ = Line::new(Point::new(0, 792), Point::new(0, 799))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -115,11 +115,10 @@ mod tests {
|
||||||
fn graphics_rotation_180() {
|
fn graphics_rotation_180() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate180);
|
display.set_rotation(DisplayRotation::Rotate180);
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(792, 479), Coord::new(799, 479))
|
let _ = Line::new(Point::new(792, 479), Point::new(799, 479))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -134,11 +133,10 @@ mod tests {
|
||||||
fn graphics_rotation_270() {
|
fn graphics_rotation_270() {
|
||||||
let mut display = Display7in5::default();
|
let mut display = Display7in5::default();
|
||||||
display.set_rotation(DisplayRotation::Rotate270);
|
display.set_rotation(DisplayRotation::Rotate270);
|
||||||
display.draw(
|
|
||||||
Line::new(Coord::new(479, 0), Coord::new(479, 7))
|
let _ = Line::new(Point::new(479, 0), Point::new(479, 7))
|
||||||
.stroke(Some(Color::Black))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.into_iter(),
|
.draw(&mut display);
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//! Graphics Support for EPDs
|
//! Graphics Support for EPDs
|
||||||
|
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::{pixelcolor::BinaryColor, prelude::*};
|
||||||
|
|
||||||
/// Displayrotation
|
/// Displayrotation
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
|
@ -22,7 +22,7 @@ impl Default for DisplayRotation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Display: Drawing<Color> {
|
pub trait Display: DrawTarget<BinaryColor> {
|
||||||
/// Clears the buffer of the display with the chosen background color
|
/// Clears the buffer of the display with the chosen background color
|
||||||
fn clear_buffer(&mut self, background_color: Color) {
|
fn clear_buffer(&mut self, background_color: Color) {
|
||||||
for elem in self.get_mut_buffer().iter_mut() {
|
for elem in self.get_mut_buffer().iter_mut() {
|
||||||
|
|
@ -45,31 +45,36 @@ pub trait Display: Drawing<Color> {
|
||||||
/// Helperfunction for the Embedded Graphics draw trait
|
/// Helperfunction for the Embedded Graphics draw trait
|
||||||
///
|
///
|
||||||
/// Becomes uneccesary when const_generics become stablised
|
/// Becomes uneccesary when const_generics become stablised
|
||||||
fn draw_helper<T>(&mut self, width: u32, height: u32, item_pixels: T)
|
fn draw_helper(
|
||||||
where
|
&mut self,
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
width: u32,
|
||||||
{
|
height: u32,
|
||||||
|
pixel: Pixel<BinaryColor>,
|
||||||
|
) -> Result<(), Self::Error> {
|
||||||
let rotation = self.rotation();
|
let rotation = self.rotation();
|
||||||
let buffer = self.get_mut_buffer();
|
let buffer = self.get_mut_buffer();
|
||||||
for Pixel(UnsignedCoord(x, y), color) in item_pixels {
|
|
||||||
if outside_display(x, y, width, height, rotation) {
|
let Pixel(point, color) = pixel;
|
||||||
continue;
|
if outside_display(point, width, height, rotation) {
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give us index inside the buffer and the bit-position in that u8 which needs to be changed
|
// Give us index inside the buffer and the bit-position in that u8 which needs to be changed
|
||||||
let (index, bit) = find_position(x, y, width, height, rotation);
|
let (index, bit) = find_position(point.x as u32, point.y as u32, width, height, rotation);
|
||||||
let index = index as usize;
|
let index = index as usize;
|
||||||
|
|
||||||
// "Draw" the Pixel on that bit
|
// "Draw" the Pixel on that bit
|
||||||
match color {
|
match color {
|
||||||
Color::Black => {
|
// Black
|
||||||
|
BinaryColor::On => {
|
||||||
buffer[index] &= !bit;
|
buffer[index] &= !bit;
|
||||||
}
|
}
|
||||||
Color::White => {
|
// White
|
||||||
|
BinaryColor::Off => {
|
||||||
buffer[index] |= bit;
|
buffer[index] |= bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,8 +88,10 @@ pub trait Display: Drawing<Color> {
|
||||||
/// # use epd_waveshare::epd2in9::DEFAULT_BACKGROUND_COLOR;
|
/// # use epd_waveshare::epd2in9::DEFAULT_BACKGROUND_COLOR;
|
||||||
/// # use epd_waveshare::prelude::*;
|
/// # use epd_waveshare::prelude::*;
|
||||||
/// # use epd_waveshare::graphics::VarDisplay;
|
/// # use epd_waveshare::graphics::VarDisplay;
|
||||||
|
/// # use epd_waveshare::color::Black;
|
||||||
/// # use embedded_graphics::prelude::*;
|
/// # use embedded_graphics::prelude::*;
|
||||||
/// # use embedded_graphics::primitives::{Circle, Line};
|
/// # use embedded_graphics::primitives::{Circle, Line};
|
||||||
|
/// # use embedded_graphics::style::PrimitiveStyle;
|
||||||
/// let width = 128;
|
/// let width = 128;
|
||||||
/// let height = 296;
|
/// let height = 296;
|
||||||
///
|
///
|
||||||
|
|
@ -93,11 +100,9 @@ pub trait Display: Drawing<Color> {
|
||||||
///
|
///
|
||||||
/// display.set_rotation(DisplayRotation::Rotate90);
|
/// display.set_rotation(DisplayRotation::Rotate90);
|
||||||
///
|
///
|
||||||
/// display.draw(
|
/// let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||||
/// Line::new(Coord::new(0, 120), Coord::new(0, 295))
|
/// .into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
/// .stroke(Some(Color::Black))
|
/// .draw(&mut display);
|
||||||
/// .into_iter(),
|
|
||||||
/// );
|
|
||||||
/// ```
|
/// ```
|
||||||
pub struct VarDisplay<'a> {
|
pub struct VarDisplay<'a> {
|
||||||
width: u32,
|
width: u32,
|
||||||
|
|
@ -119,12 +124,15 @@ impl<'a> VarDisplay<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Drawing<Color> for VarDisplay<'a> {
|
impl<'a> DrawTarget<BinaryColor> for VarDisplay<'a> {
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
type Error = core::convert::Infallible;
|
||||||
where
|
|
||||||
T: IntoIterator<Item = Pixel<Color>>,
|
fn draw_pixel(&mut self, pixel: Pixel<BinaryColor>) -> Result<(), Self::Error> {
|
||||||
{
|
self.draw_helper(self.width, self.height, pixel)
|
||||||
self.draw_helper(self.width, self.height, item_pixels);
|
}
|
||||||
|
|
||||||
|
fn size(&self) -> Size {
|
||||||
|
Size::new(self.width, self.height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,7 +155,11 @@ impl<'a> Display for VarDisplay<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if a pos is outside the defined display
|
// Checks if a pos is outside the defined display
|
||||||
fn outside_display(x: u32, y: u32, width: u32, height: u32, rotation: DisplayRotation) -> bool {
|
fn outside_display(p: Point, width: u32, height: u32, rotation: DisplayRotation) -> bool {
|
||||||
|
if p.x < 0 || p.y < 0 {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let (x, y) = (p.x as u32, p.y as u32);
|
||||||
match rotation {
|
match rotation {
|
||||||
DisplayRotation::Rotate0 | DisplayRotation::Rotate180 => {
|
DisplayRotation::Rotate0 | DisplayRotation::Rotate180 => {
|
||||||
if x >= width || y >= height {
|
if x >= width || y >= height {
|
||||||
|
|
@ -189,10 +201,9 @@ fn find_position(x: u32, y: u32, width: u32, height: u32, rotation: DisplayRotat
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::{find_position, outside_display, Display, DisplayRotation, VarDisplay};
|
use super::{find_position, outside_display, Display, DisplayRotation, VarDisplay};
|
||||||
|
use crate::color::Black;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::{prelude::*, primitives::Line, style::PrimitiveStyle};
|
||||||
use embedded_graphics::prelude::*;
|
|
||||||
use embedded_graphics::primitives::Line;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn buffer_clear() {
|
fn buffer_clear() {
|
||||||
|
|
@ -228,7 +239,7 @@ mod tests {
|
||||||
for x in 0..(width + height) {
|
for x in 0..(width + height) {
|
||||||
//limit x because it runs too long
|
//limit x because it runs too long
|
||||||
for y in 0..(u32::max_value()) {
|
for y in 0..(u32::max_value()) {
|
||||||
if outside_display(x, y, width, height, rotation2) {
|
if outside_display(Point::new(x as i32, y as i32), width, height, rotation2) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
let (idx, _) = find_position(x, y, width, height, rotation2);
|
let (idx, _) = find_position(x, y, width, height, rotation2);
|
||||||
|
|
@ -247,11 +258,9 @@ mod tests {
|
||||||
let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 128 / 8 * 296];
|
let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 128 / 8 * 296];
|
||||||
let mut display = VarDisplay::new(width, height, &mut buffer);
|
let mut display = VarDisplay::new(width, height, &mut buffer);
|
||||||
|
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 0), Point::new(7, 0))
|
||||||
Line::new(Coord::new(0, 0), Coord::new(7, 0))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
@ -273,11 +282,9 @@ mod tests {
|
||||||
|
|
||||||
display.set_rotation(DisplayRotation::Rotate90);
|
display.set_rotation(DisplayRotation::Rotate90);
|
||||||
|
|
||||||
display.draw(
|
let _ = Line::new(Point::new(0, 120), Point::new(0, 295))
|
||||||
Line::new(Coord::new(0, 120), Coord::new(0, 295))
|
.into_styled(PrimitiveStyle::with_stroke(Black, 1))
|
||||||
.stroke(Some(Color::Black))
|
.draw(&mut display);
|
||||||
.into_iter(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let buffer = display.buffer();
|
let buffer = display.buffer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
//! Font6x8::render_str("Hello World!")
|
//! Font6x8::render_str("Hello World!")
|
||||||
//! .stroke(Some(Color::Black))
|
//! .stroke(Some(Color::Black))
|
||||||
//! .fill(Some(Color::White))
|
//! .fill(Some(Color::White))
|
||||||
//! .translate(Coord::new(5, 50))
|
//! .translate(Point::new(5, 50))
|
||||||
//! .into_iter(),
|
//! .into_iter(),
|
||||||
//! );
|
//! );
|
||||||
//!
|
//!
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue