pub struct Ssd1306<DI, SIZE, MODE> { /* private fields */ }
Expand description
SSD1306 driver.
Note that some methods are only available when the display is configured in a certain mode
.
Implementations
sourceimpl<DI, SIZE> Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourceimpl<DI, SIZE> Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
impl<DI, SIZE> Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
sourcepub fn clear(&mut self) -> Result<(), TerminalModeError>
pub fn clear(&mut self) -> Result<(), TerminalModeError>
Clear the display and reset the cursor to the top left corner
sourcepub fn print_char(&mut self, c: char) -> Result<(), TerminalModeError>
pub fn print_char(&mut self, c: char) -> Result<(), TerminalModeError>
Print a character to the display
sourcepub fn position(&self) -> Result<(u8, u8), TerminalModeError>
pub fn position(&self) -> Result<(u8, u8), TerminalModeError>
Get the current cursor position, in character coordinates. This is the (column, row) that the next character will be written to.
sourcepub fn set_position(
&mut self,
column: u8,
row: u8
) -> Result<(), TerminalModeError>
pub fn set_position(
&mut self,
column: u8,
row: u8
) -> Result<(), TerminalModeError>
Set the cursor position, in character coordinates. This is the (column, row) that the next character will be written to. If the position is out of bounds, an Err will be returned.
sourceimpl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourcepub fn clear(&mut self) -> Result<(), DisplayError>
pub fn clear(&mut self) -> Result<(), DisplayError>
Clear the display.
sourceimpl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourcepub fn new(interface: DI, size: SIZE, rotation: DisplayRotation) -> Self
pub fn new(interface: DI, size: SIZE, rotation: DisplayRotation) -> Self
Create a basic SSD1306 interface.
Use the into_*_mode
methods to enable more functionality.
sourceimpl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourcepub fn into_buffered_graphics_mode(
self
) -> Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>
pub fn into_buffered_graphics_mode(
self
) -> Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>
Convert the display into a buffered graphics mode, supporting embedded-graphics.
See BufferedGraphicsMode for more information.
sourcepub fn into_terminal_mode(self) -> Ssd1306<DI, SIZE, TerminalMode>
pub fn into_terminal_mode(self) -> Ssd1306<DI, SIZE, TerminalMode>
Convert the display into a text-only, terminal-like mode.
See TerminalMode for more information.
sourcepub fn init_with_addr_mode(&mut self, mode: AddrMode) -> Result<(), DisplayError>
pub fn init_with_addr_mode(&mut self, mode: AddrMode) -> Result<(), DisplayError>
Initialise the display in one of the available addressing modes.
sourcepub fn set_addr_mode(&mut self, mode: AddrMode) -> Result<(), DisplayError>
pub fn set_addr_mode(&mut self, mode: AddrMode) -> Result<(), DisplayError>
Change the addressing mode
sourcepub fn bounded_draw(
&mut self,
buffer: &[u8],
disp_width: usize,
upper_left: (u8, u8),
lower_right: (u8, u8)
) -> Result<(), DisplayError>
pub fn bounded_draw(
&mut self,
buffer: &[u8],
disp_width: usize,
upper_left: (u8, u8),
lower_right: (u8, 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.
This method takes advantage of a bounding box for faster writes.
sourcepub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError>
pub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError>
Send a raw buffer to the display.
sourcepub fn dimensions(&self) -> (u8, u8)
pub fn dimensions(&self) -> (u8, u8)
Get display dimensions, taking into account the current rotation of the display
use ssd1306::{mode::TerminalMode, prelude::*, Ssd1306};
let mut display = Ssd1306::new(
interface,
DisplaySize128x64,
DisplayRotation::Rotate0,
).into_terminal_mode();
assert_eq!(display.dimensions(), (128, 64));
let mut rotated_display = Ssd1306::new(
interface,
DisplaySize128x64,
DisplayRotation::Rotate90,
).into_terminal_mode();
assert_eq!(rotated_display.dimensions(), (64, 128));
sourcepub fn rotation(&self) -> DisplayRotation
pub fn rotation(&self) -> DisplayRotation
Get the display rotation.
sourcepub fn set_rotation(
&mut self,
rotation: DisplayRotation
) -> Result<(), DisplayError>
pub fn set_rotation(
&mut self,
rotation: DisplayRotation
) -> Result<(), DisplayError>
Set the display rotation.
sourcepub fn set_mirror(&mut self, mirror: bool) -> Result<(), DisplayError>
pub fn set_mirror(&mut self, mirror: bool) -> Result<(), DisplayError>
Set mirror enabled/disabled.
sourcepub fn set_brightness(
&mut self,
brightness: Brightness
) -> Result<(), DisplayError>
pub fn set_brightness(
&mut self,
brightness: Brightness
) -> Result<(), DisplayError>
Change the display brightness.
sourcepub fn set_display_on(&mut self, on: bool) -> Result<(), DisplayError>
pub fn set_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_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 limiting 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 set_column(&mut self, column: u8) -> Result<(), DisplayError>
pub fn set_column(&mut self, column: u8) -> Result<(), DisplayError>
Set the column address in the framebuffer of the display where any sent data should be drawn.
sourceimpl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE>
impl<SPI, DC, SIZE, MODE> Ssd1306<SPIInterfaceNoCS<SPI, DC>, SIZE, MODE>
Trait Implementations
sourceimpl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BasicMode> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourcefn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>
fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>
Set the display rotation.
sourcefn init(&mut self) -> Result<(), DisplayError>
fn init(&mut self) -> Result<(), DisplayError>
Initialise in horizontal addressing mode.
type Error = DisplayError
type Error = DisplayError
Error.
sourceimpl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourcefn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>
fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>
Set the display rotation
This method resets the cursor but does not clear the screen.
sourcefn init(&mut self) -> Result<(), DisplayError>
fn init(&mut self) -> Result<(), DisplayError>
Initialise and clear the display in graphics mode.
type Error = DisplayError
type Error = DisplayError
Error.
sourceimpl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
sourcefn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), TerminalModeError>
fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), TerminalModeError>
Set the display rotation
This method resets the cursor but does not clear the screen.
sourcefn init(&mut self) -> Result<(), TerminalModeError>
fn init(&mut self) -> Result<(), TerminalModeError>
Initialise the display in page mode (i.e. a byte walks down a column of 8 pixels) with column 0 on the left and column (SIZE::Width::U8 - 1) on the right, but no automatic line wrapping.
type Error = TerminalModeError
type Error = TerminalModeError
Error.
sourceimpl<DI, SIZE> DrawTarget for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> DrawTarget for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
type Color = BinaryColor
type Color = BinaryColor
The pixel color type the targetted display supports.
type Error = DisplayError
type Error = DisplayError
Error type to return when a drawing operation fails. Read more
sourcefn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error> where
I: IntoIterator<Item = Pixel<Self::Color>>,
fn draw_iter<I>(&mut self, pixels: I) -> Result<(), Self::Error> where
I: IntoIterator<Item = Pixel<Self::Color>>,
Draw individual pixels to the display without a defined order. Read more
sourcefn fill_contiguous<I>(
&mut self,
area: &Rectangle,
colors: I
) -> Result<(), Self::Error> where
I: IntoIterator<Item = Self::Color>,
fn fill_contiguous<I>(
&mut self,
area: &Rectangle,
colors: I
) -> Result<(), Self::Error> where
I: IntoIterator<Item = Self::Color>,
Fill a given area with an iterator providing a contiguous stream of pixel colors. Read more
sourceimpl<DI, SIZE> OriginDimensions for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
impl<DI, SIZE> OriginDimensions for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>> where
DI: WriteOnlyDataCommand,
SIZE: DisplaySize,
sourceimpl<DI, SIZE> Write for Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
impl<DI, SIZE> Write for Ssd1306<DI, SIZE, TerminalMode> where
DI: WriteOnlyDataCommand,
SIZE: TerminalDisplaySize,
impl<DI: Copy, SIZE: Copy, MODE: Copy> Copy for Ssd1306<DI, SIZE, MODE>
Auto Trait Implementations
impl<DI, SIZE, MODE> RefUnwindSafe for Ssd1306<DI, SIZE, MODE> where
DI: RefUnwindSafe,
MODE: RefUnwindSafe,
SIZE: RefUnwindSafe,
impl<DI, SIZE, MODE> Send for Ssd1306<DI, SIZE, MODE> where
DI: Send,
MODE: Send,
SIZE: Send,
impl<DI, SIZE, MODE> Sync for Ssd1306<DI, SIZE, MODE> where
DI: Sync,
MODE: Sync,
SIZE: Sync,
impl<DI, SIZE, MODE> Unpin for Ssd1306<DI, SIZE, MODE> where
DI: Unpin,
MODE: Unpin,
SIZE: Unpin,
impl<DI, SIZE, MODE> UnwindSafe for Ssd1306<DI, SIZE, MODE> where
DI: UnwindSafe,
MODE: UnwindSafe,
SIZE: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CheckedAs for T
impl<T> CheckedAs for T
sourcefn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst> where
T: CheckedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dst where
Src: CheckedCast<Dst>,
sourcefn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
sourceimpl<T> Dimensions for T where
T: OriginDimensions,
impl<T> Dimensions for T where
T: OriginDimensions,
sourcefn bounding_box(&self) -> Rectangle
fn bounding_box(&self) -> Rectangle
Returns the bounding box.
sourceimpl<T> OverflowingAs for T
impl<T> OverflowingAs for T
sourcefn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool) where
T: OverflowingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dst where
Src: OverflowingCast<Dst>,
sourcefn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
OverflowingCasts the value.
sourceimpl<T> SaturatingAs for T
impl<T> SaturatingAs for T
sourcefn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dst where
T: SaturatingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dst where
Src: SaturatingCast<Dst>,
sourcefn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
sourceimpl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
sourcefn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dst where
T: UnwrappedCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dst where
Src: UnwrappedCast<Dst>,
sourcefn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
UnwrappedCasts the value.
sourceimpl<T> WrappingAs for T
impl<T> WrappingAs for T
sourcefn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dst where
T: WrappingCast<Dst>,
Casts the value.
sourceimpl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dst where
Src: WrappingCast<Dst>,
sourcefn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
WrappingCasts the value.