Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: K9_Head_Controller
Revision 3:5e1fd11c4f94, committed 2014-01-05
- Comitter:
- bxd
- Date:
- Sun Jan 05 22:26:12 2014 +0000
- Parent:
- 2:237e7b9d17c8
- Child:
- 4:41a00db32ae7
- Commit message:
- Fixed horrible bug in read8, left ALL CALL enabled on reset.
Changed in this revision
| Adafruit_PWMServoDriver.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Adafruit_PWMServoDriver.cpp Sat Dec 14 06:04:33 2013 +0000
+++ b/Adafruit_PWMServoDriver.cpp Sun Jan 05 22:26:12 2014 +0000
@@ -32,7 +32,10 @@
void Adafruit_PWMServoDriver::reset(void) {
- write8(PCA9685_MODE1, 0x0);
+
+ // leave the ALL CALL address enabled (we might use that!)
+ // if you don't want ALL CALL, write 00 to offset 00
+ write8(PCA9685_MODE1, 0x1);
}
void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
@@ -76,8 +79,10 @@
uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) {
char data;
- _i2c->write(_i2caddr, &data, 1, true);
- _i2c->read(_i2caddr, &data, 1);
+ if(_i2c->write(_i2caddr, (char *)&addr, 1, true))
+ printf("no ack on write before read.\n");
+ if(_i2c->read(_i2caddr, &data, 1))
+ printf("no ack on read\n");
return (uint8_t)data;
}
@@ -85,6 +90,6 @@
char data[] = { addr, d };
if(_i2c->write(_i2caddr, data, 2))
{
- //("No ACK on i2c write!");
+ printf("No ACK on i2c write!");
}
}
\ No newline at end of file