Skip to main content

Panel

Trait Panel 

Source
pub trait Panel<B: DisplayBus> {
    const CMD_LEN: usize;
    const PIXEL_WRITE_CMD: [u8; 4];

    // Required methods
    fn width(&self) -> u16;
    fn height(&self) -> u16;
    async fn init<D: DelayNs>(
        &mut self,
        bus: &mut B,
        delay: D,
    ) -> Result<(), B::Error>;
    async fn set_window(
        &mut self,
        bus: &mut B,
        x0: u16,
        y0: u16,
        x1: u16,
        y1: u16,
    ) -> Result<(), DisplayError<B::Error>>;
    async fn set_color_format(
        &mut self,
        bus: &mut B,
        color_format: ColorFormat,
    ) -> Result<(), DisplayError<B::Error>>;

    // Provided methods
    fn size(&self) -> (u16, u16) { ... }
    fn x_alignment(&self) -> u16 { ... }
    fn y_alignment(&self) -> u16 { ... }
    async fn set_full_window(
        &mut self,
        bus: &mut B,
    ) -> Result<(), DisplayError<B::Error>> { ... }
    async fn check_id(
        &mut self,
        bus: &mut B,
    ) -> Result<bool, DisplayError<B::Error>>
       where B: BusRead { ... }
    async fn set_orientation(
        &mut self,
        bus: &mut B,
        orientation: Orientation,
    ) -> Result<(), DisplayError<B::Error>> { ... }
}
Expand description

A trait representing a specific display panel model (e.g., ST7789, ILI9341).

While DisplayBus handles how data is sent to the screen, this Panel trait handles what is sent. It encapsulates the specific command set and initialization sequence required by the display controller IC.

Required Associated Constants§

Source

const CMD_LEN: usize

Source

const PIXEL_WRITE_CMD: [u8; 4]

The specific command byte(s) used to initiate a pixel write operation to the display’s RAM. For many MIPI DCS compliant displays, this is 0x2C (RAMWR).

Note: We can’t use [u8; Self::CMD_LEN] in stable Rust constants yet, so we use a reference slice &PIXEL_WRITE_CMD[0..P::CMD_LEN] when using this.

Required Methods§

Source

fn width(&self) -> u16

Returns the display width, accounting for orientation.

Source

fn height(&self) -> u16

Returns the display height, accounting for orientation.

Source

async fn init<D: DelayNs>( &mut self, bus: &mut B, delay: D, ) -> Result<(), B::Error>

Initializes the panel.

Source

async fn set_window( &mut self, bus: &mut B, x0: u16, y0: u16, x1: u16, y1: u16, ) -> Result<(), DisplayError<B::Error>>

Sets the active drawing window on the display.

This method translates the abstract coordinates (x0, y0, x1, y1) into the specific “Column Address Set” and “Page Address Set” commands understood by the display controller.

Note: For some monochrome displays or AMOLED panels, coordinates must be aligned to self.x_alignment() and self.y_alignment().

Source

async fn set_color_format( &mut self, bus: &mut B, color_format: ColorFormat, ) -> Result<(), DisplayError<B::Error>>

Configures the pixel color format (e.g., RGB565, RGB888).

This updates the display controller’s interface pixel format setting to match the data being sent.

Provided Methods§

Source

fn size(&self) -> (u16, u16)

Returns the display size (width, height), accounting for orientation.

Source

fn x_alignment(&self) -> u16

Returns the X coordinate alignment requirements for this panel.

Source

fn y_alignment(&self) -> u16

Returns the Y coordinate alignment requirements for this panel.

Source

async fn set_full_window( &mut self, bus: &mut B, ) -> Result<(), DisplayError<B::Error>>

Sets the window to the full screen size.

Source

async fn check_id( &mut self, bus: &mut B, ) -> Result<bool, DisplayError<B::Error>>
where B: BusRead,

Check the panel ID (if supported).

Source

async fn set_orientation( &mut self, bus: &mut B, orientation: Orientation, ) -> Result<(), DisplayError<B::Error>>

Sets the display orientation.

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§