This is a library for our Adafruit 16-channel PWM or any other board that uses the PCA9685 I2C PWM driver chip.
Dependents: K9_Head_Controller
Revision 6:a76057c4c7ac, committed 2021-06-26
- Comitter:
- SomeRandomBloke
- Date:
- Sat Jun 26 12:05:53 2021 +0000
- Parent:
- 5:9ff15661ddd6
- Commit message:
- moved to Mbed OS 6
Changed in this revision
Adafruit_PWMServoDriver.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 9ff15661ddd6 -r a76057c4c7ac Adafruit_PWMServoDriver.cpp --- a/Adafruit_PWMServoDriver.cpp Tue Sep 08 16:18:49 2020 +0000 +++ b/Adafruit_PWMServoDriver.cpp Sat Jun 26 12:05:53 2021 +0000 @@ -48,9 +48,9 @@ prescaleval /= 4096; prescaleval /= freq; prescaleval -= 1; - //printf("Estimated pre-scale: %f\r\n", prescaleval); + //debug("Estimated pre-scale: %f\r\n", prescaleval); uint8_t prescale = floor(prescaleval + 0.5); - //printf("Final pre-scale: %f", prescale); + //debug("Final pre-scale: %f", prescale); uint8_t oldmode = read8(PCA9685_MODE1); uint8_t newmode = (oldmode&0x7F) | 0x10; // sleep @@ -68,23 +68,14 @@ uint8_t data[] = { (uint8_t)(LED0_ON_L+4*num), (uint8_t)on, (uint8_t)(on >> 8), (uint8_t)off, (uint8_t)(off >> 8) }; _i2c->write(_i2caddr, (const char *)data, 5); - /* - 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(); - */ } uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) { char data; if(_i2c->write(_i2caddr, (char *)&addr, 1, true)) - printf("I2C ERR: no ack on write before read.\n"); + debug("I2C ERR: no ack on write before read.\n"); if(_i2c->read(_i2caddr, &data, 1)) - printf("I2C ERR: no ack on read\n"); + debug("I2C ERR: no ack on read\n"); return (uint8_t)data; } @@ -92,6 +83,6 @@ char data[] = { addr, d }; if(_i2c->write(_i2caddr, data, 2)) { - printf("I2C ERR: No ACK on i2c write!"); + debug("I2C ERR: No ACK on i2c write!"); } } \ No newline at end of file