Skip to main content

ScreenARGB8888ToMono8BitPage

Struct ScreenARGB8888ToMono8BitPage 

Source
pub struct ScreenARGB8888ToMono8BitPage<'a, S: Screen<'a>> { /* private fields */ }
Expand description

Expose an underlying ARGB8888-formatted screen as a Mono VLSB (a.k.a. Mono_8BitPage) screen of the same resolution.

§Mono VLSB source layout

Mono VLSB packs 8 vertically-adjacent pixels into a single byte, from top to bottom, grouped into width-sized “pages”, from left to right. A page is a row of width N and height 8 pixels, formed by N successive bytes. So, bit k of byte col + (row / 8) * width is the pixel at (col, row-within-frame row).

For a write frame of height h, the source needs width * ceil(h / 8) bytes; if the height is not a multiple of 8, the high bits of each column in the last page are unused.

§ARGB8888 output layout

One pixel per four bytes, in byte order [A, R, G, B] with A = 0xFF.

§Chunking and draw-buffer sizing

The Screen HIL allows large writes to be split across multiple write(_, continue_write=true) calls. This adapter accepts any chunk size (in Mono VLSB bytes); internally it processes one sub-rectangle at a time on the underlying screen, so the draw buffer only needs to hold one sub-op’s ARGB output. A larger draw buffer lets one client write be satisfied in fewer underlying set_write_frame + write round-trips (at most one per full-width page held by the buffer) at the cost of more static RAM.

The buffer must be able to hold at least one row of the widest sub-op the adapter will ever emit — i.e. one row of the client’s write-frame width (frame.width * 4 bytes). Boards that expect full-width writes should size it to at least resource_width * 8 * 4 (one full-width page) so head/tail partial sub-ops always fit in a single underlying write.

Implementations§

Source§

impl<'a, S: Screen<'a>> ScreenARGB8888ToMono8BitPage<'a, S>

Source

pub fn new(screen: &'a S, draw_buffer: &'static mut [u8]) -> Self

Trait Implementations§

Source§

impl<'a, S: Screen<'a>> Screen<'a> for ScreenARGB8888ToMono8BitPage<'a, S>

Source§

fn set_client(&self, client: &'a dyn ScreenClient)

Set the object to receive the asynchronous command callbacks.
Source§

fn get_resolution(&self) -> (usize, usize)

Get a tuple (width, height) with the current resolution (in pixels). Read more
Source§

fn get_pixel_format(&self) -> ScreenPixelFormat

Get the current pixel format. Read more
Source§

fn get_rotation(&self) -> ScreenRotation

Get the current rotation. Read more
Source§

fn set_write_frame( &self, x: usize, y: usize, width: usize, height: usize, ) -> Result<(), ErrorCode>

Sets the write frame. Read more
Source§

fn write( &self, buffer: SubSliceMut<'static, u8>, continue_write: bool, ) -> Result<(), ErrorCode>

Write data from buffer to the selected write frame. Read more
Source§

fn set_brightness(&self, brightness: u16) -> Result<(), ErrorCode>

Set the display brightness value. Read more
Source§

fn set_power(&self, enabled: bool) -> Result<(), ErrorCode>

Controls the screen power supply. Read more
Source§

fn set_invert(&self, enabled: bool) -> Result<(), ErrorCode>

Controls the color inversion mode. Read more
Source§

impl<'a, S: Screen<'a>> ScreenClient for ScreenARGB8888ToMono8BitPage<'a, S>

Source§

fn screen_is_ready(&self)

Some screens need some time to start, this function is called when the screen is ready.
Source§

fn command_complete(&self, result: Result<(), ErrorCode>)

The screen will call this function to notify that a command (except write) has finished.
Source§

fn write_complete( &self, buffer: SubSliceMut<'static, u8>, result: Result<(), ErrorCode>, )

The screen will call this function to notify that the write command has finished. This is different from command_complete as it has to pass back the write buffer

Auto Trait Implementations§

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> 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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.