pub trait DisplayDriver: 'static {
type Color: PixelColor;
type Display: DrawTarget<Color = Self::Color>;
// Required method
fn draw_target(&mut self) -> &mut Self::Display;
// Provided methods
async fn init(&mut self) -> Result<(), DisplayError> { ... }
async fn flush(&mut self) -> Result<(), DisplayError> { ... }
async fn clear(&mut self) -> Result<(), DisplayError> { ... }
async fn set_brightness(
&mut self,
_brightness: u8,
) -> Result<(), DisplayError> { ... }
async fn set_display_on(&mut self, on: bool) -> Result<(), DisplayError> { ... }
}Expand description
Interface for display drivers.
TODO: Allow sync-only drivers?
Required Associated Types§
type Color: PixelColor
type Display: DrawTarget<Color = Self::Color>
Required Methods§
fn draw_target(&mut self) -> &mut Self::Display
Provided Methods§
Sourceasync fn init(&mut self) -> Result<(), DisplayError>
async fn init(&mut self) -> Result<(), DisplayError>
Called when the display is initialized.
It is guaranteed that:
- No other function is called before this function.
- If this function returns an error, other functions will not be called.
Default implementation returns Ok(()).
async fn flush(&mut self) -> Result<(), DisplayError>
Sourceasync fn clear(&mut self) -> Result<(), DisplayError>
async fn clear(&mut self) -> Result<(), DisplayError>
Clear the display.
Sourceasync fn set_brightness(&mut self, _brightness: u8) -> Result<(), DisplayError>
async fn set_brightness(&mut self, _brightness: u8) -> Result<(), DisplayError>
Sets brightness of the display.
0 is off, 255 is full brightness.
async fn set_display_on(&mut self, on: bool) -> Result<(), DisplayError>
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.
RKTK API Docs