[−][src]Trait hd44780_ntb::HD44780
Complete command set for HD44780 display controller.
Refer to Hitachi HD44780 datasheet for more information.
Associated Constants
const COMMAND_DELAY: u16
Delay time constant used to ensure HD44780 can finish processing command.
Minimum should be > 37µs @ 270KHz per HD44780 datasheet.
Some commands like clear_display() and return_home() multiple this value by some factor to achieve their required delays.
const CLEAR_DISPLAY: u8
const CURSOR_SHIFT: u8
const DISPLAY_CONTROL: u8
const ENTRY_MODE_SET: u8
const FUNCTION_SET: u8
const RETURN_HOME: u8
const SET_CG_RAM_ADDR: u8
const SET_DD_RAM_ADDR: u8
Required methods
fn command(&mut self, byte: u8, delay: u16) -> Result
Provides an interface to send commands through the HD44780 driver.
This is NOT part of the actual HD44780 command set but a necessary method to interface with all drivers.
Provides a place for drivers to do any needed common command processing.
The implementation of the command set in this trait will use this method after doing any needed per command processing.
Arguments
byte
- The command being written to HD44780 hardware.delay
- The expected delay(µs) after sending command so hardware has time to process it.
Implementing drivers may ignore delay
if the under-laying interface
is slower than the command time.
For example I²C@100KHz should not need to worry about the delay on most commands as the time to send a single byte along with address etc should be greater.
Care should be taken though when handling commands like clear_display(), return_home(), and commands sent from init() as they are expected to take long enough that additional time will be needed for processing in the HD44780.
fn init<FSM, DCM, EMSM>(
&mut self,
fs_mode: FSM,
dc_mode: DCM,
ems_mode: EMSM
) -> Result where
FSM: Into<Option<FunctionMode>>,
DCM: Into<Option<DisplayMode>>,
EMSM: Into<Option<EntryMode>>,
&mut self,
fs_mode: FSM,
dc_mode: DCM,
ems_mode: EMSM
) -> Result where
FSM: Into<Option<FunctionMode>>,
DCM: Into<Option<DisplayMode>>,
EMSM: Into<Option<EntryMode>>,
Used to initialize the display into a know state.
Normally the display controller's power on reset sets up the display into a known 8 bit interface state. In cases where the reset hasn't done so correctly or another program has left the display in an unknown state this method can be used to get the display into a known state. This method can also be used to switch between 4 and 8 bit (pin) data bus modes.
The best description I found of how to do the necessary 4 or 8 bit mode selection can be found in the Wikipedia HD44780 article.
Arguments
fs_mode
- Same as function mode bit flags used with function_set() command.dc_mode
- Same as display mode bit flags used with display_control() command.ems_mode
- Same as entry mode bit flags used with entry_mode_set() command.
Provided methods
fn clear_display(&mut self) -> Result
Clear the display.
From HD44780 datasheet: Clears entire display and sets DD RAM address 0 in address counter.
Examples
lcd.clear_display()?;
fn cursor_shift(&mut self, mode: ShiftMode) -> Result
Used to shift the display or the cursor to the left or right.
From HD44780 datasheet: Moves cursor and shifts display without changing DD RAM contents.
Examples
// The same as `ShiftMode::default()` let sm = ShiftMode::CURSOR_MOVE | ShiftMode::MOVE_RIGHT lcd.cursor_shift(sm)?;
fn display_control(&mut self, mode: DisplayMode) -> Result
Set display on/off controls.
From HD44780 datasheet: Sets entire display on/off, cursor on/off, and blinking of cursor position character.
Examples
let dm = DisplayMode::DISPLAY_ON | DisplayMode::CURSOR_ON; lcd.display_control(dm)?;
fn entry_mode_set(&mut self, mode: EntryMode) -> Result
Sets data cursor direction and display shifting.
From HD44780 datasheet: Sets cursor move direction and specifies display shift. These operations are performed during data write and read.
Examples
// EntryMode::default() == EntryMode::ENTRY_SHIFT_INCREMENT lcd.entry_mode_set(EntryMode::default())?;
fn function_set(&mut self, mode: FunctionMode) -> Result
Used to initialize the interface size (4, 8 bit), display line count, and font.
Normally would be called only once in a new/constructor type function for the instance. In most cases init() should be used instead to make changes and to insure correct initialization of the hardware.
From HD44780 datasheet: Sets interface data length, number of display lines, and character font.
Examples
let im = InitMode::DATA_4BIT | InitMode::LINES_2; lcd.function_set(im).?;
Errors
Returns an error when 2 lines and 5x10 font modes are selected together as that is not supported by the hardware.
fn return_home(&mut self) -> Result
Reset the cursor to home position.
From HD44780 datasheet: Sets DD RAM address 0 in address counter. Also returns display from being shifted to original position. DD RAM contents remain unchanged.
Examples
lcd.return_home()?;
fn set_cg_ram_addr(&mut self, address: u8) -> Result
Set CG RAM(Custom Char) address.
From HD44780 datasheet: Sets CG RAM address. CG RAM data is sent and received after this setting.
Examples
// Start of 2nd character. let location = 0x09; lcd.set_cg_ram_addr(location)?;
fn set_dd_ram_addr(&mut self, address: u8) -> Result
Set DD RAM(Display) address.
From HD44780 datasheet: Sets DD RAM address. DD RAM data is sent and received after this setting.
Examples
// Start of the 2nd line on 2 line display. let location = 0x40; lcd.set_dd_ram_addr(location)?;
Implementors
impl HD44780 for SpyDriver
[src]
const COMMAND_DELAY: u16
[src]
fn command(&mut self, byte: u8, delay: u16) -> Result
[src]
fn init<FSM, DCM, EMSM>(
&mut self,
fs_mode: FSM,
dc_mode: DCM,
ems_mode: EMSM
) -> Result where
FSM: Into<Option<FunctionMode>>,
DCM: Into<Option<DisplayMode>>,
EMSM: Into<Option<EntryMode>>,
[src]
&mut self,
fs_mode: FSM,
dc_mode: DCM,
ems_mode: EMSM
) -> Result where
FSM: Into<Option<FunctionMode>>,
DCM: Into<Option<DisplayMode>>,
EMSM: Into<Option<EntryMode>>,
impl<RS, EN, DP, D> HD44780 for GpioDriver<RS, EN, DP, D> where
RS: OutputPin,
EN: OutputPin,
DP: OutputPin,
D: DelayUs<u16>,
[src]
RS: OutputPin,
EN: OutputPin,
DP: OutputPin,
D: DelayUs<u16>,