ServoKit.ServoUtil (servo_kit v0.0.5) View Source
A collection of functions that are used for the servo abstractions.
Link to this section Summary
Functions
Calculates angle in degrees from a duty cycle in percent.
Calculates duty cycle in percent from an angle in degrees.
Link to this section Functions
Calculates angle in degrees from a duty cycle in percent.
Examples
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.angle_from_duty_cycle(driver, 2.5)
0
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.angle_from_duty_cycle(driver, 7.5)
90
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.angle_from_duty_cycle(driver, 12.5)
180
Calculates duty cycle in percent from an angle in degrees.
Examples
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.duty_cycle_from_angle(driver, 0)
2.5
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.duty_cycle_from_angle(driver, 90)
7.5
iex> driver = %{actuation_range: 170, duty_cycle_minmax: {2.5, 12.5}}
...> ServoKit.ServoUtil.duty_cycle_from_angle(driver, 180)
12.5