From 071a014ac166cd25b3cf7315c643026a26e712cf Mon Sep 17 00:00:00 2001 From: Wesley Moore Date: Wed, 14 Nov 2018 15:35:10 +1100 Subject: [PATCH] Implement deep_sleep on Display --- src/command.rs | 8 ++++---- src/display.rs | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/command.rs b/src/command.rs index a98e4c3..e0bf611 100644 --- a/src/command.rs +++ b/src/command.rs @@ -45,9 +45,9 @@ pub enum DeepSleepMode { /// Not sleeping Normal, /// Deep sleep with RAM preserved - Mode1, + PreserveRAM, /// Deep sleep RAM not preserved - Mode2, + DiscardRAM, } pub enum Command { @@ -233,8 +233,8 @@ impl Command { DeepSleepMode(mode) => { let mode = match mode { self::DeepSleepMode::Normal => 0b00, - self::DeepSleepMode::Mode1 => 0b01, - self::DeepSleepMode::Mode2 => 0b11, + self::DeepSleepMode::PreserveRAM => 0b01, + self::DeepSleepMode::DiscardRAM => 0b11, }; pack!(buf, 0x10, [mode]) diff --git a/src/display.rs b/src/display.rs index da6ca6d..56d5749 100644 --- a/src/display.rs +++ b/src/display.rs @@ -1,6 +1,6 @@ use hal; -use command::{BufCommand, Command, DataEntryMode, IncrementAxis}; +use command::{BufCommand, Command, DataEntryMode, DeepSleepMode, IncrementAxis}; use interface::DisplayInterface; // Max display resolution is 160x296 @@ -90,7 +90,6 @@ impl Display where I: DisplayInterface { } fn deep_sleep(&mut self) -> Result<(), I::Error> { - // TODO: Send DeepSleep command - unimplemented!() + Command::DeepSleepMode(DeepSleepMode::PreserveRAM).execute(&mut self.interface) } }