Class that stores state and functions for interacting with PCA9685 PWM chip.
More...
#include <Adafruit_PWMServoDriver.h>
|
| Adafruit_PWMServoDriver () |
| Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface.
|
|
| Adafruit_PWMServoDriver (const uint8_t addr) |
| Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface. More...
|
|
| Adafruit_PWMServoDriver (const uint8_t addr, TwoWire &i2c) |
| Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface. More...
|
|
bool | begin (uint8_t prescale=0) |
| Setups the I2C interface and hardware. More...
|
|
void | reset () |
| Sends a reset command to the PCA9685 chip over I2C.
|
|
void | sleep () |
| Puts board into sleep mode.
|
|
void | wakeup () |
| Wakes board from sleep.
|
|
void | setExtClk (uint8_t prescale) |
| Sets EXTCLK pin to use the external clock. More...
|
|
void | setPWMFreq (float freq) |
| Sets the PWM frequency for the entire chip, up to ~1.6 KHz. More...
|
|
void | setOutputMode (bool totempole) |
| Sets the output mode of the PCA9685 to either open drain or push pull / totempole. Warning: LEDs with integrated zener diodes should only be driven in open drain mode. More...
|
|
uint16_t | getPWM (uint8_t num, bool off=false) |
| Gets the PWM output of one of the PCA9685 pins. More...
|
|
uint8_t | setPWM (uint8_t num, uint16_t on, uint16_t off) |
| Sets the PWM output of one of the PCA9685 pins. More...
|
|
void | setPin (uint8_t num, uint16_t val, bool invert=false) |
| Helper to set pin PWM output. Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on. Optional invert parameter supports inverting the pulse for sinking to ground. More...
|
|
uint8_t | readPrescale (void) |
| Reads set Prescale from PCA9685. More...
|
|
void | writeMicroseconds (uint8_t num, uint16_t Microseconds) |
| Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise. More...
|
|
void | setOscillatorFrequency (uint32_t freq) |
| Setter for the internally tracked oscillator used for freq calculations. More...
|
|
uint32_t | getOscillatorFrequency (void) |
| Getter for the internally tracked oscillator used for freq calculations. More...
|
|
Class that stores state and functions for interacting with PCA9685 PWM chip.
◆ Adafruit_PWMServoDriver() [1/2]
Adafruit_PWMServoDriver::Adafruit_PWMServoDriver |
( |
const uint8_t |
addr | ) |
|
Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface.
- Parameters
-
addr | The 7-bit I2C address to locate this chip, default is 0x40 |
◆ Adafruit_PWMServoDriver() [2/2]
Adafruit_PWMServoDriver::Adafruit_PWMServoDriver |
( |
const uint8_t |
addr, |
|
|
TwoWire & |
i2c |
|
) |
| |
Instantiates a new PCA9685 PWM driver chip with the I2C address on a TwoWire interface.
- Parameters
-
addr | The 7-bit I2C address to locate this chip, default is 0x40 |
i2c | A reference to a 'TwoWire' object that we'll use to communicate with |
◆ begin()
bool Adafruit_PWMServoDriver::begin |
( |
uint8_t |
prescale = 0 | ) |
|
Setups the I2C interface and hardware.
- Parameters
-
prescale | Sets External Clock (Optional) |
- Returns
- true if successful, otherwise false
◆ setExtClk()
void Adafruit_PWMServoDriver::setExtClk |
( |
uint8_t |
prescale | ) |
|
Sets EXTCLK pin to use the external clock.
- Parameters
-
prescale | Configures the prescale value to be used by the external clock |
◆ setPWMFreq()
void Adafruit_PWMServoDriver::setPWMFreq |
( |
float |
freq | ) |
|
Sets the PWM frequency for the entire chip, up to ~1.6 KHz.
- Parameters
-
freq | Floating point frequency that we will attempt to match |
◆ setOutputMode()
void Adafruit_PWMServoDriver::setOutputMode |
( |
bool |
totempole | ) |
|
Sets the output mode of the PCA9685 to either open drain or push pull / totempole. Warning: LEDs with integrated zener diodes should only be driven in open drain mode.
- Parameters
-
totempole | Totempole if true, open drain if false. |
◆ getPWM()
uint16_t Adafruit_PWMServoDriver::getPWM |
( |
uint8_t |
num, |
|
|
bool |
off = false |
|
) |
| |
Gets the PWM output of one of the PCA9685 pins.
- Parameters
-
num | One of the PWM output pins, from 0 to 15 |
off | If true, returns PWM OFF value, otherwise PWM ON |
- Returns
- requested PWM output value
◆ setPWM()
uint8_t Adafruit_PWMServoDriver::setPWM |
( |
uint8_t |
num, |
|
|
uint16_t |
on, |
|
|
uint16_t |
off |
|
) |
| |
Sets the PWM output of one of the PCA9685 pins.
- Parameters
-
num | One of the PWM output pins, from 0 to 15 |
on | At what point in the 4096-part cycle to turn the PWM output ON |
off | At what point in the 4096-part cycle to turn the PWM output OFF |
- Returns
- 0 if successful, otherwise 1
◆ setPin()
void Adafruit_PWMServoDriver::setPin |
( |
uint8_t |
num, |
|
|
uint16_t |
val, |
|
|
bool |
invert = false |
|
) |
| |
Helper to set pin PWM output. Sets pin without having to deal with on/off tick placement and properly handles a zero value as completely off and 4095 as completely on. Optional invert parameter supports inverting the pulse for sinking to ground.
- Parameters
-
num | One of the PWM output pins, from 0 to 15 |
val | The number of ticks out of 4096 to be active, should be a value from 0 to 4095 inclusive. |
invert | If true, inverts the output, defaults to 'false' |
◆ readPrescale()
uint8_t Adafruit_PWMServoDriver::readPrescale |
( |
void |
| ) |
|
Reads set Prescale from PCA9685.
- Returns
- prescale value
◆ writeMicroseconds()
void Adafruit_PWMServoDriver::writeMicroseconds |
( |
uint8_t |
num, |
|
|
uint16_t |
Microseconds |
|
) |
| |
Sets the PWM output of one of the PCA9685 pins based on the input microseconds, output is not precise.
- Parameters
-
num | One of the PWM output pins, from 0 to 15 |
Microseconds | The number of Microseconds to turn the PWM output ON |
◆ setOscillatorFrequency()
void Adafruit_PWMServoDriver::setOscillatorFrequency |
( |
uint32_t |
freq | ) |
|
Setter for the internally tracked oscillator used for freq calculations.
- Parameters
-
freq | The frequency the PCA9685 should use for frequency calculations |
◆ getOscillatorFrequency()
uint32_t Adafruit_PWMServoDriver::getOscillatorFrequency |
( |
void |
| ) |
|
Getter for the internally tracked oscillator used for freq calculations.
- Returns
- The frequency the PCA9685 thinks it is running at (it cannot introspect)
The documentation for this class was generated from the following files: