2014-05-03 06:22:05 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2014-05-24 06:09:18 +08:00
|
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/api"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/pebble"
|
2014-05-03 06:22:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-05-24 06:09:18 +08:00
|
|
|
master := gobot.NewGobot()
|
|
|
|
api.NewApi(master).Start()
|
2014-05-03 06:22:05 +08:00
|
|
|
|
2014-05-24 06:09:18 +08:00
|
|
|
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
|
|
|
|
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
|
2014-05-03 06:22:05 +08:00
|
|
|
|
2014-05-24 06:09:18 +08:00
|
|
|
work := func() {
|
|
|
|
pebbleDriver.SendNotification("Hello Pebble!")
|
|
|
|
gobot.On(pebbleDriver.Events["button"], func(data interface{}) {
|
|
|
|
fmt.Println("Button pushed: " + data.(string))
|
|
|
|
})
|
2014-05-03 06:22:05 +08:00
|
|
|
|
2014-05-24 06:09:18 +08:00
|
|
|
gobot.On(pebbleDriver.Events["tap"], func(data interface{}) {
|
|
|
|
fmt.Println("Tap event detected")
|
|
|
|
})
|
|
|
|
}
|
2014-05-03 06:22:05 +08:00
|
|
|
|
2014-05-24 06:09:18 +08:00
|
|
|
robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work)
|
2014-05-03 06:22:05 +08:00
|
|
|
|
2014-05-24 06:09:18 +08:00
|
|
|
master.Robots = append(master.Robots, robot)
|
|
|
|
master.Start()
|
2014-05-03 06:22:05 +08:00
|
|
|
}
|