Skip to content

Commit 7469265

Browse files
author
Charles-Ellison
committed
Merge branch 'ServoGroups'
2 parents 76d61f4 + 355e721 commit 7469265

File tree

2 files changed

+11
-28
lines changed

2 files changed

+11
-28
lines changed

Adafruit_PWMServoDriverGroup.cpp

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,5 @@
11
#include "Adafruit_PWMServoDriverGroup.h"
22

3-
/*!
4-
* @brief Instantiates new PCA9685 PWM driver chips with consecutive
5-
* I2C addresses begining with the default on a TwoWire interface
6-
* @param nDrivers Number of PWM driver chips to instantiate
7-
* @param nServosEach Number of servos to allocate on each driver
8-
*/
9-
Adafruit_PWMServoDriverGroup::Adafruit_PWMServoDriverGroup(const uint8_t nDrivers, const uint8_t nServosEach) {
10-
_nDrivers = nDrivers;
11-
_nServosEach = nServosEach;
12-
13-
_drivers = (Adafruit_PWMServoDriver **) malloc(nDrivers * sizeof(Adafruit_PWMServoDriver *));
14-
15-
for(uint8_t i=0; i < _nDrivers; i++) {
16-
_drivers[i] = new Adafruit_PWMServoDriver(PCA9685_I2C_ADDRESS + i);
17-
}
18-
}
19-
203
/*!
214
* @brief Instantiates new PCA9685 PWM driver chips with user defined
225
* I2C addresses on a TwoWire interface
@@ -75,7 +58,7 @@ uint8_t Adafruit_PWMServoDriverGroup::getNumServos() {
7558

7659
/*!
7760
* @brief Gets the Adafruit_PWMServoDriver associated with a given servo and
78-
* the servo number on that device
61+
* the local servo number on that device
7962
* @param num Number of servo in master list
8063
* @param localId returns the number of the servo as known to the PCA9685 chip
8164
* @return The Adafruit_PWMServoDriver associated with the requested servo
@@ -218,19 +201,20 @@ void Adafruit_PWMServoDriverGroup::writeMicroseconds(uint8_t num, uint16_t micro
218201
* @returns The frequency the PCA9685 thinks it is running at (it cannot
219202
* introspect)
220203
*/
221-
void Adafruit_PWMServoDriverGroup::setOscillatorFrequency(uint32_t freq){
222-
for(int i = 0; i < _nDrivers; i++) _drivers[i]->setOscillatorFrequency(freq);
223-
}
224-
225-
void Adafruit_PWMServoDriverGroup::setOscillatorFrequency(uint8_t id, uint32_t freq){
226-
_drivers[id]->setOscillatorFrequency(freq);
204+
uint32_t Adafruit_PWMServoDriverGroup::getOscillatorFrequency(uint8_t id){
205+
return _drivers[id]->getOscillatorFrequency();
227206
}
228207

229208
/*!
230209
* @brief Setter for the internally tracked oscillator used for freq
231210
* calculations
232211
* @param freq The frequency the PCA9685 should use for frequency calculations
233212
*/
234-
uint32_t Adafruit_PWMServoDriverGroup::getOscillatorFrequency(uint8_t id){
235-
return _drivers[id]->getOscillatorFrequency();
213+
void Adafruit_PWMServoDriverGroup::setOscillatorFrequency(uint32_t freq){
214+
for(int i = 0; i < _nDrivers; i++) _drivers[i]->setOscillatorFrequency(freq);
236215
}
216+
217+
void Adafruit_PWMServoDriverGroup::setOscillatorFrequency(uint8_t id, uint32_t freq){
218+
_drivers[id]->setOscillatorFrequency(freq);
219+
}
220+

Adafruit_PWMServoDriverGroup.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file Adafruit_PWMServoDriverGroup.h
33
*
44
* This Library sets up a group of Adafruit_PWMServoDrivers
5-
* to act like a Adafruit_PWMServoDrivers object
5+
* to act like a single Adafruit_PWMServoDrivers object
66
*
77
*
88
* Designed specifically to work with the Adafruit 16-channel PWM & Servo
@@ -28,7 +28,6 @@
2828
class Adafruit_PWMServoDriverGroup {
2929
public:
3030

31-
Adafruit_PWMServoDriverGroup(const uint8_t ndrivers, const uint8_t nServosEach);
3231
Adafruit_PWMServoDriverGroup(const uint8_t ndrivers, const uint8_t nServosEach, const uint8_t *addr);
3332
Adafruit_PWMServoDriverGroup(const uint8_t ndrivers, const uint8_t nServosEach, const uint8_t *addr, TwoWire &i2c);
3433

0 commit comments

Comments
 (0)