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
Trait Implementations
sourceimpl Write<u8> for I2cMock
impl Write<u8> for I2cMock
sourcefn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
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);
type Error = I2cMockError
type Error = I2cMockError
Error type
sourceimpl WriteRead<u8> for I2cMock
impl WriteRead<u8> for I2cMock
sourcefn write_read(
&mut self,
address: u8,
bytes: &[u8],
buffer: &mut [u8]
) -> Result<(), Self::Error>
fn write_read(
&mut self,
address: u8,
bytes: &[u8],
buffer: &mut [u8]
) -> Result<(), Self::Error>
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);
type Error = I2cMockError
type Error = I2cMockError
Error type
Auto Trait Implementations
impl RefUnwindSafe for I2cMock
impl Send for I2cMock
impl Sync for I2cMock
impl Unpin for I2cMock
impl UnwindSafe for I2cMock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more