Struct ssd1306::Ssd1306

source ·
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§

source§

impl<DI, SIZE> Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>

source

pub fn clear_buffer(&mut self)

Clear the underlying framebuffer. You need to call disp.flush() for any effect on the screen.

source

pub fn flush(&mut self) -> Result<(), DisplayError>

Write out data to a display.

This only updates the parts of the display that have changed since the last flush.

source

pub fn set_pixel(&mut self, x: u32, y: u32, value: bool)

Turn a pixel on or off. A non-zero value is treated as on, 0 as off. If the X and Y coordinates are out of the bounds of the display, this method call is a noop.

source§

impl<DI, SIZE> Ssd1306<DI, SIZE, TerminalMode>

source

pub fn clear(&mut self) -> Result<(), TerminalModeError>

Clear the display and reset the cursor to the top left corner

source

pub fn print_char(&mut self, c: char) -> Result<(), TerminalModeError>

Print a character to the display

source

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.

source

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.

source§

impl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode>

source

pub fn clear(&mut self) -> Result<(), DisplayError>

Clear the display.

source§

impl<DI, SIZE> Ssd1306<DI, SIZE, BasicMode>

source

pub fn new(interface: DI, size: SIZE, rotation: DisplayRotation) -> Self

Create a basic SSD1306 interface.

Use the into_*_mode methods to enable more functionality.

source§

impl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE>

source

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.

source

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.

source

pub fn init_with_addr_mode( &mut self, mode: AddrMode ) -> Result<(), DisplayError>

Initialise the display in one of the available addressing modes.

source

pub fn set_addr_mode(&mut self, mode: AddrMode) -> Result<(), DisplayError>

Change the addressing mode

source

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.

source

pub fn draw(&mut self, buffer: &[u8]) -> Result<(), DisplayError>

Send a raw buffer to the display.

source

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));
source

pub fn rotation(&self) -> DisplayRotation

Get the display rotation.

source

pub fn set_rotation( &mut self, rotation: DisplayRotation ) -> Result<(), DisplayError>

Set the display rotation.

source

pub fn set_mirror(&mut self, mirror: bool) -> Result<(), DisplayError>

Set mirror enabled/disabled.

source

pub fn set_brightness( &mut self, brightness: Brightness ) -> Result<(), DisplayError>

Change the display brightness.

source

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.

source

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.

source

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.

source

pub fn set_row(&mut self, row: u8) -> Result<(), DisplayError>

Set the page address (row 8px high) in the framebuffer of the display where any sent data should be drawn.

Note that the parameter is in pixels, but the page will be set to the start of the 8px row which contains the passed-in row.

source

pub fn set_invert(&mut self, invert: bool) -> Result<(), DisplayError>

Set the screen pixel on/off inversion

source§

impl<DI, SIZE, MODE> Ssd1306<DI, SIZE, MODE>

source

pub fn reset<RST, DELAY>( &mut self, rst: &mut RST, delay: &mut DELAY ) -> Result<(), Error<Infallible, RST::Error>>
where RST: OutputPin, DELAY: DelayMs<u8>,

Reset the display.

Trait Implementations§

source§

impl<DI: Clone, SIZE: Clone, MODE: Clone> Clone for Ssd1306<DI, SIZE, MODE>

source§

fn clone(&self) -> Ssd1306<DI, SIZE, MODE>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<DI: Debug, SIZE: Debug, MODE: Debug> Debug for Ssd1306<DI, SIZE, MODE>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BasicMode>

source§

fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>

Set the display rotation.

source§

fn init(&mut self) -> Result<(), DisplayError>

Initialise in horizontal addressing mode.

§

type Error = DisplayError

Error.
source§

impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>

source§

fn set_rotation(&mut self, rot: DisplayRotation) -> Result<(), DisplayError>

Set the display rotation

This method resets the cursor but does not clear the screen.

source§

fn init(&mut self) -> Result<(), DisplayError>

Initialise and clear the display in graphics mode.

§

type Error = DisplayError

Error.
source§

impl<DI, SIZE> DisplayConfig for Ssd1306<DI, SIZE, TerminalMode>

source§

fn set_rotation( &mut self, rot: DisplayRotation ) -> Result<(), TerminalModeError>

Set the display rotation

This method resets the cursor but does not clear the screen.

source§

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

Error.
source§

impl<DI, SIZE> DrawTarget for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>

§

type Color = BinaryColor

The pixel color type the targetted display supports.
§

type Error = DisplayError

Error type to return when a drawing operation fails. Read more
source§

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
source§

fn clear(&mut self, color: Self::Color) -> Result<(), Self::Error>

Fill the entire display with a solid color. Read more
source§

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
source§

fn fill_solid( &mut self, area: &Rectangle, color: Self::Color ) -> Result<(), Self::Error>

Fill a given area with a solid color. Read more
source§

impl<DI, SIZE> OriginDimensions for Ssd1306<DI, SIZE, BufferedGraphicsMode<SIZE>>

source§

fn size(&self) -> Size

Returns the size of the bounding box.
source§

impl<DI, SIZE> Write for Ssd1306<DI, SIZE, TerminalMode>

source§

fn write_str(&mut self, s: &str) -> Result<(), Error>

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> Dimensions for T

source§

fn bounding_box(&self) -> Rectangle

Returns the bounding box.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.