Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setPWM return behavior #98

Merged
merged 1 commit into from
Aug 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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