pub trait Screen<'a> {
// Required methods
fn set_client(&self, client: &'a dyn ScreenClient);
fn get_resolution(&self) -> (usize, usize);
fn get_pixel_format(&self) -> ScreenPixelFormat;
fn get_rotation(&self) -> ScreenRotation;
fn set_write_frame(
&self,
x: usize,
y: usize,
width: usize,
height: usize,
) -> Result<(), ErrorCode>;
fn write(
&self,
buffer: SubSliceMut<'static, u8>,
continue_write: bool,
) -> Result<(), ErrorCode>;
fn set_brightness(&self, brightness: u16) -> Result<(), ErrorCode>;
fn set_power(&self, enabled: bool) -> Result<(), ErrorCode>;
fn set_invert(&self, enabled: bool) -> Result<(), ErrorCode>;
}
Expand description
Basic interface for screens.
Required Methods§
Sourcefn set_client(&self, client: &'a dyn ScreenClient)
fn set_client(&self, client: &'a dyn ScreenClient)
Set the object to receive the asynchronous command callbacks.
Sourcefn get_resolution(&self) -> (usize, usize)
fn get_resolution(&self) -> (usize, usize)
Get a tuple (width, height)
with the current resolution (in pixels).
This function is synchronous as the driver should know this value without requesting it from the screen.
Note that width and height may change due to rotation.
Sourcefn get_pixel_format(&self) -> ScreenPixelFormat
fn get_pixel_format(&self) -> ScreenPixelFormat
Get the current pixel format.
This function is synchronous as the driver should know this value without requesting it from the screen.
Sourcefn get_rotation(&self) -> ScreenRotation
fn get_rotation(&self) -> ScreenRotation
Get the current rotation.
This function is synchronous as the driver should know this value without requesting it from the screen.
Sourcefn set_write_frame(
&self,
x: usize,
y: usize,
width: usize,
height: usize,
) -> Result<(), ErrorCode>
fn set_write_frame( &self, x: usize, y: usize, width: usize, height: usize, ) -> Result<(), ErrorCode>
Sets the write frame.
This function has to be called before the first call to the write
function. This will generate a command_complete()
callback when
finished.
Return values:
Ok(())
: The write frame is valid.INVAL
: The parameters of the write frame are not valid.BUSY
: Unable to set the write frame on the device.
Sourcefn write(
&self,
buffer: SubSliceMut<'static, u8>,
continue_write: bool,
) -> Result<(), ErrorCode>
fn write( &self, buffer: SubSliceMut<'static, u8>, continue_write: bool, ) -> Result<(), ErrorCode>
Write data from buffer
to the selected write frame.
When finished, the driver will call the write_complete()
callback.
This function can be called multiple times if the write frame is larger
than the size of the available buffer by setting continue_write
to
true
. If continue_write
is false, the buffer write position will be
reset before the data are written.
Return values:
Ok(())
: Write is valid and will be sent to the screen.SIZE
: The buffer is too long for the selected write frame.BUSY
: Another write is in progress.
Sourcefn set_brightness(&self, brightness: u16) -> Result<(), ErrorCode>
fn set_brightness(&self, brightness: u16) -> Result<(), ErrorCode>
Set the display brightness value.
Depending on the display, this may not cause any actual changes
until and unless power is enabled (see set_power
).
The following values must be supported:
- 0: completely no light emitted
- 1..65536: set brightness to the given level
The display should interpret the brightness value as lightness (each increment should change perceived brightness the same). 1 shall be the minimum supported brightness, 65536 is the maximum brightness. Values in between should approximate the intermediate values; minimum and maximum included (e.g. when there is only 1 level).
Sourcefn set_power(&self, enabled: bool) -> Result<(), ErrorCode>
fn set_power(&self, enabled: bool) -> Result<(), ErrorCode>
Controls the screen power supply.
Use it to initialize the display device.
For screens where display needs nonzero brightness (e.g. LED), this
shall set brightness to a default value if set_brightness
was not
called first.
The device may implement power independently from brightness, so call
set_brightness
to turn on/off the module completely.
To allow starting in the correct configuration, the driver is allowed to
cache values like brightness or invert mode and apply them together when
power is enabled. If the display cannot use selected configuration, this
call returns INVAL
.
When finished, calls ScreenClient::screen_is_ready
, both when power
is enabled and disabled.
Sourcefn set_invert(&self, enabled: bool) -> Result<(), ErrorCode>
fn set_invert(&self, enabled: bool) -> Result<(), ErrorCode>
Controls the color inversion mode.
Pixels already in the frame buffer, as well as newly submitted, will be
inverted. What that means depends on the current pixel format. May get
disabled when switching to another pixel format. Returns NOSUPPORT
if
the device does not accelerate color inversion. Returns INVAL
if the
current pixel format does not support color inversion.