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

new function setAllPWM #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions Adafruit_PWMServoDriver.cpp 100755 → 100644
Expand Up @@ -238,6 +238,29 @@ void Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on, uint16_t off) {
_i2c->endTransmission();
}

/*!
* @brief Sets the PWM output of all of the PCA9685 pins
* @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
*/
void Adafruit_PWMServoDriver::setAllPWM(uint16_t on, uint16_t off) {
#ifdef ENABLE_DEBUG_OUTPUT
Serial.print("Setting all PWM ");
Serial.print(": ");
Serial.print(on);
Serial.print("->");
Serial.println(off);
#endif

_i2c->beginTransmission(_i2caddr);
_i2c->write(PCA9685_ALLLED_ON_L);
_i2c->write(on);
_i2c->write(on >> 8);
_i2c->write(off);
_i2c->write(off >> 8);
_i2c->endTransmission();
}

/*!
* @brief Helper to set pin PWM output. Sets pin without having to deal with
* on/off tick placement and properly handles a zero value as completely off and
Expand Down
1 change: 1 addition & 0 deletions Adafruit_PWMServoDriver.h
Expand Up @@ -86,6 +86,7 @@ class Adafruit_PWMServoDriver {
void setOutputMode(bool totempole);
uint8_t getPWM(uint8_t num);
void setPWM(uint8_t num, uint16_t on, uint16_t off);
void setAllPWM(uint16_t on, uint16_t off);
void setPin(uint8_t num, uint16_t val, bool invert = false);
uint8_t readPrescale(void);
void writeMicroseconds(uint8_t num, uint16_t Microseconds);
Expand Down