|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
|
|
|
use crate::color::OctColor; |
|
|
|
use crate::epd5in65f::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; |
|
|
|
use crate::epd5in65f::{DEFAULT_BACKGROUND_COLOR, HEIGHT, WIDTH}; |
|
|
|
use crate::graphics::{OctDisplay, DisplayRotation}; |
|
|
|
use crate::graphics::{DisplayRotation, OctDisplay}; |
|
|
|
use embedded_graphics::prelude::*; |
|
|
|
use embedded_graphics::prelude::*; |
|
|
|
use crate::color::OctColor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Full size buffer for use with the 5in65f EPD
|
|
|
|
/// Full size buffer for use with the 5in65f EPD
|
|
|
|
///
|
|
|
|
///
|
|
|
|
@ -56,14 +56,14 @@ impl OctDisplay for Display5in65f { |
|
|
|
mod tests { |
|
|
|
mod tests { |
|
|
|
use super::*; |
|
|
|
use super::*; |
|
|
|
use crate::epd5in65f; |
|
|
|
use crate::epd5in65f; |
|
|
|
use crate::graphics::{OctDisplay, DisplayRotation}; |
|
|
|
use crate::graphics::{DisplayRotation, OctDisplay}; |
|
|
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle}; |
|
|
|
use embedded_graphics::{primitives::Line, style::PrimitiveStyle}; |
|
|
|
|
|
|
|
|
|
|
|
// test buffer length
|
|
|
|
// test buffer length
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn graphics_size() { |
|
|
|
fn graphics_size() { |
|
|
|
let display = Display5in65f::default(); |
|
|
|
let display = Display5in65f::default(); |
|
|
|
assert_eq!(display.buffer().len(), 448*600 / 2); |
|
|
|
assert_eq!(display.buffer().len(), 448 * 600 / 2); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// test default background color on all bytes
|
|
|
|
// test default background color on all bytes
|
|
|
|
@ -71,10 +71,13 @@ mod tests { |
|
|
|
fn graphics_default() { |
|
|
|
fn graphics_default() { |
|
|
|
let display = Display5in65f::default(); |
|
|
|
let display = Display5in65f::default(); |
|
|
|
for &byte in display.buffer() { |
|
|
|
for &byte in display.buffer() { |
|
|
|
assert_eq!(byte, OctColor::colors_byte( |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
byte, |
|
|
|
|
|
|
|
OctColor::colors_byte( |
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
)); |
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -89,13 +92,19 @@ mod tests { |
|
|
|
let buffer = display.buffer(); |
|
|
|
let buffer = display.buffer(); |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
assert_eq!(OctColor::split_byte(byte), Ok((OctColor::Black, OctColor::Black))); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
OctColor::split_byte(byte), |
|
|
|
|
|
|
|
Ok((OctColor::Black, OctColor::Black)) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
OctColor::split_byte(byte), |
|
|
|
OctColor::split_byte(byte), |
|
|
|
Ok((epd5in65f::DEFAULT_BACKGROUND_COLOR, epd5in65f::DEFAULT_BACKGROUND_COLOR)) |
|
|
|
Ok(( |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR |
|
|
|
|
|
|
|
)) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -105,20 +114,29 @@ mod tests { |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
display.set_rotation(DisplayRotation::Rotate90); |
|
|
|
display.set_rotation(DisplayRotation::Rotate90); |
|
|
|
|
|
|
|
|
|
|
|
let _ = Line::new(Point::new(0, WIDTH as i32 - 2), Point::new(0, WIDTH as i32- 1)) |
|
|
|
let _ = Line::new( |
|
|
|
|
|
|
|
Point::new(0, WIDTH as i32 - 2), |
|
|
|
|
|
|
|
Point::new(0, WIDTH as i32 - 1), |
|
|
|
|
|
|
|
) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.draw(&mut display); |
|
|
|
.draw(&mut display); |
|
|
|
|
|
|
|
|
|
|
|
let buffer = display.buffer(); |
|
|
|
let buffer = display.buffer(); |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
assert_eq!(OctColor::split_byte(byte), Ok((OctColor::Black, OctColor::Black))); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
OctColor::split_byte(byte), |
|
|
|
|
|
|
|
Ok((OctColor::Black, OctColor::Black)) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
OctColor::split_byte(byte), |
|
|
|
OctColor::split_byte(byte), |
|
|
|
Ok((epd5in65f::DEFAULT_BACKGROUND_COLOR, epd5in65f::DEFAULT_BACKGROUND_COLOR)) |
|
|
|
Ok(( |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR |
|
|
|
|
|
|
|
)) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -128,21 +146,29 @@ mod tests { |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
display.set_rotation(DisplayRotation::Rotate180); |
|
|
|
display.set_rotation(DisplayRotation::Rotate180); |
|
|
|
|
|
|
|
|
|
|
|
let _ = Line::new(Point::new(WIDTH as i32 - 2, HEIGHT as i32 - 1), |
|
|
|
let _ = Line::new( |
|
|
|
Point::new(WIDTH as i32 - 1, HEIGHT as i32 - 1)) |
|
|
|
Point::new(WIDTH as i32 - 2, HEIGHT as i32 - 1), |
|
|
|
|
|
|
|
Point::new(WIDTH as i32 - 1, HEIGHT as i32 - 1), |
|
|
|
|
|
|
|
) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.draw(&mut display); |
|
|
|
.draw(&mut display); |
|
|
|
|
|
|
|
|
|
|
|
let buffer = display.buffer(); |
|
|
|
let buffer = display.buffer(); |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
assert_eq!(OctColor::split_byte(byte), Ok((OctColor::Black, OctColor::Black))); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
OctColor::split_byte(byte), |
|
|
|
|
|
|
|
Ok((OctColor::Black, OctColor::Black)) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
OctColor::split_byte(byte), |
|
|
|
OctColor::split_byte(byte), |
|
|
|
Ok((epd5in65f::DEFAULT_BACKGROUND_COLOR, epd5in65f::DEFAULT_BACKGROUND_COLOR)) |
|
|
|
Ok(( |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR |
|
|
|
|
|
|
|
)) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -152,21 +178,29 @@ mod tests { |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
let mut display = Display5in65f::default(); |
|
|
|
display.set_rotation(DisplayRotation::Rotate270); |
|
|
|
display.set_rotation(DisplayRotation::Rotate270); |
|
|
|
|
|
|
|
|
|
|
|
let _ = Line::new(Point::new(HEIGHT as i32 -1, 0), |
|
|
|
let _ = Line::new( |
|
|
|
Point::new(HEIGHT as i32 -1, 1)) |
|
|
|
Point::new(HEIGHT as i32 - 1, 0), |
|
|
|
|
|
|
|
Point::new(HEIGHT as i32 - 1, 1), |
|
|
|
|
|
|
|
) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.into_styled(PrimitiveStyle::with_stroke(OctColor::Black, 1)) |
|
|
|
.draw(&mut display); |
|
|
|
.draw(&mut display); |
|
|
|
|
|
|
|
|
|
|
|
let buffer = display.buffer(); |
|
|
|
let buffer = display.buffer(); |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
for &byte in buffer.iter().take(1) { |
|
|
|
assert_eq!(OctColor::split_byte(byte), Ok((OctColor::Black, OctColor::Black))); |
|
|
|
assert_eq!( |
|
|
|
|
|
|
|
OctColor::split_byte(byte), |
|
|
|
|
|
|
|
Ok((OctColor::Black, OctColor::Black)) |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
for &byte in buffer.iter().skip(1) { |
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
OctColor::split_byte(byte), |
|
|
|
OctColor::split_byte(byte), |
|
|
|
Ok((epd5in65f::DEFAULT_BACKGROUND_COLOR, epd5in65f::DEFAULT_BACKGROUND_COLOR)) |
|
|
|
Ok(( |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR, |
|
|
|
|
|
|
|
epd5in65f::DEFAULT_BACKGROUND_COLOR |
|
|
|
|
|
|
|
)) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|