2017-03-13 11:01:39 -04:00
|
|
|
// +build example
|
|
|
|
//
|
|
|
|
// Do not build by default.
|
|
|
|
|
2014-04-27 17:43:15 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-07-10 17:21:21 -07:00
|
|
|
|
2016-12-08 13:24:03 +01:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/platforms/leap"
|
2014-04-27 17:43:15 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-03 16:58:43 +02:00
|
|
|
leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
|
|
|
|
l := leap.NewDriver(leapMotionAdaptor)
|
2014-04-27 17:43:15 -07:00
|
|
|
|
|
|
|
work := func() {
|
2016-09-01 12:17:43 +02:00
|
|
|
l.On(leap.HandEvent, func(data interface{}) {
|
2015-07-02 14:40:13 -07:00
|
|
|
printHand(data.(leap.Hand))
|
2014-04-27 17:43:15 -07:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-08 18:36:14 -07:00
|
|
|
robot := gobot.NewRobot("leapBot",
|
|
|
|
[]gobot.Connection{leapMotionAdaptor},
|
|
|
|
[]gobot.Device{l},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-18 21:08:25 +02:00
|
|
|
robot.Start()
|
2014-04-27 17:43:15 -07:00
|
|
|
}
|
|
|
|
|
2015-07-02 14:40:13 -07:00
|
|
|
func printHand(hand leap.Hand) {
|
|
|
|
fmt.Println("Hand", hand)
|
2014-04-27 17:43:15 -07:00
|
|
|
}
|