From 4a6492af0a8b9f456d0f09aea4dcccd1535bad3c Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 18 Aug 2015 17:45:10 -0600 Subject: [PATCH] pca9685: fix problem where setting pwm accidentally cleared full bits When setting the On or Off times, the FullOn or FullOff control bits would be improperly masked and therefore not preserved. Signed-off-by: Jon Trulson Signed-off-by: Sisinty Sasmita Patra --- src/pca9685/pca9685.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pca9685/pca9685.cxx b/src/pca9685/pca9685.cxx index 1b4e9bf3..900b4c99 100644 --- a/src/pca9685/pca9685.cxx +++ b/src/pca9685/pca9685.cxx @@ -182,9 +182,9 @@ bool PCA9685::ledFullOn(uint8_t led, bool val) uint8_t bits = readByte(regoff); if (val) - bits |= ((1 << 4) & 0xff); + bits |= 0x10; else - bits &= ~((1 << 4) & 0xff); + bits &= ~0x10; return writeByte(regoff, bits); } @@ -209,9 +209,9 @@ bool PCA9685::ledFullOff(uint8_t led, bool val) uint8_t bits = readByte(regoff); if (val) - bits |= ((1 << 4) & 0xff); + bits |= 0x10; else - bits &= ~((1 << 4) & 0xff); + bits &= ~0x10; return writeByte(regoff, bits); } @@ -240,7 +240,7 @@ bool PCA9685::ledOnTime(uint8_t led, uint16_t time) regoff = REG_LED0_ON_L + (led * 4); // we need to preserve the full ON bit in *_ON_H - uint8_t onbit = (readByte(regoff + 1) & 0x40); + uint8_t onbit = (readByte(regoff + 1) & 0x10); time = (time & 0x0fff) | (onbit << 8); @@ -271,7 +271,7 @@ bool PCA9685::ledOffTime(uint8_t led, uint16_t time) regoff = REG_LED0_ON_L + (led * 4) + 2; // we need to preserve the full OFF bit in *_OFF_H - uint8_t offbit = (readByte(regoff + 1) & 0x40); + uint8_t offbit = (readByte(regoff + 1) & 0x10); time = (time & 0x0fff) | (offbit << 8);