CircuitsSim.Device.GPIOButton (circuits_sim v0.1.2)
View SourceThis is simple GPIO-connected button
Buttons can be connected in a few ways:
:external_pullup
- 0 is pressed, 1 is released:external_pulldown
- 1 is pressed, 0 is released:internal_pullup
- 0 is pressed. The GPIO will need to be configured in pullup mode for releases to be 1.:internal_pulldown
- 1 is pressed. The GPIO will need to be configured in pulldown mode for releases to be 0.
Call press/1
and release/1
to change the state of the button.
Summary
Types
@type connection_mode() ::
:external_pullup | :external_pulldown | :internal_pullup | :internal_pulldown
@type options() :: [{:connection, connection_mode()}]
@type t() :: %CircuitsSim.Device.GPIOButton{ connection: connection_mode(), state: :pressed | :released }
Functions
@spec press(Circuits.GPIO.gpio_spec(), non_neg_integer() | :infinity) :: :ok
Press the button
Pass in a duration in milliseconds to automatically release the button after a timeout.
@spec release(Circuits.GPIO.gpio_spec()) :: :ok
Release the button