Skip to content

Commit

Permalink
Merge pull request #98 from caternuson/iss96
Browse files Browse the repository at this point in the history
Update setPWM return behavior
  • Loading branch information
caternuson committed Aug 10, 2023
2 parents 0e664c6 + 2919ecc commit 6e74540
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Adafruit_PWMServoDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ uint16_t Adafruit_PWMServoDriver::getPWM(uint8_t num, bool off) {
* @param num One of the PWM output pins, from 0 to 15
* @param on At what point in the 4096-part cycle to turn the PWM output ON
* @param off At what point in the 4096-part cycle to turn the PWM output OFF
* @return result from endTransmission
* @return 0 if successful, otherwise 1
*/
uint8_t Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on,
uint16_t off) {
Expand All @@ -249,9 +249,12 @@ uint8_t Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on,
buffer[2] = on >> 8;
buffer[3] = off;
buffer[4] = off >> 8;
i2c_dev->write(buffer, 5);

return 0;
if (i2c_dev->write(buffer, 5)) {
return 0;
} else {
return 1;
}
}

/*!
Expand Down

0 comments on commit 6e74540

Please sign in to comment.