34 lines
613 B
Go
34 lines
613 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
"github.com/hybridgroup/gobot/api"
|
|
"github.com/hybridgroup/gobot/platforms/pebble"
|
|
)
|
|
|
|
func main() {
|
|
gbot := gobot.NewGobot()
|
|
api.NewAPI(gbot).Start()
|
|
|
|
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
|
|
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
|
|
|
|
work := func() {
|
|
gobot.On(pebbleDriver.Event("accel"), func(data interface{}) {
|
|
fmt.Println(data.(string))
|
|
})
|
|
}
|
|
|
|
robot := gobot.NewRobot("pebble",
|
|
[]gobot.Connection{pebbleAdaptor},
|
|
[]gobot.Device{pebbleDriver},
|
|
work,
|
|
)
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
gbot.Start()
|
|
}
|