# `CircuitsSim.I2C.SimpleI2CDevice`
[🔗](https://github.com/elixir-circuits/circuits_sim/blob/v0.1.2/lib/circuits_sim/i2c/simple_i2c_device.ex#L1)

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

# `t`

```elixir
@type t() :: term()
```

All the types that implement this protocol.

# `handle_message`

```elixir
@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.

# `read_register`

```elixir
@spec read_register(t(), non_neg_integer()) :: {non_neg_integer(), t()}
```

Read a register

# `render`

```elixir
@spec render(t()) :: IO.ANSI.ansidata()
```

Return a pretty printable view the the state

# `write_register`

```elixir
@spec write_register(t(), non_neg_integer(), non_neg_integer()) :: t()
```

Write a value to a register

---

*Consult [api-reference.md](api-reference.md) for complete listing*
