busio.I2C

class circuitpython_mocks.busio.I2C(scl: Pin, sda: Pin, **kwargs)[source]

A mock of busio.I2C class.

deinit() None

Free any hardware used by the object.

readfrom_into(address: int, buffer: array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int = 9223372036854775807) None[source]

A mock imitation of busio.I2C.readfrom_into.

Mock Expectations

This function checks against I2CRead expectations.

scan() list[int][source]

Scan all I2C addresses between 0x08 and 0x77 inclusive and return a list of those that respond.

Mock Expectations

This function will check against I2CScan expectations.

try_lock() bool

Attempt to grab the lock. Return True on success, False if the lock is already taken.

unlock() None

Release the lock so others may use the resource.

writeto(address: int, buffer: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, start: int = 0, end: int = 9223372036854775807) None[source]

A mock imitation of busio.I2C.writeto.

Mock Expectations

This function checks against I2CWrite expectations.

writeto_then_readfrom(address: int, out_buffer: array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, in_buffer: array | bytearray | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray, *, out_start: int = 0, out_end: int = 9223372036854775807, in_start: int = 0, in_end: int = 9223372036854775807) None[source]

A mock imitation of busio.I2C.writeto_then_readfrom.

Mock Expectations

This function checks against I2CTransfer expectations.

I2C operations

class circuitpython_mocks.busio.operations.I2CRead(address: int, response: bytearray)[source]

A class to identify a read operation over a I2C bus.

class circuitpython_mocks.busio.operations.I2CWrite(address: int, expected: bytearray)[source]

A class to identify a write operation over a I2C bus.

class circuitpython_mocks.busio.operations.I2CTransfer(address: int, expected: bytearray, response: bytearray)[source]

A class to identify a write operation over a I2C bus.

class circuitpython_mocks.busio.operations.I2CScan(expected: list[int])[source]

A class to identify a scan operation over a I2C bus.

The given expected value will be the result of I2C.scan().