Compare commits
No commits in common. "78b6442fe30a509a34a5d06f809d2e65be10e382" and "05e927d0a8ff47f2ae43045d03034c1426cc3d23" have entirely different histories.
78b6442fe3
...
05e927d0a8
4 changed files with 9 additions and 141 deletions
66
Cargo.lock
generated
66
Cargo.lock
generated
|
|
@ -2,81 +2,15 @@
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "autocfg"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "az"
|
|
||||||
version = "1.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "embedded-graphics"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0649998afacf6d575d126d83e68b78c0ab0e00ca2ac7e9b3db11b4cbe8274ef0"
|
|
||||||
dependencies = [
|
|
||||||
"az",
|
|
||||||
"byteorder",
|
|
||||||
"embedded-graphics-core",
|
|
||||||
"float-cmp",
|
|
||||||
"micromath",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "embedded-graphics-core"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ba9ecd261f991856250d2207f6d8376946cd9f412a2165d3b75bc87a0bc7a044"
|
|
||||||
dependencies = [
|
|
||||||
"az",
|
|
||||||
"byteorder",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "embedded-hal"
|
name = "embedded-hal"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
|
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "float-cmp"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "micromath"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c3c8dda44ff03a2f238717214da50f65d5a53b45cd213a7370424ffdb6fae815"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-traits"
|
|
||||||
version = "0.2.19"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zel-gdeq031t10"
|
name = "zel-gdeq031t10"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"embedded-graphics",
|
|
||||||
"embedded-hal",
|
"embedded-hal",
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,4 @@ version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
embedded-graphics = { version = "0.8.1", optional = true }
|
|
||||||
embedded-hal = "1.0.0"
|
embedded-hal = "1.0.0"
|
||||||
|
|
||||||
[features]
|
|
||||||
embedded-graphics = ["dep:embedded-graphics"]
|
|
||||||
|
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
use embedded_graphics::{
|
|
||||||
pixelcolor::BinaryColor,
|
|
||||||
prelude::{DrawTarget, OriginDimensions, Size},
|
|
||||||
};
|
|
||||||
impl<PartialWindow: crate::ApplyPartialWindow> OriginDimensions
|
|
||||||
for crate::DoubleFrame<PartialWindow>
|
|
||||||
{
|
|
||||||
fn size(&self) -> Size {
|
|
||||||
Size {
|
|
||||||
width: crate::EPD_WIDTH as u32,
|
|
||||||
height: crate::EPD_HEIGHT as u32,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<PartialWindow: crate::ApplyPartialWindow> DrawTarget for crate::DoubleFrame<PartialWindow> {
|
|
||||||
type Color = BinaryColor;
|
|
||||||
|
|
||||||
type Error = core::convert::Infallible;
|
|
||||||
|
|
||||||
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error>
|
|
||||||
where
|
|
||||||
I: IntoIterator<Item = embedded_graphics::Pixel<Self::Color>>,
|
|
||||||
{
|
|
||||||
for pixel in pixels {
|
|
||||||
self.draw_pixel(pixel.0.x as u16, pixel.0.y as u16, convert_colour(pixel.1));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn convert_colour(colour: BinaryColor) -> crate::PixelColour {
|
|
||||||
match colour {
|
|
||||||
BinaryColor::Off => crate::PixelColour::Black,
|
|
||||||
BinaryColor::On => crate::PixelColour::White,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
42
src/lib.rs
42
src/lib.rs
|
|
@ -5,9 +5,6 @@
|
||||||
//! **Note**: 9-bit SPI mode (where the data/command is designated with an extra bit for each byte)
|
//! **Note**: 9-bit SPI mode (where the data/command is designated with an extra bit for each byte)
|
||||||
//! is not supported by this driver. Only the mode with a dedicated data/command line is supported.
|
//! is not supported by this driver. Only the mode with a dedicated data/command line is supported.
|
||||||
|
|
||||||
#[cfg(feature = "embedded-graphics")]
|
|
||||||
mod embedded_graphics_impl;
|
|
||||||
|
|
||||||
use embedded_hal::{
|
use embedded_hal::{
|
||||||
delay::DelayNs,
|
delay::DelayNs,
|
||||||
digital::{InputPin, OutputPin},
|
digital::{InputPin, OutputPin},
|
||||||
|
|
@ -67,20 +64,12 @@ pub struct DoubleFrame<PartialWindow> {
|
||||||
partial_window: PartialWindow,
|
partial_window: PartialWindow,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The colour of a given pixel.
|
|
||||||
///
|
|
||||||
/// Since the GDEQ031T10 is pure black-and-white (no greyscale), this is just a two-state enum.S
|
|
||||||
pub enum PixelColour {
|
pub enum PixelColour {
|
||||||
Black = 0,
|
Black = 0,
|
||||||
White = 1,
|
White = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A trait for partial window strategies for use with [DoubleFrame].
|
pub trait ApplyParitalWindow: private::Sealed {
|
||||||
///
|
|
||||||
/// This trait is sealed, so the only strategies available are [NoPartialWindow]
|
|
||||||
/// and [AutomaticPartialWindow].
|
|
||||||
pub trait ApplyPartialWindow: private::Sealed {
|
|
||||||
/// Applies the given window to the display so that its next update will only refresh part of the display.
|
|
||||||
fn apply<
|
fn apply<
|
||||||
BusyPin: InputPin,
|
BusyPin: InputPin,
|
||||||
ResetPin: OutputPin,
|
ResetPin: OutputPin,
|
||||||
|
|
@ -92,29 +81,22 @@ pub trait ApplyPartialWindow: private::Sealed {
|
||||||
display: &mut EPaperDisplay<BusyPin, ResetPin, DcPin, Spi, Delay>,
|
display: &mut EPaperDisplay<BusyPin, ResetPin, DcPin, Spi, Delay>,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// Add a new bounding box which must be covered by the partial window.
|
|
||||||
///
|
|
||||||
/// Calls to this method accumulate, meaning all bounding boxes will be covered by the
|
|
||||||
/// partial window until [ApplyPartialWindow::reset_partial_window] is called.
|
|
||||||
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16);
|
fn update_partial_window(&mut self, min_x: u16, max_x: u16, min_y: u16, max_y: u16);
|
||||||
|
|
||||||
/// Resets the partial window to be empty.
|
|
||||||
fn reset_partial_window(&mut self);
|
fn reset_partial_window(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
mod private {
|
mod private {
|
||||||
pub trait Sealed {}
|
pub(super) trait Sealed {}
|
||||||
|
|
||||||
impl Sealed for super::NoPartialWindow {}
|
impl Sealed for super::NoPartialWindow {}
|
||||||
|
|
||||||
impl Sealed for super::AutomaticPartialWindow {}
|
impl Sealed for super::AutomaticPartialWindow {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A partial window strategy which doesn't do any window tracking and simply updates
|
|
||||||
/// the entire display.
|
|
||||||
pub struct NoPartialWindow;
|
pub struct NoPartialWindow;
|
||||||
|
|
||||||
impl ApplyPartialWindow for NoPartialWindow {
|
impl ApplyParitalWindow for NoPartialWindow {
|
||||||
fn apply<
|
fn apply<
|
||||||
BusyPin: InputPin,
|
BusyPin: InputPin,
|
||||||
ResetPin: OutputPin,
|
ResetPin: OutputPin,
|
||||||
|
|
@ -132,8 +114,6 @@ impl ApplyPartialWindow for NoPartialWindow {
|
||||||
fn reset_partial_window(&mut self) {}
|
fn reset_partial_window(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A partial window strategy which tracks the bounding box of all changes made to the display
|
|
||||||
/// since the last display update and only updates that region.
|
|
||||||
pub struct AutomaticPartialWindow {
|
pub struct AutomaticPartialWindow {
|
||||||
min_x: u16,
|
min_x: u16,
|
||||||
max_x: u16,
|
max_x: u16,
|
||||||
|
|
@ -141,7 +121,7 @@ pub struct AutomaticPartialWindow {
|
||||||
max_y: u16,
|
max_y: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApplyPartialWindow for AutomaticPartialWindow {
|
impl ApplyParitalWindow for AutomaticPartialWindow {
|
||||||
fn apply<
|
fn apply<
|
||||||
BusyPin: InputPin,
|
BusyPin: InputPin,
|
||||||
ResetPin: OutputPin,
|
ResetPin: OutputPin,
|
||||||
|
|
@ -191,6 +171,10 @@ impl DoubleFrame<NoPartialWindow> {
|
||||||
partial_window: NoPartialWindow,
|
partial_window: NoPartialWindow,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn draw_pixel(&mut self, x: usize, y: usize, colour: PixelColour) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DoubleFrame<AutomaticPartialWindow> {
|
impl DoubleFrame<AutomaticPartialWindow> {
|
||||||
|
|
@ -208,12 +192,6 @@ impl DoubleFrame<AutomaticPartialWindow> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<PartialWindow: ApplyPartialWindow> DoubleFrame<PartialWindow> {
|
|
||||||
pub fn draw_pixel(&mut self, x: u16, y: u16, colour: PixelColour) {
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, Delay: DelayNs>
|
impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, Delay: DelayNs>
|
||||||
EPaperDisplay<BusyPin, ResetPin, DcPin, Spi, Delay>
|
EPaperDisplay<BusyPin, ResetPin, DcPin, Spi, Delay>
|
||||||
{
|
{
|
||||||
|
|
@ -294,7 +272,7 @@ impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, D
|
||||||
self.wait_for_display();
|
self.wait_for_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_full_frame<PartialWindow: ApplyPartialWindow>(&mut self, double_frame: &mut DoubleFrame<PartialWindow>) {
|
pub fn draw_full_frame<PartialWindow: ApplyParitalWindow>(&mut self, double_frame: &mut DoubleFrame<PartialWindow>) {
|
||||||
double_frame.partial_window.apply(self);
|
double_frame.partial_window.apply(self);
|
||||||
self.write_command(0x10);
|
self.write_command(0x10);
|
||||||
for byte in double_frame.old.0 {
|
for byte in double_frame.old.0 {
|
||||||
|
|
@ -321,12 +299,10 @@ impl<BusyPin: InputPin, ResetPin: OutputPin, DcPin: OutputPin, Spi: SpiDevice, D
|
||||||
self.write_data(0xA5);
|
self.write_data(0xA5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enables partial updates based on whichever strategy was chosen at time of display initialisation.
|
|
||||||
pub fn enable_partial_mode(&mut self) {
|
pub fn enable_partial_mode(&mut self) {
|
||||||
self.write_command(0x91);
|
self.write_command(0x91);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disable partial updates; all updates will refresh the entire display.
|
|
||||||
pub fn disable_partial_mode(&mut self) {
|
pub fn disable_partial_mode(&mut self) {
|
||||||
self.write_command(0x92);
|
self.write_command(0x92);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue