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 b3ae465
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 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,18 @@ impl<I2C: I2c> Display<I2C> {
Ok(Display { driver })
}

/// Turn display off
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 +84,7 @@ impl<I2C: I2c> Display<I2C> {
)
.draw(&mut self.driver)?;
self.driver.flush()?;
self.driver.set_display_on(true)?;
Ok(())
}

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

0 comments on commit b3ae465

Please sign in to comment.