Pigpiox v0.1.2 Pigpiox.GPIO View Source
This module exposes pigpiod’s basic GPIO functionality.
Link to this section Summary
Types
The state of a GPIO pin - 0 for low, 1 for high
A mode that a GPIO pin can be in. Returned by get_mode/1 and passed to set_mode/2
Functions
Returns the current mode for a specific GPIO pin
Returns the current servo pulsewidth for a specific GPIO pin
Returns the current level for a specific GPIO pin
Sets a mode for a specific GPIO pin. pin must be a valid GPIO pin number for the device, with some exceptions.
See pigpio’s documentation for more details
Sets the servo pulsewidth for a specific GPIO pin
Starts a watcher to monitor the level of a specific GPIO pin
Sets the current level for a specific GPIO pin
Link to this section Types
The state of a GPIO pin - 0 for low, 1 for high.
mode :: :input | :output | :alt0 | :alt1 | :alt2 | :alt3 | :alt4 | :alt5
A mode that a GPIO pin can be in. Returned by get_mode/1 and passed to set_mode/2.
Link to this section Functions
get_mode(pin :: integer) ::
{:ok, mode | :unknown} |
{:error, atom}
Returns the current mode for a specific GPIO pin
get_servo_pulsewidth(pin :: integer) ::
{:ok, non_neg_integer} |
{:error, atom}
Returns the current servo pulsewidth for a specific GPIO pin
Returns the current level for a specific GPIO pin
set_mode(pin :: integer, mode) :: :ok | {:error, atom}
Sets a mode for a specific GPIO pin. pin must be a valid GPIO pin number for the device, with some exceptions.
See pigpio’s documentation for more details.
mode can be any of mode/0.
set_servo_pulsewidth(pin :: integer, width :: non_neg_integer) ::
:ok |
{:error, atom}
Sets the servo pulsewidth for a specific GPIO pin.
The pulsewidths supported by servos varies and should probably be determined by experiment. A value of 1500 should always be safe and represents the mid-point of rotation.
A pulsewidth of 0 will stop the servo.
You can DAMAGE a servo if you command it to move beyond its limits.
Starts a watcher to monitor the level of a specific GPIO pin
The calling process will receive a message with the current level of the pin, as well as a message every time the level of that pin changes.
The message will be of the format:
{:gpio_leveL_change, gpio, level}
write(pin :: integer, level) :: :ok | {:error, atom}
Sets the current level for a specific GPIO pin