From 601d76e1b16446155e7091ea2b5700ee9fb281da Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 3 Nov 2019 21:12:17 +0100 Subject: [PATCH] use setPrescale function --- Adafruit_PWMServoDriver.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/Adafruit_PWMServoDriver.cpp b/Adafruit_PWMServoDriver.cpp index 38b95e1..a6a33ed 100755 --- a/Adafruit_PWMServoDriver.cpp +++ b/Adafruit_PWMServoDriver.cpp @@ -165,14 +165,7 @@ void Adafruit_PWMServoDriver::setPWMFreq(float freq) { Serial.println(prescale); #endif - uint8_t oldmode = read8(PCA9685_MODE1); - uint8_t newmode = (oldmode & ~MODE1_RESTART) | MODE1_SLEEP; // sleep - write8(PCA9685_MODE1, newmode); // go to sleep - write8(PCA9685_PRESCALE, prescale); // set the prescaler - write8(PCA9685_MODE1, oldmode); - delay(5); - // This sets the MODE1 register to turn on auto increment. - write8(PCA9685_MODE1, oldmode | MODE1_RESTART | MODE1_AI); + setPrescale(prescale); #ifdef ENABLE_DEBUG_OUTPUT Serial.print("Mode now 0x");