From 64174b3ac6fe7f6d8ecb22f1147858ce708f1dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Tue, 3 Oct 2023 16:41:43 -0400 Subject: [PATCH 1/6] feat: Added sleep/wake methods to display --- mipidsi/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/mipidsi/src/lib.rs b/mipidsi/src/lib.rs index 93e11bc..82f7dcc 100644 --- a/mipidsi/src/lib.rs +++ b/mipidsi/src/lib.rs @@ -253,4 +253,19 @@ where self.dcs .write_command(dcs::SetTearingEffect(tearing_effect)) } + + /// + /// Puts the display to sleep, reducing power consumption. + /// Need to call [Self::wake] before issuing other commands + /// + pub fn sleep(&mut self) -> Result<(), Error> { + self.dcs.write_command(dcs::EnterSleepMode) + } + + /// + /// Wakes the display after it's been set to sleep via [Self::sleep] + /// + pub fn wake(&mut self) -> Result<(), Error> { + self.dcs.write_command(dcs::ExitSleepMode) + } } From 1ed4f8911bdeee99ecaa98b7ad1b4f2d5246f02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Tue, 3 Oct 2023 16:48:11 -0400 Subject: [PATCH 2/6] doc: comment on init --- mipidsi/src/builder.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mipidsi/src/builder.rs b/mipidsi/src/builder.rs index 587a286..3528e87 100644 --- a/mipidsi/src/builder.rs +++ b/mipidsi/src/builder.rs @@ -117,7 +117,8 @@ where /// /// Consumes the builder to create a new [Display] with an optional reset [OutputPin]. /// Blocks using the provided [DelayUs] `delay_source` to perform the display initialization. - /// + /// The display will be awake ready to use, no need to call [Display::wake] after init. + /// /// ### WARNING /// The reset pin needs to be in *high* state in order for the display to operate. /// If it wasn't provided the user needs to ensure this is the case. From 7910eb026feee1e9f7f94be58f22843217791be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Tue, 3 Oct 2023 16:50:09 -0400 Subject: [PATCH 3/6] fix: format --- mipidsi/src/builder.rs | 2 +- mipidsi/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mipidsi/src/builder.rs b/mipidsi/src/builder.rs index 3528e87..40a8e65 100644 --- a/mipidsi/src/builder.rs +++ b/mipidsi/src/builder.rs @@ -118,7 +118,7 @@ where /// Consumes the builder to create a new [Display] with an optional reset [OutputPin]. /// Blocks using the provided [DelayUs] `delay_source` to perform the display initialization. /// The display will be awake ready to use, no need to call [Display::wake] after init. - /// + /// /// ### WARNING /// The reset pin needs to be in *high* state in order for the display to operate. /// If it wasn't provided the user needs to ensure this is the case. diff --git a/mipidsi/src/lib.rs b/mipidsi/src/lib.rs index 82f7dcc..144b352 100644 --- a/mipidsi/src/lib.rs +++ b/mipidsi/src/lib.rs @@ -253,7 +253,7 @@ where self.dcs .write_command(dcs::SetTearingEffect(tearing_effect)) } - + /// /// Puts the display to sleep, reducing power consumption. /// Need to call [Self::wake] before issuing other commands @@ -261,7 +261,7 @@ where pub fn sleep(&mut self) -> Result<(), Error> { self.dcs.write_command(dcs::EnterSleepMode) } - + /// /// Wakes the display after it's been set to sleep via [Self::sleep] /// From 2de4c1835c014b43344fbea78e285e8ac126cec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Fri, 6 Oct 2023 11:25:32 -0400 Subject: [PATCH 4/6] feat: added minimal delay to wake and sleep --- mipidsi/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mipidsi/src/lib.rs b/mipidsi/src/lib.rs index 144b352..a41b812 100644 --- a/mipidsi/src/lib.rs +++ b/mipidsi/src/lib.rs @@ -80,6 +80,7 @@ use dcs::Dcs; use display_interface::WriteOnlyDataCommand; pub mod error; +use embedded_hal::blocking::delay::DelayUs; use embedded_hal::digital::v2::OutputPin; pub use error::Error; @@ -258,14 +259,18 @@ where /// Puts the display to sleep, reducing power consumption. /// Need to call [Self::wake] before issuing other commands /// - pub fn sleep(&mut self) -> Result<(), Error> { - self.dcs.write_command(dcs::EnterSleepMode) + pub fn sleep>(&mut self, delay: &mut D) -> Result<(), Error> { + self.dcs.write_command(dcs::EnterSleepMode)?; + delay.delay_us(120_000); // All supported models requires a 120ms delay + Ok(()) } /// /// Wakes the display after it's been set to sleep via [Self::sleep] /// - pub fn wake(&mut self) -> Result<(), Error> { - self.dcs.write_command(dcs::ExitSleepMode) + pub fn wake>(&mut self, delay: &mut D) -> Result<(), Error> { + self.dcs.write_command(dcs::ExitSleepMode)?; + delay.delay_us(120_000); // ST77xx have the highest wait delay of 120ms + Ok(()) } } From e15a375cced751777b526b21e5ce03202420c0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Fri, 6 Oct 2023 11:26:59 -0400 Subject: [PATCH 5/6] doc: clearer comment on wich display requires 120ms --- mipidsi/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mipidsi/src/lib.rs b/mipidsi/src/lib.rs index a41b812..4fe1e64 100644 --- a/mipidsi/src/lib.rs +++ b/mipidsi/src/lib.rs @@ -261,7 +261,8 @@ where /// pub fn sleep>(&mut self, delay: &mut D) -> Result<(), Error> { self.dcs.write_command(dcs::EnterSleepMode)?; - delay.delay_us(120_000); // All supported models requires a 120ms delay + // All supported models requires a 120ms delay before issuing other commands + delay.delay_us(120_000); Ok(()) } @@ -270,7 +271,8 @@ where /// pub fn wake>(&mut self, delay: &mut D) -> Result<(), Error> { self.dcs.write_command(dcs::ExitSleepMode)?; - delay.delay_us(120_000); // ST77xx have the highest wait delay of 120ms + // ST7789 and st7735s have the highest minimal delay of 120ms + delay.delay_us(120_000); Ok(()) } } From 6098f5661ef24ceac82843148b203060251a64d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xgroleau=F0=9F=90=A2?= Date: Fri, 6 Oct 2023 11:34:35 -0400 Subject: [PATCH 6/6] doc: Added changes in changelog --- mipidsi/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mipidsi/CHANGELOG.md b/mipidsi/CHANGELOG.md index 18b7575..85886e3 100644 --- a/mipidsi/CHANGELOG.md +++ b/mipidsi/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Added - added `GC9A01` model support +- added `Display::wake` method +- added `Display::sleep` method ## [v0.7.1] - 2023-05-24