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

Link to this type level() View Source
level() :: 0 | 1

The state of a GPIO pin - 0 for low, 1 for high.

Link to this type mode() View Source
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

Link to this function get_mode(pin) View Source
get_mode(pin :: integer) ::
  {:ok, mode | :unknown} |
  {:error, atom}

Returns the current mode for a specific GPIO pin

Link to this function get_servo_pulsewidth(pin) View Source
get_servo_pulsewidth(pin :: integer) ::
  {:ok, non_neg_integer} |
  {:error, atom}

Returns the current servo pulsewidth for a specific GPIO pin

Link to this function read(pin) View Source
read(pin :: integer) :: {:ok, level} | {:error, atom}

Returns the current level for a specific GPIO pin

Link to this function set_mode(pin, mode) View Source
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.

Link to this function set_servo_pulsewidth(pin, width) View Source
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.

Link to this function watch(pin) View Source
watch(integer) :: {:ok, pid} | {:error, atom}

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}

Link to this function write(pin, level) View Source
write(pin :: integer, level) :: :ok | {:error, atom}

Sets the current level for a specific GPIO pin