Skip to content

Commit 2476cd7

Browse files
soypatdeadprogram
authored andcommitted
pca9685: fix on=0 bug
Setting on to zero caused PWM signal to be set to high.
1 parent 01fed47 commit 2476cd7

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

pca9685/pca9685.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,14 @@ func (d Dev) Top() uint32 {
8989
}
9090

9191
// Set sets the `on` value of a PWM channel in the range [0..15].
92+
// Max value `on` can take is 4095.
9293
// Example:
9394
// d.Set(1, d.Top()/4)
9495
// sets the dutycycle of second (LED1) channel to 25%.
9596
func (d Dev) Set(channel uint8, on uint32) {
96-
switch {
97-
case on > maxtop:
98-
panic("pca9685: value must be in range 0..4096")
99-
case on == 0:
100-
d.SetPhased(channel, 0, maxtop)
101-
return
97+
if on > maxtop {
98+
panic("pca9685: value must be in range 0..4095")
10299
}
103-
104100
d.SetPhased(channel, on, 0)
105101
}
106102

0 commit comments

Comments
 (0)