Struct ht16k33::i2c_mock::I2cMock

source ·
pub struct I2cMock {
    pub data_values: [u8; 16],
    /* private fields */
}
Expand description

The mock I2C state.

Example

// NOTE: `None` is used for the Logger in these examples for convenience,
// in practice using an actual logger is preferred.

extern crate ht16k33;
use ht16k33::i2c_mock::I2cMock;

// Create an I2cMock.
let i2c_mock = I2cMock::new(None);

Fields

data_values: [u8; 16]

Display RAM state.

Implementations

Create an I2cMock.

Arguments
  • logger - A logging instance.
Notes

logger = None, will log to the slog-stdlog drain. This makes the library effectively work the same as if it was just using log instead of slog.

Trait Implementations

write implementation.

Arguments
  • _address - The slave address. Ignored.
  • bytes - The command/address instructions to be written.
Examples
let mut i2c_mock = I2cMock::new(None);

// First value is the data address, remaining values are to be written
// starting at the data address which auto-increments and then wraps.
let write_buffer = [ht16k33::DisplayDataAddress::ROW_0.bits(), 0u8, 0u8];

i2c_mock.write(0, &write_buffer);
Error type

write_read implementation.

Arguments
  • _address - The slave address. Ignored.
  • bytes - The command/address instructions to be written.
  • buffer - The read results.
Examples
let mut i2c_mock = I2cMock::new(None);

let mut read_buffer = [0u8; 16];
i2c_mock.write_read(0, &[ht16k33::DisplayDataAddress::ROW_0.bits()], &mut read_buffer);
Error type

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.