2014-05-24 06:09:18 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-11 08:21:21 +08:00
|
|
|
|
2014-05-24 06:09:18 +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()
|
2014-08-02 00:46:07 +08:00
|
|
|
a := api.NewAPI(gbot)
|
|
|
|
a.Port = "8080"
|
|
|
|
a.Start()
|
2014-05-24 06:09:18 +08:00
|
|
|
|
|
|
|
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
|
|
|
|
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
|
|
|
|
|
|
|
|
work := func() {
|
2016-08-30 23:53:29 +08:00
|
|
|
pebbleDriver.On(pebbleDriver.Event("accel"), func(data interface{}) {
|
2014-05-24 06:09:18 +08:00
|
|
|
fmt.Println(data.(string))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-09 09:36:14 +08:00
|
|
|
robot := gobot.NewRobot("pebble",
|
|
|
|
[]gobot.Connection{pebbleAdaptor},
|
|
|
|
[]gobot.Device{pebbleDriver},
|
|
|
|
work,
|
|
|
|
)
|
2014-05-24 06:09:18 +08:00
|
|
|
|
2014-07-09 09:36:14 +08:00
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
2014-05-24 06:09:18 +08:00
|
|
|
}
|