forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pebble.go
40 lines (31 loc) · 820 Bytes
/
pebble.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/api"
"github.com/hybridgroup/gobot/platforms/pebble"
)
func main() {
gbot := gobot.NewGobot()
api := api.NewAPI(gbot)
api.Port = "8080"
api.Start()
pebbleAdaptor := pebble.NewPebbleAdaptor("pebble")
pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble")
work := func() {
pebbleDriver.SendNotification("Hello Pebble!")
gobot.On(pebbleDriver.Event("button"), func(data interface{}) {
fmt.Println("Button pushed: " + data.(string))
})
gobot.On(pebbleDriver.Event("tap"), func(data interface{}) {
fmt.Println("Tap event detected")
})
}
robot := gobot.NewRobot("pebble",
[]gobot.Connection{pebbleAdaptor},
[]gobot.Device{pebbleDriver},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}