PCA9685.Commands (pca9685 v1.0.0)

Low-level functions for interacting directly with the PCA9685 device over I2C.

Link to this section Summary

Functions

Initialize the device and set all channels to off.

Set all 16 PWM outputs to a the same output value in a single operation.

Set a specific PWM output to the provided duty cycle.

Set's the device's PWM update frequency to the provided number of Hz.

Start a connection to the PCA9685 device over I2C.

Link to this section Types

Specs

address() :: 0..127

Specs

bus() :: String.t()

Specs

channel() :: 0..15
Link to this type

duty_cycle()

Specs

duty_cycle() :: 0..4095

Specs

frequency() :: 25..1526

Link to this section Functions

Link to this function

initialize!(pid, freq_hz)

Specs

initialize!(pid(), frequency()) :: :ok | {:error, term()}

Initialize the device and set all channels to off.

Link to this function

set_all_pwm(pid, on, off)

Specs

set_all_pwm(pid(), duty_cycle(), duty_cycle()) :: :ok | {:error, term()}

Set all 16 PWM outputs to a the same output value in a single operation.

Link to this function

set_one_pwm(pid, channel, on, off)

Specs

set_one_pwm(pid(), channel(), duty_cycle(), duty_cycle()) ::
  :ok | {:error, term()}

Set a specific PWM output to the provided duty cycle.

Link to this function

set_pwm_frequency(pid, freq_hz)

Specs

set_pwm_frequency(pid(), frequency()) :: :ok | {:error, term()}

Set's the device's PWM update frequency to the provided number of Hz.

Calculates it with a hard coded prescale value.

Link to this function

start_link(bus, address)

Specs

start_link(bus(), address()) :: {:ok, pid()} | {:error, term()}

Start a connection to the PCA9685 device over I2C.