CircuitsSim.I2C.I2CDevice protocol (circuits_sim v0.1.2)
View SourceA protocol for I2C devices
See Circuits.I2C.SimpleI2CDevice
if you have a simple register-based I2C device.
Summary
Functions
Handle an user message
Read count bytes
Return the internal state as ASCII art
Write data to the device
Write data to the device and immediately follow it with a read
Types
@type t() :: term()
All the types that implement this protocol.
Functions
Handle an user message
User messages are used to modify the state of the simulated device outside of I2C. This can be used to simulate real world changes like temperature changes affecting a simulated temperature sensor. Another use is as a hook for getting internal state.
@spec read(t(), non_neg_integer()) :: {{:ok, binary()} | {:error, any()}, t()}
Read count bytes
The first item in the returned tuple is what's returned from the original call to Circuits.I2C.read/2. Try to make the errors consistent with that function if possible.
@spec render(t()) :: IO.ANSI.ansidata()
Return the internal state as ASCII art
Write data to the device
Write data to the device and immediately follow it with a read