pca9685

package
v3.4.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package pca9685 includes utilities to controls pca9685 module and servo motors.

More details

Datasheet

https://www.nxp.com/docs/en/data-sheet/PCA9685.pdf

Product page:

https://www.nxp.com/products/analog/interfaces/ic-bus/ic-led-controllers/16-channel-12-bit-pwm-fm-plus-ic-bus-led-controller:PCA9685

Example
Output:

Index

Examples

Constants

View Source
const I2CAddr uint16 = 0x40

I2CAddr i2c default address.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dev

type Dev struct {
	// contains filtered or unexported fields
}

Dev is a handler to pca9685 controller

func NewI2C

func NewI2C(bus i2c.Bus, address uint16) (*Dev, error)

NewI2C returns a Dev object that communicates over I2C.

To use on the default address, pca9685.I2CAddr must be passed as argument.

func (*Dev) SetAllPwm

func (d *Dev) SetAllPwm(on, off gpio.Duty) error

SetAllPwm set a pwm value for all outputs

func (*Dev) SetPwm

func (d *Dev) SetPwm(channel int, on, off gpio.Duty) error

SetPwm set a pwm value for given pca9685 channel

func (*Dev) SetPwmFreq

func (d *Dev) SetPwmFreq(freqHz physic.Frequency) error

SetPwmFreq set the pwm frequency

type Servo

type Servo struct {
	// contains filtered or unexported fields
}

Servo individual servo from a group of servos connected to a pca9685 module

func (*Servo) SetAngle

func (s *Servo) SetAngle(angle physic.Angle) error

SetAngle set an angle on the servo will consider the angle limits set

func (*Servo) SetMinMaxAngle

func (s *Servo) SetMinMaxAngle(min, max physic.Angle)

SetMinMaxAngle change angle limits for the servo

func (*Servo) SetPwm

func (s *Servo) SetPwm(pwm gpio.Duty) error

SetPwm set an pmw value to the servo

type ServoGroup

type ServoGroup struct {
	*Dev
	// contains filtered or unexported fields
}

ServoGroup a group of servos connected to a pca9685 module

func NewServoGroup

func NewServoGroup(dev *Dev, minPwm, maxPwm gpio.Duty, minAngle, maxAngle physic.Angle) *ServoGroup

NewServoGroup returns a servo group connected throught the pca9685 module some pwm and angle limits can be set

func (*ServoGroup) GetServo

func (s *ServoGroup) GetServo(channel int) *Servo

GetServo returns a individual Servo to be controlled

func (*ServoGroup) SetAngle

func (s *ServoGroup) SetAngle(channel int, angle physic.Angle) error

SetAngle set an angle in a given channel of the servo group

func (*ServoGroup) SetMinMaxPwm

func (s *ServoGroup) SetMinMaxPwm(minAngle, maxAngle physic.Angle, minPwm, maxPwm gpio.Duty)

SetMinMaxPwm change pwm and angle limits

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL