Removing the raspi_adafruit program as it has been split into three separate programs, removing my Makefile for the raspi adafruit programs, and fixing up a few comments.

This commit is contained in:
Josh Finken 2016-09-02 06:44:50 -06:00
parent 8a4e5a6771
commit 409cdfb041
4 changed files with 6 additions and 112 deletions

View File

@ -1,23 +0,0 @@
ip := 192.168.0.2
build_dcmotor := GOARM=7 GOARCH=arm GOOS=linux go build -v raspi_adafruit_dcmotor.go
build_stepper := GOARM=7 GOARCH=arm GOOS=linux go build -v raspi_adafruit_stepper.go
build_servo := GOARM=7 GOARCH=arm GOOS=linux go build -v raspi_adafruit_servo.go
all:
$(build_stepper)
$(build_dcmotor)
$(build_servo)
scp raspi_adafruit_stepper raspi_adafruit_dcmotor raspi_adafruit_servo pi@$(ip):~
stepper:
$(build_stepper)
scp raspi_adafruit_stepper pi@$(ip):~
dc:
$(build_dcmotor)
scp raspi_adafruit_dcmotor pi@$(ip):~
servo:
$(build_servo)
scp raspi_adafruit_servo pi@$(ip):~

View File

@ -1,82 +0,0 @@
package main
import (
"log"
"time"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/i2c"
"github.com/hybridgroup/gobot/platforms/raspi"
)
func adafruitStepperMotorRunner(a *i2c.AdafruitMotorHatDriver, motor int) (err error) {
log.Printf("Stepper Motor Run Loop...\n")
// set the speed state:
speed := 30 // rpm
a.SetStepperMotorSpeed(motor, speed)
//fmt.Println("Single coil steps")
if err = a.Step(motor, 100, i2c.AdafruitForward, i2c.AdafruitSingle); err != nil {
log.Printf(err.Error())
return
}
if err = a.Step(motor, 100, i2c.AdafruitBackward, i2c.AdafruitSingle); err != nil {
log.Printf(err.Error())
return
}
return
}
func adafruitDCMotorRunner(a *i2c.AdafruitMotorHatDriver, dcMotor int) (err error) {
log.Printf("DC Motor Run Loop...\n")
// set the speed:
var speed int32 = 255 // 255 = full speed!
if err = a.SetDCMotorSpeed(dcMotor, speed); err != nil {
return
}
// run FORWARD
if err = a.RunDCMotor(dcMotor, i2c.AdafruitForward); err != nil {
return
}
// Sleep and RELEASE
<-time.After(2000 * time.Millisecond)
if err = a.RunDCMotor(dcMotor, i2c.AdafruitRelease); err != nil {
return
}
// run BACKWARD
if err = a.RunDCMotor(dcMotor, i2c.AdafruitBackward); err != nil {
return
}
// Sleep and RELEASE
<-time.After(2000 * time.Millisecond)
if err = a.RunDCMotor(dcMotor, i2c.AdafruitRelease); err != nil {
return
}
return
}
func main() {
gbot := gobot.NewGobot()
r := raspi.NewRaspiAdaptor("raspi")
adaFruit := i2c.NewAdafruitMotorHatDriver(r, "adafruit")
work := func() {
gobot.Every(5*time.Second, func() {
//dcMotor := 3 // 0-based
//adafruitDCMotorRunner(adaFruit, dcMotor)
motor := 0 // 0-based
adafruitStepperMotorRunner(adaFruit, motor)
})
}
robot := gobot.NewRobot("adaFruitBot",
[]gobot.Connection{r},
[]gobot.Device{adaFruit},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}

View File

@ -13,8 +13,8 @@ func adafruitStepperMotorRunner(a *i2c.AdafruitMotorHatDriver, motor int) (err e
log.Printf("Stepper Motor Run Loop...\n")
// set the speed state:
speed := 30 // rpm
style := i2c.AdafruitMicrostep
steps := 50
style := i2c.AdafruitDouble
steps := 20
a.SetStepperMotorSpeed(motor, speed)

View File

@ -90,8 +90,8 @@ func TestAdafruitMotorHatDriverRunDCMotor(t *testing.T) {
ada, _ := initTestAdafruitMotorHatDriverWithStubbedAdaptor()
dcMotor := 1
// NOT using this prevents importing the i2c package
//dir := i2c.AdafruitForward
// NOTE: not using the direction constant to prevent importing
// the i2c package
err := ada.RunDCMotor(dcMotor, 1)
gobottest.Assert(t, err, nil)
}
@ -107,9 +107,8 @@ func TestAdafruitMotorHatDriverSetStepperMotorSpeed(t *testing.T) {
func TestAdafruitMotorHatDriverStepperStep(t *testing.T) {
ada, _ := initTestAdafruitMotorHatDriverWithStubbedAdaptor()
// NOT using these prevents importing the i2c package
//dir := i2c.AdafruitForward
//style := i2c.AdafruitMicrostep
// NOTE: not using the direction and style constants to prevent importing
// the i2c package
stepperMotor := 0
steps := 50
err := ada.Step(stepperMotor, steps, 1, 3)