View Source CircuitsSim.I2C.SimpleI2CDevice protocol (circuits_sim v0.1.0)

A protocol that makes register-based I2C devices easier to simulate

Summary

Types

t()

All the types that implement this protocol.

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

Link to this function

handle_message(dev, message)

View Source
@spec handle_message(t(), any()) :: {any(), t()}

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

Link to this function

write_register(dev, reg, value)

View Source
@spec write_register(t(), non_neg_integer(), non_neg_integer()) :: t()

Write a value to a register