Skip to content

Commit

Permalink
Add support to turn off the display
Browse files Browse the repository at this point in the history
  • Loading branch information
zargony committed Aug 10, 2024
1 parent 5254aec commit 268d70f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion firmware/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*;
use embedded_graphics::text::{Alignment, Text};
use embedded_hal::i2c::I2c;
use log::info;
use log::{debug, info};
use ssd1306::mode::{BufferedGraphicsMode, DisplayConfig};
use ssd1306::prelude::I2CInterface;
use ssd1306::rotation::DisplayRotation;
Expand Down Expand Up @@ -44,10 +44,19 @@ impl<I2C: I2c> Display<I2C> {
Ok(Display { driver })
}

/// Turn display off
#[allow(dead_code)]
pub fn turn_off(&mut self) -> Result<(), Error> {
debug!("Display: Power off");
self.driver.set_display_on(false)?;
Ok(())
}

/// Clear display
pub fn clear(&mut self) -> Result<(), Error> {
self.driver.clear(BinaryColor::Off)?;
self.driver.flush()?;
self.driver.set_display_on(true)?;
Ok(())
}

Expand Down Expand Up @@ -76,6 +85,7 @@ impl<I2C: I2c> Display<I2C> {
)
.draw(&mut self.driver)?;
self.driver.flush()?;
self.driver.set_display_on(true)?;
Ok(())
}

Expand All @@ -92,6 +102,7 @@ impl<I2C: I2c> Display<I2C> {
)
.draw(&mut self.driver)?;
self.driver.flush()?;
self.driver.set_display_on(true)?;
Ok(())
}
}

0 comments on commit 268d70f

Please sign in to comment.