Skip to main content

LcdText

Trait LcdText 

Source
pub trait LcdText<const W: usize, const H: usize> {
    const ADDRESS: u8;
    const WIDTH: usize = W;
    const HEIGHT: usize = H;

    // Required method
    fn write_text(&self, text: impl AsRef<str>);
}
Expand description

Platform-agnostic LCD text device contract.

Platform crates implement this trait for their generated LCD text types so shared logic can write text without knowing the hardware backend.

Design intent:

  • This trait is intended for static dispatch on embedded targets.
  • Dimensions are const generics so geometry remains compile-time.
  • write_text accepts any string-like input via AsRef<str>.

§Example: Write Text

This example writes text through a generic trait-bound helper.

use device_envoy_core::lcd_text::LcdText;

fn write_message<const W: usize, const H: usize>(lcd_text: &impl LcdText<W, H>) {
    lcd_text.write_text("Hello from\ndevice-envoy!");
}

Required Associated Constants§

Source

const ADDRESS: u8

LCD I2C address.

Provided Associated Constants§

Source

const WIDTH: usize = W

Display width in characters.

Source

const HEIGHT: usize = H

Display height in characters.

Required Methods§

Source

fn write_text(&self, text: impl AsRef<str>)

Write text to the display. See the LcdText trait documentation for usage examples.

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§