hybridgroup.gobot/examples/pebble_accelerometer.go

34 lines
613 B
Go
Raw Normal View History

package main
import (
"fmt"
2014-07-11 08:21:21 +08:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
"github.com/hybridgroup/gobot/platforms/pebble"
)
func main() {
2014-07-09 09:36:14 +08:00
gbot := gobot.NewGobot()
api.NewAPI(gbot).Start()
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
work := func() {
2014-07-09 09:36:14 +08:00
gobot.On(pebbleDriver.Event("accel"), func(data interface{}) {
fmt.Println(data.(string))
})
}
2014-07-09 09:36:14 +08:00
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{pebbleDriver},
work,
)
2014-07-09 09:36:14 +08:00
gbot.AddRobot(robot)
gbot.Start()
}