examples: Correct adafruit examples to use new drivers package location

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2016-10-15 19:55:43 +02:00
parent 6c1e392b18
commit 64ae34f40f
3 changed files with 10 additions and 9 deletions

View File

@ -10,7 +10,6 @@ import (
) )
func adafruitDCMotorRunner(a *i2c.AdafruitMotorHatDriver, dcMotor int) (err error) { func adafruitDCMotorRunner(a *i2c.AdafruitMotorHatDriver, dcMotor int) (err error) {
log.Printf("DC Motor Run Loop...\n") log.Printf("DC Motor Run Loop...\n")
// set the speed: // set the speed:
var speed int32 = 255 // 255 = full speed! var speed int32 = 255 // 255 = full speed!
@ -37,10 +36,11 @@ func adafruitDCMotorRunner(a *i2c.AdafruitMotorHatDriver, dcMotor int) (err erro
} }
return return
} }
func main() { func main() {
gbot := gobot.NewGobot() gbot := gobot.NewGobot()
r := raspi.NewRaspiAdaptor("raspi") r := raspi.NewAdaptor()
adaFruit := i2c.NewAdafruitMotorHatDriver(r, "adafruit") adaFruit := i2c.NewAdafruitMotorHatDriver(r)
work := func() { work := func() {
gobot.Every(5*time.Second, func() { gobot.Every(5*time.Second, func() {

View File

@ -26,6 +26,7 @@ func degree2pulse(deg int) int32 {
pulse += ((servoMax - servoMin) / maxDegree) * deg pulse += ((servoMax - servoMin) / maxDegree) * deg
return int32(pulse) return int32(pulse)
} }
func adafruitServoMotorRunner(a *i2c.AdafruitMotorHatDriver) (err error) { func adafruitServoMotorRunner(a *i2c.AdafruitMotorHatDriver) (err error) {
log.Printf("Servo Motor Run Loop...\n") log.Printf("Servo Motor Run Loop...\n")
// Changing from the default 0x40 address because this configuration involves // Changing from the default 0x40 address because this configuration involves
@ -64,14 +65,14 @@ func adafruitServoMotorRunner(a *i2c.AdafruitMotorHatDriver) (err error) {
} }
return return
} }
func main() { func main() {
gbot := gobot.NewGobot() gbot := gobot.NewGobot()
r := raspi.NewRaspiAdaptor("raspi") r := raspi.NewAdaptor()
adaFruit := i2c.NewAdafruitMotorHatDriver(r, "adafruit") adaFruit := i2c.NewAdafruitMotorHatDriver(r)
work := func() { work := func() {
gobot.Every(5*time.Second, func() { gobot.Every(5*time.Second, func() {
adafruitServoMotorRunner(adaFruit) adafruitServoMotorRunner(adaFruit)
}) })
} }

View File

@ -28,14 +28,14 @@ func adafruitStepperMotorRunner(a *i2c.AdafruitMotorHatDriver, motor int) (err e
} }
return return
} }
func main() { func main() {
gbot := gobot.NewGobot() gbot := gobot.NewGobot()
r := raspi.NewRaspiAdaptor("raspi") r := raspi.NewAdaptor()
adaFruit := i2c.NewAdafruitMotorHatDriver(r, "adafruit") adaFruit := i2c.NewAdafruitMotorHatDriver(r)
work := func() { work := func() {
gobot.Every(5*time.Second, func() { gobot.Every(5*time.Second, func() {
motor := 0 // 0-based motor := 0 // 0-based
adafruitStepperMotorRunner(adaFruit, motor) adafruitStepperMotorRunner(adaFruit, motor)
}) })