circuits_gpio v0.1.0 Circuits.GPIO View Source
Link to this section Summary
Functions
Release the resources associated with the GPIO
Return info about the low level GPIO interface
Open a GPIO for use. pin
should be a valid GPIO pin number on the system
and pin_direction
should be :input
or :output
Get the GPIO pin number
Read the current value on a pin
Change the direction of the pin
Enable or disable pin value change notifications. The notifications are sent based on the trigger parameter
Enable or disable internal pull-up or pull-down resistor to GPIO pin
Set the value of a pin. The pin should be configured to an output for this to work
Link to this section Types
pin_direction()
View Source
pin_direction() :: :input | :output
pin_direction() :: :input | :output
pin_number()
View Source
pin_number() :: non_neg_integer()
pin_number() :: non_neg_integer()
pull_mode()
View Source
pull_mode() :: :not_set | :none | :pullup | :pulldown
pull_mode() :: :not_set | :none | :pullup | :pulldown
trigger()
View Source
trigger() :: :rising | :falling | :both | :none
trigger() :: :rising | :falling | :both | :none
value()
View Source
value() :: 0 | 1
value() :: 0 | 1
Link to this section Functions
close(gpio)
View Source
close(reference()) :: :ok
close(reference()) :: :ok
Release the resources associated with the GPIO.
This is optional. The garbage collector will free GPIO resources that aren't in use, but this will free them sooner.
info()
View Source
info() :: map()
info() :: map()
Return info about the low level GPIO interface
This may be helpful when debugging issues.
open(pin_number, pin_direction)
View Source
open(pin_number(), pin_direction()) :: {:ok, reference()} | {:error, atom()}
open(pin_number(), pin_direction()) :: {:ok, reference()} | {:error, atom()}
Open a GPIO for use. pin
should be a valid GPIO pin number on the system
and pin_direction
should be :input
or :output
.
pin(gpio)
View Source
pin(reference()) :: pin_number()
pin(reference()) :: pin_number()
Get the GPIO pin number
read(gpio) View Source
Read the current value on a pin.
set_direction(gpio, pin_direction)
View Source
set_direction(reference(), pin_direction()) :: :ok | {:error, atom()}
set_direction(reference(), pin_direction()) :: :ok | {:error, atom()}
Change the direction of the pin.
set_interrupts(gpio, trigger, opts \\ []) View Source
Enable or disable pin value change notifications. The notifications are sent based on the trigger parameter:
- :none - No notifications are sent
- :rising - Send a notification when the pin changes from 0 to 1
- :falling - Send a notification when the pin changes from 1 to 0
- :both - Send a notification on all changes
Available Options:
suppress_glitches
- It is possible that the pin transitions to a value and back by the time that Circuits GPIO gets to process it. This controls whether a notification is sent. Set this tofalse
to receive notifications.receiver
- Process which should receive the notifications. Defaults to the calling process (self()
)
Notifications look like:
{:gpio, pin_number, timestamp, value}
Where pin_number
is the pin that changed values, timestamp
is roughly when
the transition occurred in nanoseconds, and value
is the new value.
set_pull_mode(gpio, pull_mode) View Source
Enable or disable internal pull-up or pull-down resistor to GPIO pin
write(gpio, value) View Source
Set the value of a pin. The pin should be configured to an output for this to work.