pub struct HD44780<B: DataBus> { /* private fields */ }Implementations§
Source§impl<RS: OutputPin, EN: OutputPin, D0: OutputPin, D1: OutputPin, D2: OutputPin, D3: OutputPin, D4: OutputPin, D5: OutputPin, D6: OutputPin, D7: OutputPin> HD44780<EightBitBus<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>>
impl<RS: OutputPin, EN: OutputPin, D0: OutputPin, D1: OutputPin, D2: OutputPin, D3: OutputPin, D4: OutputPin, D5: OutputPin, D6: OutputPin, D7: OutputPin> HD44780<EightBitBus<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>>
Sourcepub fn new_8bit<D: DelayUs<u16> + DelayMs<u8>>(
rs: RS,
en: EN,
d0: D0,
d1: D1,
d2: D2,
d3: D3,
d4: D4,
d5: D5,
d6: D6,
d7: D7,
delay: &mut D,
) -> Result<HD44780<EightBitBus<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>>>
pub fn new_8bit<D: DelayUs<u16> + DelayMs<u8>>( rs: RS, en: EN, d0: D0, d1: D1, d2: D2, d3: D3, d4: D4, d5: D5, d6: D6, d7: D7, delay: &mut D, ) -> Result<HD44780<EightBitBus<RS, EN, D0, D1, D2, D3, D4, D5, D6, D7>>>
Create an instance of a HD44780 from 8 data pins, a register select
pin, an enable pin and a struct implementing the delay trait.
- The delay instance is used to sleep between commands to
ensure the
HD44780has enough time to process commands. - The eight db0..db7 pins are used to send and recieve with
the
HD44780. - The register select pin is used to tell the
HD44780if incoming data is a command or data. - The enable pin is used to tell the
HD44780that there is data on the 8 data pins and that it should read them in.
Source§impl<RS: OutputPin, EN: OutputPin, D4: OutputPin, D5: OutputPin, D6: OutputPin, D7: OutputPin> HD44780<FourBitBus<RS, EN, D4, D5, D6, D7>>
impl<RS: OutputPin, EN: OutputPin, D4: OutputPin, D5: OutputPin, D6: OutputPin, D7: OutputPin> HD44780<FourBitBus<RS, EN, D4, D5, D6, D7>>
Sourcepub fn new_4bit<D: DelayUs<u16> + DelayMs<u8>>(
rs: RS,
en: EN,
d4: D4,
d5: D5,
d6: D6,
d7: D7,
delay: &mut D,
) -> Result<HD44780<FourBitBus<RS, EN, D4, D5, D6, D7>>>
pub fn new_4bit<D: DelayUs<u16> + DelayMs<u8>>( rs: RS, en: EN, d4: D4, d5: D5, d6: D6, d7: D7, delay: &mut D, ) -> Result<HD44780<FourBitBus<RS, EN, D4, D5, D6, D7>>>
Create an instance of a HD44780 from 4 data pins, a register select
pin, an enable pin and a struct implementing the delay trait.
- The delay instance is used to sleep between commands to
ensure the
HD44780has enough time to process commands. - The four db0..db3 pins are used to send and recieve with
the
HD44780. - The register select pin is used to tell the
HD44780if incoming data is a command or data. - The enable pin is used to tell the
HD44780that there is data on the 4 data pins and that it should read them in.
This mode operates differently than 8 bit mode by using 4 less pins for data, which is nice on devices with less I/O although the I/O takes a ‘bit’ longer
Instead of commands being sent byte by byte each command is broken up into it’s upper and lower nibbles (4 bits) before being sent over the data bus
Source§impl<I2C: Write> HD44780<I2CBus<I2C>>
impl<I2C: Write> HD44780<I2CBus<I2C>>
Sourcepub fn new_i2c<D: DelayUs<u16> + DelayMs<u8>>(
i2c_bus: I2C,
address: u8,
delay: &mut D,
) -> Result<HD44780<I2CBus<I2C>>>
pub fn new_i2c<D: DelayUs<u16> + DelayMs<u8>>( i2c_bus: I2C, address: u8, delay: &mut D, ) -> Result<HD44780<I2CBus<I2C>>>
Create an instance of a HD44780 from an i2c write peripheral,
the HD44780 I2C address and a struct implementing the delay trait.
- The delay instance is used to sleep between commands to
ensure the
HD44780has enough time to process commands. - The i2c peripheral is used to send data to the
HD44780and to set its register select and enable pins.
This mode operates on an I2C bus, using an I2C to parallel port expander
Source§impl<B> HD44780<B>where
B: DataBus,
impl<B> HD44780<B>where
B: DataBus,
Sourcepub fn reset<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
delay: &mut D,
) -> Result<()>
pub fn reset<D: DelayUs<u16> + DelayMs<u8>>( &mut self, delay: &mut D, ) -> Result<()>
Unshifts the display and sets the cursor position to 0
lcd.reset();Sourcepub fn set_display_mode<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
display_mode: DisplayMode,
delay: &mut D,
) -> Result<()>
pub fn set_display_mode<D: DelayUs<u16> + DelayMs<u8>>( &mut self, display_mode: DisplayMode, delay: &mut D, ) -> Result<()>
Set if the display should be on, if the cursor should be visible, and if the cursor should blink
Note: This is equivilent to calling all of the other relavent
methods however this operation does it all in one go to the HD44780
Sourcepub fn clear<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
delay: &mut D,
) -> Result<()>
pub fn clear<D: DelayUs<u16> + DelayMs<u8>>( &mut self, delay: &mut D, ) -> Result<()>
Clear the entire display
lcd.clear();Sourcepub fn set_autoscroll<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
enabled: bool,
delay: &mut D,
) -> Result<()>
pub fn set_autoscroll<D: DelayUs<u16> + DelayMs<u8>>( &mut self, enabled: bool, delay: &mut D, ) -> Result<()>
If enabled, automatically scroll the display when a new character is written to the display
lcd.set_autoscroll(true);Sourcepub fn set_cursor_visibility<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
visibility: Cursor,
delay: &mut D,
) -> Result<()>
pub fn set_cursor_visibility<D: DelayUs<u16> + DelayMs<u8>>( &mut self, visibility: Cursor, delay: &mut D, ) -> Result<()>
Set if the cursor should be visible
Sourcepub fn set_display<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
display: Display,
delay: &mut D,
) -> Result<()>
pub fn set_display<D: DelayUs<u16> + DelayMs<u8>>( &mut self, display: Display, delay: &mut D, ) -> Result<()>
Set if the characters on the display should be visible
Sourcepub fn set_cursor_blink<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
blink: CursorBlink,
delay: &mut D,
) -> Result<()>
pub fn set_cursor_blink<D: DelayUs<u16> + DelayMs<u8>>( &mut self, blink: CursorBlink, delay: &mut D, ) -> Result<()>
Set if the cursor should blink
Sourcepub fn set_cursor_mode<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
mode: CursorMode,
delay: &mut D,
) -> Result<()>
pub fn set_cursor_mode<D: DelayUs<u16> + DelayMs<u8>>( &mut self, mode: CursorMode, delay: &mut D, ) -> Result<()>
Set which way the cursor will move when a new character is written
// Move right (Default) when a new character is written
lcd.set_cursor_mode(CursorMode::Right)
// Move left when a new character is written
lcd.set_cursor_mode(CursorMode::Left)Sourcepub fn set_cursor_pos<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
position: u8,
delay: &mut D,
) -> Result<()>
pub fn set_cursor_pos<D: DelayUs<u16> + DelayMs<u8>>( &mut self, position: u8, delay: &mut D, ) -> Result<()>
Set the cursor position
// Move to line 2
lcd.set_cursor_pos(40)Sourcepub fn shift_cursor<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
dir: Direction,
delay: &mut D,
) -> Result<()>
pub fn shift_cursor<D: DelayUs<u16> + DelayMs<u8>>( &mut self, dir: Direction, delay: &mut D, ) -> Result<()>
Shift just the cursor to the left or the right
lcd.shift_cursor(Direction::Left);
lcd.shift_cursor(Direction::Right);Sourcepub fn shift_display<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
dir: Direction,
delay: &mut D,
) -> Result<()>
pub fn shift_display<D: DelayUs<u16> + DelayMs<u8>>( &mut self, dir: Direction, delay: &mut D, ) -> Result<()>
Shift the entire display to the left or the right
lcd.shift_display(Direction::Left);
lcd.shift_display(Direction::Right);Sourcepub fn write_char<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
data: char,
delay: &mut D,
) -> Result<()>
pub fn write_char<D: DelayUs<u16> + DelayMs<u8>>( &mut self, data: char, delay: &mut D, ) -> Result<()>
Write a single character to the HD44780. This char just gets downcast to a u8
internally, so make sure that whatever character you’re printing fits inside that range, or
you can just use write_byte to have the compiler check for you.
See the documentation on that function for more details about compatibility.
lcd.write_char('A', &mut delay)?; // prints 'A'Sourcepub fn write_str<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
string: &str,
delay: &mut D,
) -> Result<()>
pub fn write_str<D: DelayUs<u16> + DelayMs<u8>>( &mut self, string: &str, delay: &mut D, ) -> Result<()>
Writes a string to the HD44780. Internally, this just prints the string byte-by-byte, so
make sure the characters in the string fit in a normal u8. See the documentation on
write_byte for more details on compatibility.
lcd.write_str("Hello, World!", &mut delay)?;Sourcepub fn write_bytes<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
string: &[u8],
delay: &mut D,
) -> Result<()>
pub fn write_bytes<D: DelayUs<u16> + DelayMs<u8>>( &mut self, string: &[u8], delay: &mut D, ) -> Result<()>
Writes a sequence of bytes to the HD44780. See the documentation on the write_byte function for more details about compatibility.
lcd.write_bytes(b"Hello, World!", &mut delay)?;Sourcepub fn write_byte<D: DelayUs<u16> + DelayMs<u8>>(
&mut self,
data: u8,
delay: &mut D,
) -> Result<()>
pub fn write_byte<D: DelayUs<u16> + DelayMs<u8>>( &mut self, data: u8, delay: &mut D, ) -> Result<()>
Writes a single byte to the HD44780. These usually map to ASCII characters when printed on the
screen, but not always. While it varies depending on the ROM of the LCD, 0x20u8..=0x5b
and 0x5d..=0x7d should map to their standard ASCII characters. That is, all the printable
ASCII characters work, excluding \ and ~, which are usually displayed as ¥ and 🡢
respectively.
More information can be found in the Hitachi datasheets for the HD44780.
lcd.write_byte(b'A', &mut delay)?; // prints 'A'
lcd.write_byte(b'\\', &mut delay)?; // usually prints ¥
lcd.write_byte(b'~', &mut delay)?; // usually prints 🡢
lcd.write_byte(b'\x7f', &mut delay)?; // usually prints 🡠