Trait pwr_hd44780::Hd44780 [] [src]

pub trait Hd44780 {
    fn clear(&mut self) -> UnitResult;
fn home(&mut self) -> UnitResult;
fn move_at(&mut self, y: usize, x: usize) -> UnitResult;
fn print_char(&mut self, ch: u8) -> UnitResult;
fn set_backlight(&mut self, enabled: bool) -> UnitResult;
fn set_cursor_blinking(&mut self, enabled: bool) -> UnitResult;
fn set_cursor_visible(&mut self, enabled: bool) -> UnitResult;
fn set_text_visible(&mut self, enabled: bool) -> UnitResult;
fn create_char(&mut self, idx: u8, lines: [u8; 8]) -> UnitResult;
fn height(&self) -> usize;
fn width(&self) -> usize; fn print_char_at(&mut self, y: usize, x: usize, ch: u8) -> UnitResult { ... }
fn print<T: Into<String>>(&mut self, str: T) -> UnitResult { ... }
fn print_at<T: Into<String>>(
        &mut self,
        y: usize,
        x: usize,
        str: T
    ) -> UnitResult { ... } }

Required Methods

Clears the screen and moves cursor at (0, 0).

Moves the cursor at (0, 0).

Moves the cursor at given position.

Example

lcd.move_at(2, 2);

Errors

When passed an invalid coordinates (eg. beyond the screen), returns an error and does not update the cursor position.

Prints a single ASCII character at current cursor's position and moves the cursor. Can be used to print custom-made characters (ie. the ones created by create_char).

Example

lcd.print_char(2);

Enables / disables the backlight.

Enables / disables blinking the cursor. Blinking means that the whole character box is blinking (a whole 5x8 or 5x10 box),

Enables / disables the cursor. Visible means that only bottom of the character box is blinking (a single line).

Shows / hides the text.

Creates a custom character from given bitmap.

Each array item in given bitmap represents a single line, of which only the last 5 bits are important - rest is ignored.

idx must be from range <0, 7> (that is: only 8 custom characters are possible, that's a limit imposed by the designers of the HD44780).

When passed an invalid idx, does nothing.

Example

lcd.create_char(1, [
  0b00000000,
  0b10000000,
  0b01000000,
  0b00100000,
  0b00010000,
  0b00001000,
  0b00000100,
  0b00000010,
]);

lcd.print_char(1);

Errors

Returns an error when passed an invalid index.

Returns screen's height (number of lines).

Returns screen's width (number of characters per line).

Provided Methods

Prints a single ASCII character at given position and moves the cursor. Can be used to print custom-made characters (ie. the ones created by create_char).

Example

lcd.print_char_at(1, 0, 2);

Errors

  1. Returns an error when passed an invalid coordinates.

  2. When given character requires overflowing current line, the behaviour is undefined.

Prints a string at current cursor's position and moves the cursor.

Example

lcd.print("Hello World!");
lcd.print(format!("Hello, {}!", someone));

Errors

When given character requires overflowing current line, the behaviour is undefined.

Prints a string at given position.

Example

lcd.print_at(1, 0, "Hello World!");
lcd.print_at(2, 0, format!("Hello, {}!", someone));

Errors

  1. Returns an error when passed an invalid coordinates.

  2. When given string requires overflowing current line, the behaviour is undefined.

Implementors