pca9685

package
v0.0.0-...-613ce78 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package pca9685 is a driver for the PCA9685 I2C servo/pwm board. e.g. https://www.adafruit.com/product/815

Index

Constants

View Source
const (
	REG_MODE1 byte = iota
	REG_MODE2
	REG_SUBADR1
	REG_SUBADR2
	REG_SUBADR3
	REG_ALLCALLADR
	REG_PWM0_ON_L
	REG_PWM0_ON_H
	REG_PWM0_OFF_L
	REG_PWM0_OFF_H
	REG_PRESCALE = 0xFE
)

Register names and addresses.

View Source
const (
	MODE1_ALLCAL byte = 1 << iota
	MODE1_SUB3
	MODE1_SUB2
	MODE1_SUB1
	MODE1_SLEEP
	MODE1_AI
	MODE1_EXTCLK
	MODE1_RESTART
)

MODE1 bit values.

View Source
const (
	CLOCK_MHZ       = 25
	PRESCALE_SERVO  = 121 // 50Hz
	MICROS_PER_TICK = (PRESCALE_SERVO + 1 + CLOCK_MHZ/2) / CLOCK_MHZ
)

Typical PWM prescalar values (assuming a 25MHz clock).

View Source
const Address = 0x40

The I2C address which this device listens to by default.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device wraps an I2C connection to the device.

func New

func New(bus drivers.I2C) Device

New creates a new PCA9685 connection. The I2C bus must already be configured.

This function only creates the Device object. It does not touch the device.

func (*Device) Configure

func (d *Device) Configure() error

Configure sets up the device for communication.

func (*Device) SetPin

func (d *Device) SetPin(pin byte, micros uint16) error

SetPin sets the pulse width for a given pin to an approximate number of microseconds. Valid pin values are 0..15. Valid values are 1000 to 2000, or zero. A value of 0 turns off the servo.

Jump to

Keyboard shortcuts

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