|
1 | 1 | #include "Adafruit_PWMServoDriverGroup.h"
|
2 | 2 |
|
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 |
| - |
20 | 3 | /*!
|
21 | 4 | * @brief Instantiates new PCA9685 PWM driver chips with user defined
|
22 | 5 | * I2C addresses on a TwoWire interface
|
@@ -75,7 +58,7 @@ uint8_t Adafruit_PWMServoDriverGroup::getNumServos() {
|
75 | 58 |
|
76 | 59 | /*!
|
77 | 60 | * @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 |
79 | 62 | * @param num Number of servo in master list
|
80 | 63 | * @param localId returns the number of the servo as known to the PCA9685 chip
|
81 | 64 | * @return The Adafruit_PWMServoDriver associated with the requested servo
|
@@ -218,19 +201,20 @@ void Adafruit_PWMServoDriverGroup::writeMicroseconds(uint8_t num, uint16_t micro
|
218 | 201 | * @returns The frequency the PCA9685 thinks it is running at (it cannot
|
219 | 202 | * introspect)
|
220 | 203 | */
|
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(); |
227 | 206 | }
|
228 | 207 |
|
229 | 208 | /*!
|
230 | 209 | * @brief Setter for the internally tracked oscillator used for freq
|
231 | 210 | * calculations
|
232 | 211 | * @param freq The frequency the PCA9685 should use for frequency calculations
|
233 | 212 | */
|
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); |
236 | 215 | }
|
| 216 | + |
| 217 | +void Adafruit_PWMServoDriverGroup::setOscillatorFrequency(uint8_t id, uint32_t freq){ |
| 218 | + _drivers[id]->setOscillatorFrequency(freq); |
| 219 | +} |
| 220 | + |
0 commit comments