hybridgroup.gobot/platforms/leap/README.md

49 lines
922 B
Markdown
Raw Normal View History

2014-07-07 03:17:10 +08:00
# Leap
2014-06-10 10:01:53 +08:00
This package provides the Gobot adaptor and driver for the [Leap Motion](https://www.leapmotion.com/)
## Getting Started
2014-06-10 10:01:53 +08:00
First install the [Leap Motion Software](https://www.leapmotion.com/setup)
Now you can install the package with
```
2014-07-07 03:17:10 +08:00
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/leap
2014-06-10 10:01:53 +08:00
```
## Example
```go
package main
import (
"fmt"
2014-07-11 08:02:00 +08:00
"github.com/hybridgroup/gobot"
2014-06-10 10:01:53 +08:00
"github.com/hybridgroup/gobot/platforms/leap"
)
func main() {
2014-06-10 10:01:53 +08:00
gbot := gobot.NewGobot()
2014-07-11 08:02:00 +08:00
leapMotionAdaptor := leap.NewLeapMotionAdaptor("leap", "127.0.0.1:6437")
l := leap.NewLeapMotionDriver(leapMotionAdaptor, "leap")
work := func() {
2014-07-11 08:02:00 +08:00
gobot.On(l.Event("message"), func(data interface{}) {
2014-06-10 10:01:53 +08:00
fmt.Println(data.(leap.Frame))
})
}
2014-07-11 08:02:00 +08:00
robot := gobot.NewRobot("leapBot",
[]gobot.Connection{leapMotionAdaptor},
[]gobot.Device{l},
work,
)
gbot.AddRobot(robot)
2014-06-10 10:01:53 +08:00
gbot.Start()
}
2014-07-11 08:02:00 +08:00
```