hybridgroup.gobot/examples/pebble.go

33 lines
810 B
Go
Raw Normal View History

2014-05-03 06:22:05 +08:00
package main
import (
"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() {
master := gobot.NewGobot()
api.NewApi(master).Start()
2014-05-03 06:22:05 +08:00
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
2014-05-03 06:22:05 +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
gobot.On(pebbleDriver.Events["tap"], func(data interface{}) {
fmt.Println("Tap event detected")
})
}
2014-05-03 06:22:05 +08:00
robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work)
2014-05-03 06:22:05 +08:00
master.Robots = append(master.Robots, robot)
master.Start()
2014-05-03 06:22:05 +08:00
}