lcd_1602_i2c

Struct Lcd

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

Source

pub fn new<D>( i2c: I, address: u8, rgb_address: u8, delay: &mut D, ) -> Result<Self, <I as Write>::Error>
where D: DelayMs<u16>,

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.

Source

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.

Source

pub fn set_cursor_position( &mut self, x: u8, y: u8, ) -> Result<(), <I as Write>::Error>

Set the position of the cursor

§Errors

Returns a Result that will report I2C errors, if any.

Source

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.

Source

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.

Turns on the blinking block cursor

§Errors

Returns a Result that will report I2C errors, if any.

Source

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.

Source

pub fn write_str(&mut self, s: &str) -> Result<(), <I as Write>::Error>

Adds a string 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.

Source

pub fn set_rgb( &mut self, r: u8, g: u8, b: u8, ) -> Result<(), <I as Write>::Error>

Set the color of the backlight for displays that have an RGB backlight.

§Errors

Returns a Result that will report I2C errors, if any.

Auto Trait Implementations§

§

impl<I> Freeze for Lcd<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for Lcd<I>
where I: RefUnwindSafe,

§

impl<I> Send for Lcd<I>
where I: Send,

§

impl<I> Sync for Lcd<I>
where I: Sync,

§

impl<I> Unpin for Lcd<I>
where I: Unpin,

§

impl<I> UnwindSafe for Lcd<I>
where I: UnwindSafe,

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.