2016-07-09 11:52:48 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2016-07-10 12:08:34 -06:00
|
|
|
"time"
|
2016-09-01 13:32:40 +02:00
|
|
|
|
2016-07-09 11:52:48 -06:00
|
|
|
"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() {
|
2016-07-10 12:08:34 -06:00
|
|
|
gobot.Every(1*time.Second, func() {
|
|
|
|
r := uint8(gobot.Rand(255))
|
|
|
|
g := uint8(gobot.Rand(255))
|
|
|
|
b := uint8(gobot.Rand(255))
|
|
|
|
ollie.SetRGB(r, g, b)
|
|
|
|
})
|
2016-07-09 11:52:48 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("ollieBot",
|
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{ollie},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|