2014-05-23 17:09:18 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-10 17:21:21 -07:00
|
|
|
|
2014-05-23 17:09:18 -05:00
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/api"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/pebble"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-15 20:02:54 +02:00
|
|
|
gbot := gobot.NewMaster()
|
2014-08-01 09:46:07 -07:00
|
|
|
a := api.NewAPI(gbot)
|
|
|
|
a.Port = "8080"
|
|
|
|
a.Start()
|
2014-05-23 17:09:18 -05:00
|
|
|
|
2016-10-03 16:58:43 +02:00
|
|
|
pebbleAdaptor := pebble.NewAdaptor()
|
|
|
|
pebbleDriver := pebble.NewDriver(pebbleAdaptor)
|
2014-05-23 17:09:18 -05:00
|
|
|
|
|
|
|
work := func() {
|
2016-08-30 17:53:29 +02:00
|
|
|
pebbleDriver.On(pebbleDriver.Event("accel"), func(data interface{}) {
|
2014-05-23 17:09:18 -05:00
|
|
|
fmt.Println(data.(string))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-08 18:36:14 -07:00
|
|
|
robot := gobot.NewRobot("pebble",
|
|
|
|
[]gobot.Connection{pebbleAdaptor},
|
|
|
|
[]gobot.Device{pebbleDriver},
|
|
|
|
work,
|
|
|
|
)
|
2014-05-23 17:09:18 -05:00
|
|
|
|
2014-07-08 18:36:14 -07:00
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
2014-05-23 17:09:18 -05:00
|
|
|
}
|