pub struct DisplayProperties<DI> { /* private fields */ }Expand description
Display properties struct
Implementations§
Source§impl<DI> DisplayProperties<DI>where
DI: WriteOnlyDataCommand,
impl<DI> DisplayProperties<DI>where
DI: WriteOnlyDataCommand,
Sourcepub fn new(
iface: DI,
display_size: DisplaySize,
display_rotation: DisplayRotation,
) -> DisplayProperties<DI>
pub fn new( iface: DI, display_size: DisplaySize, display_rotation: DisplayRotation, ) -> DisplayProperties<DI>
Create new DisplayProperties instance
Sourcepub fn init_column_mode(&mut self) -> Result<(), DisplayError>
pub fn init_column_mode(&mut self) -> Result<(), DisplayError>
Initialise the display in column mode (i.e. a byte walks down a column of 8 pixels) with column 0 on the left and column (display_width - 1) on the right.
Sourcepub fn set_draw_area(
&mut self,
start: (u8, u8),
end: (u8, u8),
) -> Result<(), DisplayError>
pub fn set_draw_area( &mut self, start: (u8, u8), end: (u8, u8), ) -> Result<(), DisplayError>
Set the position in the framebuffer of the display where any sent data should be
drawn. This method can be used for changing the affected area on the screen as well
as (re-)setting the start point of the next draw call.
Sourcepub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError>
pub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError>
Send the data to the display for drawing at the current position in the framebuffer
and advance the position accordingly. Cf. set_draw_area to modify the affected area by
this method.
Sourcepub fn get_size(&self) -> DisplaySize
pub fn get_size(&self) -> DisplaySize
Get the configured display size
Sourcepub fn get_dimensions(&self) -> (u8, u8)
pub fn get_dimensions(&self) -> (u8, u8)
Get display dimensions, taking into account the current rotation of the display
use ssd1309::prelude::*;
let mut display: GraphicsMode<_> = ssd1309::Builder::new().connect(interface).into();
assert_eq!(display.get_dimensions(), (128, 64));
let mut rotated_display: GraphicsMode<_> = ssd1309::Builder::new().with_rotation(DisplayRotation::Rotate90).connect(interface).into();
assert_eq!(rotated_display.get_dimensions(), (64, 128));Sourcepub fn get_rotation(&self) -> DisplayRotation
pub fn get_rotation(&self) -> DisplayRotation
Get the display rotation
Sourcepub fn set_rotation(
&mut self,
display_rotation: DisplayRotation,
) -> Result<(), DisplayError>
pub fn set_rotation( &mut self, display_rotation: DisplayRotation, ) -> Result<(), DisplayError>
Set the display rotation
Sourcepub fn display_on(&mut self, on: bool) -> Result<(), DisplayError>
pub fn display_on(&mut self, on: bool) -> Result<(), DisplayError>
Turn the display on or off. The display can be drawn to and retains all of its memory even while off.
Sourcepub fn set_contrast(&mut self, contrast: u8) -> Result<(), DisplayError>
pub fn set_contrast(&mut self, contrast: u8) -> Result<(), DisplayError>
Set the display contrast