CircuitsSim.I2C.SimpleI2CDevice protocol (circuits_sim v0.1.2)
View SourceA protocol that makes register-based I2C devices easier to simulate
Summary
Functions
Handle an user message
Read a register
Return a pretty printable view the the state
Write a value to a register
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_register(t(), non_neg_integer()) :: {non_neg_integer(), t()}
Read a register
@spec render(t()) :: IO.ANSI.ansidata()
Return a pretty printable view the the state
@spec write_register(t(), non_neg_integer(), non_neg_integer()) :: t()
Write a value to a register