Trait Hardware

Source
pub trait Hardware {
    // Required methods
    fn rs(&mut self, bit: bool);
    fn enable(&mut self, bit: bool);
    fn data(&mut self, data: u8);

    // Provided methods
    fn wait_address(&mut self) { ... }
    fn mode(&self) -> FunctionMode { ... }
    fn can_read(&self) -> bool { ... }
    fn rw(&mut self, _bit: bool) { ... }
    fn read_data(&mut self) -> u8 { ... }
    fn apply(&mut self) { ... }
}

Required Methods§

Source

fn rs(&mut self, bit: bool)

Source

fn enable(&mut self, bit: bool)

Source

fn data(&mut self, data: u8)

Provided Methods§

Source

fn wait_address(&mut self)

Address set up time is 40ns minimum (tAS) This function should be overridden in case processor is too fast for 40ns to pass.

Source

fn mode(&self) -> FunctionMode

Override to pick 8-bit mode (4-bit mode by default)

Source

fn can_read(&self) -> bool

If this implementation can read from the data port. Default is false. If true is returned, both rw and read_data need to be implemented.

Source

fn rw(&mut self, _bit: bool)

Set R/W flag.

Implementation should re-configure GPIO for input before setting R/W pin to true and configure GPIO for output after setting R/W to false.

Note that LCD driver typically uses 5V, so input should be tolerant to 5V when using busy flag.

Default implementation will panic.

Source

fn read_data(&mut self) -> u8

Read data from the data pins of the LCD (D0-D7 in 8-bit mode and D4-D7 in 4-bit mode)

Default implementation will panic.

Source

fn apply(&mut self)

Send data to the device.

This is mainly for LCDs attached via I2C / SMBUS where it’s important to make changes to data and control lines at the same time.

If control and data lines are directly attached, there’s no need to implement this method.

Implementors§