1
0
mirror of https://github.com/kidoman/embd synced 2024-12-22 04:40:04 +01:00

pca9685: bug fixes

This commit is contained in:
Karan Misra 2014-01-08 03:41:53 +05:30
parent c83bd5bf6c
commit f6ed134486
2 changed files with 4 additions and 4 deletions

View File

@ -123,7 +123,7 @@ func (d *PCA9685) SetPwm(channel, onTime, offTime int) (err error) {
}
onTimeHighReg := onTimeLowReg + 1
if err = d.Bus.WriteByteToReg(d.Addr, onTimeHighReg, onTimeHighReg); err != nil {
if err = d.Bus.WriteByteToReg(d.Addr, onTimeHighReg, onTimeHigh); err != nil {
return
}
if d.Debug {
@ -171,7 +171,7 @@ func (d *PCA9685) Close() (err error) {
log.Printf("pca9685: cleaning up all PWM control registers")
}
for regAddr := 0x0; regAddr <= 0x45; regAddr++ {
for regAddr := 0x06; regAddr <= 0x45; regAddr++ {
if err = d.Bus.WriteByteToReg(d.Addr, byte(regAddr), 0x00); err != nil {
return
}

View File

@ -16,11 +16,11 @@ func main() {
log.Panic(err)
}
pca9685 := pca9685.New(bus, 0x41, 1000)
pca9685 := pca9685.New(bus, 0x42, 1000)
pca9685.Debug = true
defer pca9685.Close()
if err := pca9685.SetPwm(15, 0, 2000); err != nil {
if err := pca9685.SetPwm(0, 0, 2000); err != nil {
log.Panic(err)
}