Skip to main content

Display

Trait Display 

Source
pub trait Display: DrawTarget {
    // Required methods
    fn buffer(&self) -> &[u8];
    fn get_mut_buffer(&mut self) -> &mut [u8];
    fn set_rotation(&mut self, rotation: DisplayRotation);
    fn rotation(&self) -> DisplayRotation;
    fn is_inverted(&self) -> bool;

    // Provided methods
    fn clear_buffer(&mut self, background_color: Color) { ... }
    fn draw_helper(
        &mut self,
        width: u32,
        height: u32,
        pixel: Pixel<BinaryColor>,
    ) -> Result<(), Self::Error> { ... }
}
Expand description

Necessary traits for all displays to implement for drawing

Adds support for:

  • Drawing (With the help of DrawTarget/Embedded Graphics)
  • Rotations
  • Clearing

Required Methods§

Source

fn buffer(&self) -> &[u8]

Returns the buffer

Source

fn get_mut_buffer(&mut self) -> &mut [u8]

Returns a mutable buffer

Source

fn set_rotation(&mut self, rotation: DisplayRotation)

Sets the rotation of the display

Source

fn rotation(&self) -> DisplayRotation

Get the current rotation of the display

Source

fn is_inverted(&self) -> bool

If the color for this display is inverted

Provided Methods§

Source

fn clear_buffer(&mut self, background_color: Color)

Clears the buffer of the display with the chosen background color

Source

fn draw_helper( &mut self, width: u32, height: u32, pixel: Pixel<BinaryColor>, ) -> Result<(), Self::Error>

Helper function for the Embedded Graphics draw trait

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§