Fix full on/off in pca9685.
It's currently not possible to toggle between full off and full on, as switching to full on leaves the full off control bit set. The full off control bit takes precedence according to the datasheet, which means the signal remains off. The 'normal' branch does correctly clear full off/full on, as it writes 0s to the `LEDn_ON` registers unconditionally and writes 0 to the control bit in `LEDn_OFF`.
This commit is contained in:
parent
48e4132996
commit
acfd46aa60
1 changed files with 3 additions and 0 deletions
|
@ -185,6 +185,7 @@ void pca9685_set_pwm_value(i2c_dev_t *dev, uint8_t channel, uint16_t val)
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
{
|
{
|
||||||
// Full off
|
// Full off
|
||||||
|
// Takes precedence over full on.
|
||||||
write_reg(dev, reg + OFFS_REG_LED_OFF, LED_FULL_ON_OFF);
|
write_reg(dev, reg + OFFS_REG_LED_OFF, LED_FULL_ON_OFF);
|
||||||
}
|
}
|
||||||
else if (val < 4096)
|
else if (val < 4096)
|
||||||
|
@ -195,6 +196,8 @@ void pca9685_set_pwm_value(i2c_dev_t *dev, uint8_t channel, uint16_t val)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Clear full off, as it takes precedence over full on.
|
||||||
|
write_reg(dev, reg + OFFS_REG_LED_OFF, 0);
|
||||||
// Full on
|
// Full on
|
||||||
write_reg(dev, reg + OFFS_REG_LED_ON, LED_FULL_ON_OFF);
|
write_reg(dev, reg + OFFS_REG_LED_ON, LED_FULL_ON_OFF);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue