gobot.io/x/gobot/v2@v2.1.0/examples/leap_motion_gestures.go (about)

     1  //go:build example
     2  // +build example
     3  
     4  //
     5  // Do not build by default.
     6  
     7  package main
     8  
     9  import (
    10  	"fmt"
    11  
    12  	"gobot.io/x/gobot/v2"
    13  	"gobot.io/x/gobot/v2/platforms/leap"
    14  )
    15  
    16  func main() {
    17  	leapMotionAdaptor := leap.NewAdaptor("127.0.0.1:6437")
    18  	l := leap.NewDriver(leapMotionAdaptor)
    19  
    20  	work := func() {
    21  		l.On(leap.GestureEvent, func(data interface{}) {
    22  			printGesture(data.(leap.Gesture))
    23  		})
    24  	}
    25  
    26  	robot := gobot.NewRobot("leapBot",
    27  		[]gobot.Connection{leapMotionAdaptor},
    28  		[]gobot.Device{l},
    29  		work,
    30  	)
    31  
    32  	robot.Start()
    33  }
    34  
    35  func printGesture(gesture leap.Gesture) {
    36  	fmt.Println("Gesture", gesture)
    37  }