diff --git a/CHANGELOG.md b/CHANGELOG.md index d413b5a..bb34a40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ with the [embedded-hal](crates.io/crates/embedded-hal) traits for maximum portab ## [Unreleased] - ReleaseDate +### Added + +- [#20](https://github.com/jamwaffles/sh1106/pull/20) Add `set_contrast` method to set the display contrast/brightness. + ## [0.3.1] - 2020-03-21 ### Fixed diff --git a/src/mode/graphics.rs b/src/mode/graphics.rs index 32a6223..e624466 100644 --- a/src/mode/graphics.rs +++ b/src/mode/graphics.rs @@ -160,6 +160,11 @@ where pub fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DI::Error> { self.properties.set_rotation(rot) } + + /// Set the display contrast + pub fn set_contrast(&mut self, contrast: u8) -> Result<(), DI::Error> { + self.properties.set_contrast(contrast) + } } #[cfg(feature = "graphics")] diff --git a/src/properties.rs b/src/properties.rs index 73b1533..54e7e73 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -187,4 +187,9 @@ where } } } + + /// Set the display contrast + pub fn set_contrast(&mut self, contrast: u8) -> Result<(), DI::Error> { + Command::Contrast(contrast).send(&mut self.iface) + } }