ServoKit.PCA9685.Util (servo_kit v0.0.2) View Source

Link to this section Summary

Functions

Calculates the PWM frequency prescale based on the formula in Datasheet 7.3.5.

Examples

iex> ServoKit.PCA9685.Util.pulse_range_from_percent(0)
{0, 0}
iex> ServoKit.PCA9685.Util.pulse_range_from_percent(50)
{0, 2048}
iex> ServoKit.PCA9685.Util.pulse_range_from_percent(100)
{0, 4095}

Link to this section Functions

Link to this function

prescale_value_from_frequecy(freq_hz)

View Source

Calculates the PWM frequency prescale based on the formula in Datasheet 7.3.5.

prescale_value = round(osc_value / (4096 * update_rate)) - 1

Examples

iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(1)
255
iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(23)
255
iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(50)
121
iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(100)
60
iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(1526)
3
iex> ServoKit.PCA9685.Util.prescale_value_from_frequecy(2000)
3
Link to this function

pulse_range_from_percent(percent)

View Source

Specs

pulse_range_from_percent(float()) :: {0, 0..4095}

Examples

iex> ServoKit.PCA9685.Util.pulse_range_from_percent(0)
{0, 0}
iex> ServoKit.PCA9685.Util.pulse_range_from_percent(50)
{0, 2048}
iex> ServoKit.PCA9685.Util.pulse_range_from_percent(100)
{0, 4095}