gobot.io/x/gobot/v2@v2.1.0/examples/leap_motion.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.MessageEvent, func(data interface{}) {
    22  			fmt.Println(data.(leap.Frame))
    23  		})
    24  	}
    25  
    26  	robot := gobot.NewRobot("leapBot",
    27  		[]gobot.Connection{leapMotionAdaptor},
    28  		[]gobot.Device{l},
    29  		work,
    30  	)
    31  
    32  	robot.Start()
    33  }