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 Adafruit_PWMServoDriver.cpp Fixed setPWM - beginTransmission now works #3

Merged
merged 1 commit into from Dec 27, 2012
Merged
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
13 changes: 8 additions & 5 deletions Adafruit_PWMServoDriver.cpp
Expand Up @@ -50,25 +50,28 @@ void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
write8(PCA9685_PRESCALE, prescale); // set the prescaler
write8(PCA9685_MODE1, oldmode);
delay(5);
write8(PCA9685_MODE1, oldmode | 0x80);
//write8(PCA9685_MODE1, oldmode | 0x80);
write8(PCA9685_MODE1, oldmode | 0xa1); // This sets the MODE1 register to turn on auto increment.
// This is why the beginTransmission below was not working.
// Serial.print("Mode now 0x"); Serial.println(read8(PCA9685_MODE1), HEX);
}

void Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on, uint16_t off) {
/*
// hmm doesnt work, whyso?
// hmm doesnt work, whyso? ( Not in AI mode. See line 54 above. ( Works now!! :D )
Wire.beginTransmission(_i2caddr);
Wire.write(LED0_ON_L+4*num);
Wire.write(on);
Wire.write(on>>8);
Wire.write(off);
Wire.write(off>>8);
Wire.endTransmission();
*/

/*
write8(LED0_ON_L+4*num, on);
write8(LED0_ON_H+4*num, on >> 8);
write8(LED0_OFF_L+4*num, off);
write8(LED0_OFF_H+4*num, off >> 8);
write8(LED0_OFF_H+4*num, off >> 8);
*/
}

uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) {
Expand Down