forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hybridgroup#452 from ulisesflynn/grove
Added grove support, and more gopigo3 examples
- Loading branch information
Showing
8 changed files
with
892 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/gpio" | ||
"gobot.io/x/gobot/platforms/dexter/gopigo3" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
raspiAdaptor := raspi.NewAdaptor() | ||
gpg3 := gopigo3.NewDriver(raspiAdaptor) | ||
led := gpio.NewGroveLedDriver(gpg3, "AD_1_1") | ||
button := gpio.NewGroveButtonDriver(gpg3, "AD_2_1") | ||
|
||
work := func() { | ||
button.On(gpio.ButtonPush, func(data interface{}) { | ||
fmt.Println("On!") | ||
led.On() | ||
}) | ||
button.On(gpio.ButtonRelease, func(data interface{}) { | ||
fmt.Println("Off!") | ||
led.Off() | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("gopigo3button", | ||
[]gobot.Connection{raspiAdaptor}, | ||
[]gobot.Device{gpg3, button, led}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/i2c" | ||
"gobot.io/x/gobot/platforms/dexter/gopigo3" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
raspiAdaptor := raspi.NewAdaptor() | ||
gpg3 := gopigo3.NewDriver(raspiAdaptor) | ||
screen := i2c.NewGroveLcdDriver(raspiAdaptor) | ||
|
||
work := func() { | ||
manufacturerName := "" | ||
boardName := "" | ||
hardwareVersion := "" | ||
manufacturerName, _ = gpg3.GetManufacturerName() | ||
boardName, _ = gpg3.GetBoardName() | ||
hardwareVersion, _ = gpg3.GetHardwareVersion() | ||
screen.Write(manufacturerName[0:15]) | ||
screen.SetPosition(16) | ||
screen.Write(boardName + " " + hardwareVersion) | ||
screen.SetRGB(0, 0, 255) | ||
screen.Home() | ||
} | ||
|
||
robot := gobot.NewRobot("gopigo3lcd", | ||
[]gobot.Connection{raspiAdaptor}, | ||
[]gobot.Device{gpg3, screen}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/aio" | ||
"gobot.io/x/gobot/platforms/dexter/gopigo3" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
raspiAdaptor := raspi.NewAdaptor() | ||
gpg3 := gopigo3.NewDriver(raspiAdaptor) | ||
sensor := aio.NewGroveLightSensorDriver(gpg3, "AD_1_1") | ||
|
||
work := func() { | ||
sensor.On(sensor.Event("data"), func(data interface{}) { | ||
fmt.Println("sensor", data) | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("gopigo3sensor", | ||
[]gobot.Connection{raspiAdaptor}, | ||
[]gobot.Device{gpg3, sensor}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/gpio" | ||
"gobot.io/x/gobot/platforms/dexter/gopigo3" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
raspiAdaptor := raspi.NewAdaptor() | ||
gpg3 := gopigo3.NewDriver(raspiAdaptor) | ||
led := gpio.NewGroveLedDriver(gpg3, "AD_1_1") | ||
|
||
work := func() { | ||
brightness := uint8(0) | ||
fadeAmount := uint8(15) | ||
|
||
gobot.Every(100*time.Millisecond, func() { | ||
led.Brightness(brightness) | ||
brightness = brightness + fadeAmount | ||
if brightness == 0 || brightness == 255 { | ||
fadeAmount = -fadeAmount | ||
} | ||
}) | ||
} | ||
|
||
robot := gobot.NewRobot("gopigo3pwm", | ||
[]gobot.Connection{raspiAdaptor}, | ||
[]gobot.Device{gpg3, led}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// +build example | ||
// | ||
// Do not build by default. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"gobot.io/x/gobot" | ||
"gobot.io/x/gobot/drivers/gpio" | ||
"gobot.io/x/gobot/platforms/dexter/gopigo3" | ||
"gobot.io/x/gobot/platforms/raspi" | ||
) | ||
|
||
func main() { | ||
raspiAdaptor := raspi.NewAdaptor() | ||
gpg3 := gopigo3.NewDriver(raspiAdaptor) | ||
servo := gpio.NewServoDriver(gpg3, "SERVO_1") | ||
|
||
work := func() { | ||
gobot.Every(1*time.Second, func() { | ||
i := uint8(gobot.Rand(180)) | ||
fmt.Println("Turning", i) | ||
servo.Move(i) | ||
}) | ||
|
||
} | ||
|
||
robot := gobot.NewRobot("gopigo3servo", | ||
[]gobot.Connection{raspiAdaptor}, | ||
[]gobot.Device{gpg3, servo}, | ||
work, | ||
) | ||
|
||
robot.Start() | ||
} |
Oops, something went wrong.