Skip to content

Commit 606fbb2

Browse files
authored
correct conversion of prescale to frequency
there should be a better way to do this
1 parent 2fd2760 commit 606fbb2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Adafruit_PWMServoDriver.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,9 @@ void Adafruit_PWMServoDriver::writeMicroseconds(uint8_t num, uint16_t Microsecon
302302
// Rounding to nearest number is equal to adding 0,5 and floor to nearest number
303303
prescale *= 4096;
304304
prescale -= 2048;
305-
double freq;
306-
prescale *= freq; // Calculated PCA9685 chip PWM Frequency
305+
uint32_t freq = FREQUENCY_CALIBRATED;
306+
freq *= prescale; // Calculated PCA9685 chip PWM Frequency
307+
freq /= 0.9; // Correct for overshoot in the frequency setting
307308

308309
#ifdef ENABLE_DEBUG_OUTPUT
309310
Serial.print(freq); Serial.println(" Calculated PCA9685 chip PWM Frequency");

0 commit comments

Comments
 (0)