Skip to content

Commit bb7c39a

Browse files
committed
Comply to current master branche
1 parent f0f9a07 commit bb7c39a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Adafruit_PWMServoDriver.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,14 @@ void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
167167
Serial.println(prescale);
168168
#endif
169169

170-
setPrescale(prescale);
170+
uint8_t oldmode = read8(PCA9685_MODE1);
171+
uint8_t newmode = (oldmode & ~MODE1_RESTART) | MODE1_SLEEP; // sleep
172+
write8(PCA9685_MODE1, newmode); // go to sleep
173+
write8(PCA9685_PRESCALE, prescale); // set the prescaler
174+
write8(PCA9685_MODE1, oldmode);
175+
delay(5);
176+
// This sets the MODE1 register to turn on auto increment.
177+
write8(PCA9685_MODE1, oldmode | MODE1_RESTART | MODE1_AI);
171178

172179
#ifdef ENABLE_DEBUG_OUTPUT
173180
Serial.print("Mode now 0x");

0 commit comments

Comments
 (0)