1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00

41 lines
813 B
Go
Raw Normal View History

2014-05-02 17:22:05 -05:00
package main
import (
"fmt"
2014-07-10 17:21:21 -07:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
"github.com/hybridgroup/gobot/platforms/pebble"
2014-05-02 17:22:05 -05:00
)
func main() {
master := gobot.NewMaster()
api := api.NewAPI(master)
2014-07-31 13:56:50 -05:00
api.Port = "8080"
api.Start()
2014-05-02 17:22:05 -05:00
pebbleAdaptor := pebble.NewAdaptor()
pebbleDriver := pebble.NewDriver(pebbleAdaptor)
2014-05-02 17:22:05 -05:00
work := func() {
pebbleDriver.SendNotification("Hello Pebble!")
pebbleDriver.On(pebbleDriver.Event("button"), func(data interface{}) {
fmt.Println("Button pushed: " + data.(string))
})
2014-05-02 17:22:05 -05:00
pebbleDriver.On(pebbleDriver.Event("tap"), func(data interface{}) {
fmt.Println("Tap event detected")
})
}
2014-05-02 17:22:05 -05:00
2014-07-08 18:36:14 -07:00
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{pebbleDriver},
work,
)
2014-05-02 17:22:05 -05:00
master.AddRobot(robot)
2014-07-10 17:21:21 -07:00
master.Start()
2014-05-02 17:22:05 -05:00
}