pub struct Lcd<I>where
I: Write,{ /* private fields */ }
Expand description
Handles all the logic related to working with the character LCD via I2C. You’ll
need to create an instance of this with the new()
method.
The I
generic type needs to implement the embedded_hal::blocking::Write
trait.
Implementations§
Source§impl<I> Lcd<I>where
I: Write,
impl<I> Lcd<I>where
I: Write,
Sourcepub fn new<D>(
i2c: I,
address: u8,
rgb_address: u8,
delay: &mut D,
) -> Result<Self, <I as Write>::Error>
pub fn new<D>( i2c: I, address: u8, rgb_address: u8, delay: &mut D, ) -> Result<Self, <I as Write>::Error>
Creates a new instance of the display object.
§Example
let lcd = Lcd::new(i2c_bus, address, rgb_address, &mut delay);
i2c
needs to implement the embedded_hal::blocking::Write
trait.
delay
needs to implement the embedded_hal::blocking::delay::DelayMs
trait.
§Errors
The I2C library will return an error if it’s not able to write to the device.
This is always a trait of type embedded_hal::blocking::Write::Error
that
is implemented by the I2C instance.
Sourcepub fn clear(
&mut self,
delay: &mut dyn DelayMs<u16>,
) -> Result<(), <I as Write>::Error>
pub fn clear( &mut self, delay: &mut dyn DelayMs<u16>, ) -> Result<(), <I as Write>::Error>
Clear the display. The LCD display driver requires a 2ms delay after clearing, which
is why this method requires a delay
object.
§Errors
Returns a Result
that will report I2C errors, if any.
Sourcepub fn set_display(
&mut self,
display: LcdDisplay,
) -> Result<(), <I as Write>::Error>
pub fn set_display( &mut self, display: LcdDisplay, ) -> Result<(), <I as Write>::Error>
Control whether the display is on or off
§Errors
Returns a Result
that will report I2C errors, if any.
Sourcepub fn set_cursor(&mut self, cursor: Cursor) -> Result<(), <I as Write>::Error>
pub fn set_cursor(&mut self, cursor: Cursor) -> Result<(), <I as Write>::Error>
Sets the visiblity of the cursor, which is a non-blinking _
§Errors
Returns a Result
that will report I2C errors, if any.
Sourcepub fn write_char(&mut self, char: char) -> Result<(), <I as Write>::Error>
pub fn write_char(&mut self, char: char) -> Result<(), <I as Write>::Error>
Adds a single character to the current position. The cursor will advance after this call to the next column
§Errors
Returns a Result
that will report I2C errors, if any.