CircuitsSim.GPIO.GPIODevice protocol (circuits_sim v0.1.2)
View SourceA protocol for GPIO devices
Summary
Functions
Handle a message sent to the GenServer running the device
Handle an user message
Read state
Return the internal state as ASCII art
Write state
Types
@type t() :: term()
All the types that implement this protocol.
Functions
Handle a message sent to the GenServer running the device
These are used for timeouts or other events
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()) :: Circuits.GPIO.value() | :hi_z
Read state
This is only called when the GPIO is an input. If the GPIO is an output, the most recently written value is returned without making this call.
If the wire is not being driven (i.e., high impedance state or disconnected), return :hi_z
.
@spec render(t()) :: IO.ANSI.ansidata()
Return the internal state as ASCII art
@spec write(t(), Circuits.GPIO.value()) :: t()
Write state
This is only called when the GPIO is set as an output.