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

pca9685: n -> channel

This commit is contained in:
Karan Misra 2014-01-07 12:40:22 +05:30
parent 0e32dc099e
commit 236cd2fd33

View File

@ -103,12 +103,12 @@ func (d *PCA9685) setup() (err error) {
// SetPwm sets the ON and OFF time registers for pwm signal shaping. // SetPwm sets the ON and OFF time registers for pwm signal shaping.
// channel: 0-15 // channel: 0-15
// onTime/offTime: 0-4095 // onTime/offTime: 0-4095
func (d *PCA9685) SetPwm(n, onTime, offTime int) (err error) { func (d *PCA9685) SetPwm(channel, onTime, offTime int) (err error) {
if err = d.setup(); err != nil { if err = d.setup(); err != nil {
return return
} }
onTimeLowReg := byte(pwm0OnLowReg + (4 * n)) onTimeLowReg := byte(pwm0OnLowReg + (4 * channel))
onTimeLow := byte(onTime & 0xFF) onTimeLow := byte(onTime & 0xFF)
onTimeHigh := byte(onTime >> 8) onTimeHigh := byte(onTime >> 8)
@ -119,7 +119,7 @@ func (d *PCA9685) SetPwm(n, onTime, offTime int) (err error) {
return return
} }
if d.Debug { if d.Debug {
log.Printf("pca9685: writing On-Time Low [%#02x] to CHAN%v_ON_L reg [RegAddr: %#02x]", onTimeLow, n, onTimeLowReg) log.Printf("pca9685: writing On-Time Low [%#02x] to CHAN%v_ON_L reg [RegAddr: %#02x]", onTimeLow, channel, onTimeLowReg)
} }
onTimeHighReg := onTimeLowReg + 1 onTimeHighReg := onTimeLowReg + 1
@ -127,7 +127,7 @@ func (d *PCA9685) SetPwm(n, onTime, offTime int) (err error) {
return return
} }
if d.Debug { if d.Debug {
log.Printf("pca9685: writing On-Time High [%#02x] to CHAN%v_ON_H reg [RegAddr: %#02x]", onTimeHigh, n, onTimeHighReg) log.Printf("pca9685: writing On-Time High [%#02x] to CHAN%v_ON_H reg [RegAddr: %#02x]", onTimeHigh, channel, onTimeHighReg)
} }
offTimeLowReg := onTimeHighReg + 1 offTimeLowReg := onTimeHighReg + 1
@ -135,7 +135,7 @@ func (d *PCA9685) SetPwm(n, onTime, offTime int) (err error) {
return return
} }
if d.Debug { if d.Debug {
log.Printf("pca9685: writing Off-Time Low [%#02x] to CHAN%v_OFF_L reg [RegAddr: %#02x]", offTimeLow, n, offTimeLowReg) log.Printf("pca9685: writing Off-Time Low [%#02x] to CHAN%v_OFF_L reg [RegAddr: %#02x]", offTimeLow, channel, offTimeLowReg)
} }
offTimeHighReg := offTimeLowReg + 1 offTimeHighReg := offTimeLowReg + 1
@ -143,7 +143,7 @@ func (d *PCA9685) SetPwm(n, onTime, offTime int) (err error) {
return return
} }
if d.Debug { if d.Debug {
log.Printf("pca9685: writing Off-Time High [%#02x] to CHAN%v_OFF_H reg [RegAddr: %#02x]", offTimeHigh, n, offTimeHighReg) log.Printf("pca9685: writing Off-Time High [%#02x] to CHAN%v_OFF_H reg [RegAddr: %#02x]", offTimeHigh, channel, offTimeHighReg)
} }
return return