hybridgroup.gobot/examples/pebble_accelerometer.go

36 lines
645 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()
a := api.NewAPI(gbot)
a.Port = "8080"
a.Start()
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
work := func() {
pebbleDriver.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()
}