pca9685: fix on=0 bug

Setting on to zero caused PWM signal to be set to high.
This commit is contained in:
Patricio Whittingslow
2022-02-25 10:41:42 -03:00
committed by Ron Evans
parent 01fed475e1
commit 2476cd7bd8
+3 -7
View File
@@ -89,18 +89,14 @@ func (d Dev) Top() uint32 {
}
// Set sets the `on` value of a PWM channel in the range [0..15].
// Max value `on` can take is 4095.
// Example:
// d.Set(1, d.Top()/4)
// sets the dutycycle of second (LED1) channel to 25%.
func (d Dev) Set(channel uint8, on uint32) {
switch {
case on > maxtop:
panic("pca9685: value must be in range 0..4096")
case on == 0:
d.SetPhased(channel, 0, maxtop)
return
if on > maxtop {
panic("pca9685: value must be in range 0..4095")
}
d.SetPhased(channel, on, 0)
}