Skip to content

Commit

Permalink
Resolve issue with PWM for PWMWrite
Browse files Browse the repository at this point in the history
4096 is outside of the value that is able to be written to a pin. Lowered the scale and updated the comments
  • Loading branch information
imle authored and deadprogram committed Oct 29, 2020
1 parent cf368e9 commit 4a30f5b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/i2c/pca9685_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (p *PCA9685Driver) Halt() (err error) {
return
}

// SetPWM sets a specific channel to a pwm value from 0-4096.
// SetPWM sets a specific channel to a pwm value from 0-4095.
// Params:
// channel int - the channel to send the pulse
// on uint16 - the time to start the pulse
Expand Down Expand Up @@ -174,7 +174,7 @@ func (p *PCA9685Driver) SetPWM(channel int, on uint16, off uint16) (err error) {
return
}

// SetAllPWM sets all channels to a pwm value from 0-4096.
// SetAllPWM sets all channels to a pwm value from 0-4095.
// Params:
// on uint16 - the time to start the pulse
// off uint16 - the time to stop the pulse
Expand Down Expand Up @@ -255,7 +255,7 @@ func (p *PCA9685Driver) PwmWrite(pin string, val byte) (err error) {
if err != nil {
return
}
v := gobot.ToScale(gobot.FromScale(float64(val), 0, 255), 0, 4096)
v := gobot.ToScale(gobot.FromScale(float64(val), 0, 255), 0, 4095)
return p.SetPWM(i, 0, uint16(v))
}

Expand Down

0 comments on commit 4a30f5b

Please sign in to comment.