From 4ccbea56074d8aaeac81754357c16566393bda1d Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Wed, 27 Jan 2021 17:34:39 +0100 Subject: [PATCH 1/6] Add Example to quick refresh trait --- src/traits.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index 044185a..d4877b5 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -238,6 +238,43 @@ where /// and how they will change. This isn't required when using full refreshes. /// /// (todo: Example ommitted due to CI failures.) +/// Example: +///```rust, no_run +///# use embedded_hal_mock::*; +///# fn main() -> Result<(), MockError> { +///# use embedded_graphics::{ +///# pixelcolor::BinaryColor::On as Black, prelude::*, primitives::Line, style::PrimitiveStyle, +///# }; +///# use epd_waveshare::{epd4in2::*, prelude::*}; +///# use epd_waveshare::graphics::VarDisplay; +///# +///# let expectations = []; +///# let mut spi = spi::Mock::new(&expectations); +///# let expectations = []; +///# let cs_pin = pin::Mock::new(&expectations); +///# let busy_in = pin::Mock::new(&expectations); +///# let dc = pin::Mock::new(&expectations); +///# let rst = pin::Mock::new(&expectations); +///# let mut delay = delay::MockNoop::new(); +///# +///# // Setup EPD +///# let mut epd = EPD4in2::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; +///let (x, y, frame_width, frame_height) = (20, 40, 80,80); +/// +///let mut buffer = [DEFAULT_BACKGROUND_COLOR.get_byte_value(); 80 / 8 * 80]; +///let mut display = VarDisplay::new(frame_width, frame_height, &mut buffer); +/// +///epd.update_partial_old_frame(&mut spi, display.buffer(), x, y, frame_width, frame_height) +/// .ok(); +/// +///display.clear_buffer(Color::White); +///// Execute drawing commands here. +/// +///epd.update_partial_new_frame(&mut spi, display.buffer(), x, y, frame_width, frame_height) +/// .ok(); +///# Ok(()) +///# } +///``` pub trait QuickRefresh where SPI: Write, From ad9574f355c5281637fe4478011097a270481264 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Wed, 27 Jan 2021 17:35:03 +0100 Subject: [PATCH 2/6] Add David & the changes to Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af0425f..9b25ca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added - + - Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) ### Changed - Use specific ParseColorError instead of () From bcbef1e80544f40fc9e4ddba33f7885c65b8e734 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Wed, 27 Jan 2021 20:29:23 +0100 Subject: [PATCH 3/6] "EPD4in2: Don't set the resolution (and some more) over and over again. If the resolution ever changes, something has horribly gone wrong." From @mgottschlag #48 --- src/epd4in2/mod.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 76ab7a6..098d085 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -132,6 +132,15 @@ where // 3A 100HZ 29 150Hz 39 200HZ 31 171HZ DEFAULT: 3c 50Hz self.cmd_with_data(spi, Command::PLL_CONTROL, &[0x3A])?; + self.send_resolution(spi)?; + + self.interface + .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; + + //VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 + self.interface + .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x97])?; + self.set_lut(spi, None)?; self.wait_until_idle(); @@ -202,15 +211,6 @@ where self.wait_until_idle(); let color_value = self.color.get_byte_value(); - self.send_resolution(spi)?; - - self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; - - //VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x97])?; - self.interface .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; self.interface From 788ddcab98519c29a272aec444564a2c030e630c Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Wed, 27 Jan 2021 20:53:24 +0100 Subject: [PATCH 4/6] Apply #48 to QuickRefresh as well --- src/epd4in2/mod.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/epd4in2/mod.rs b/src/epd4in2/mod.rs index 098d085..636b254 100644 --- a/src/epd4in2/mod.rs +++ b/src/epd4in2/mod.rs @@ -450,14 +450,6 @@ where fn update_old_frame(&mut self, spi: &mut SPI, buffer: &[u8]) -> Result<(), SPI::Error> { self.wait_until_idle(); - // todo: Eval if you need these 3 res setting items. - self.send_resolution(spi)?; - self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; - //VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x97])?; - self.interface .cmd(spi, Command::DATA_START_TRANSMISSION_1)?; @@ -490,14 +482,6 @@ where ) -> Result<(), SPI::Error> { self.wait_until_idle(); - // todo: Eval if you need these 3 res setting items. - self.send_resolution(spi)?; - self.interface - .cmd_with_data(spi, Command::VCM_DC_SETTING, &[0x12])?; - //VBDF 17|D7 VBDW 97 VBDB 57 VBDF F7 VBDW 77 VBDB 37 VBDR B7 - self.interface - .cmd_with_data(spi, Command::VCOM_AND_DATA_INTERVAL_SETTING, &[0x97])?; - if buffer.len() as u32 != width / 8 * height { //TODO: panic!! or sth like that //return Err("Wrong buffersize"); From f9a09d9018bdaa88d2f0f36ec394d0a0b9d19c51 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Wed, 27 Jan 2021 21:00:52 +0100 Subject: [PATCH 5/6] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b25ca6..dc08bc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - Use specific ParseColorError instead of () + - EPD4in2: Don't set the resolution (and some more) over and over again (#48) ### Fixed From b4c3722eceaf29a4dcb79c811e839890ed9419c9 Mon Sep 17 00:00:00 2001 From: Caemor <11088935+caemor@users.noreply.github.com> Date: Thu, 28 Jan 2021 12:08:13 +0100 Subject: [PATCH 6/6] Updated Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc08bc3..f3eeac2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - Added QuickRefresh Trait and implemented it for EPD4in2 in #62 (thanks to @David-OConnor) + - Added Epd 2in7 (B) support in #60 (thanks to @pjsier) ### Changed - Use specific ParseColorError instead of ()