2016-07-11 02:28:20 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/ble"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
bleAdaptor := ble.NewBLEClientAdaptor("ble", os.Args[1])
|
|
|
|
ollie := ble.NewSpheroOllieDriver(bleAdaptor, "ollie")
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
ollie.SetRGB(255, 0, 255)
|
2016-07-11 02:37:58 +08:00
|
|
|
gobot.Every(3*time.Second, func() {
|
|
|
|
ollie.Roll(30, uint16(gobot.Rand(360)))
|
2016-07-11 02:28:20 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("ollieBot",
|
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{ollie},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|