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
fn clear(&mut self) -> UnitResult
Clears the screen and moves cursor at (0, 0).
fn home(&mut self) -> UnitResult
Moves the cursor at (0, 0).
fn move_at(&mut self, y: usize, x: usize) -> UnitResult
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.
fn print_char(&mut self, ch: u8) -> UnitResult
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);
fn set_backlight(&mut self, enabled: bool) -> UnitResult
Enables / disables the backlight.
fn set_cursor_blinking(&mut self, enabled: bool) -> UnitResult
Enables / disables blinking the cursor.
Blinking
means that the whole character box is blinking (a whole 5x8 or 5x10 box),
fn set_cursor_visible(&mut self, enabled: bool) -> UnitResult
Enables / disables the cursor.
Visible
means that only bottom of the character box is blinking (a single line).
fn set_text_visible(&mut self, enabled: bool) -> UnitResult
Shows / hides the text.
fn create_char(&mut self, idx: u8, lines: [u8; 8]) -> UnitResult
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.
fn height(&self) -> usize
Returns screen's height (number of lines).
fn width(&self) -> usize
Returns screen's width (number of characters per line).
Provided Methods
fn print_char_at(&mut self, y: usize, x: usize, ch: u8) -> UnitResult
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
-
Returns an error when passed an invalid coordinates.
-
When given character requires overflowing current line, the behaviour is undefined.
fn print<T: Into<String>>(&mut self, str: T) -> UnitResult
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.
fn print_at<T: Into<String>>(
&mut self,
y: usize,
x: usize,
str: T
) -> UnitResult
&mut self,
y: usize,
x: usize,
str: T
) -> UnitResult