2014-04-26 18:11:51 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-05-23 10:22:14 +08:00
|
|
|
"github.com/hybridgroup/gobot/platforms/firmata"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/i2c"
|
2014-04-26 18:11:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2014-05-23 10:22:14 +08:00
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
firmataAdaptor := firmata.NewFirmataAdaptor("firmata", "/dev/ttyACM0")
|
|
|
|
wiichuck := i2c.NewWiichuckDriver(firmataAdaptor, "wiichuck")
|
2014-04-26 18:11:51 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
gobot.On(wiichuck.Events["joystick"], func(data interface{}) {
|
|
|
|
fmt.Println("joystick")
|
|
|
|
})
|
|
|
|
|
|
|
|
gobot.On(wiichuck.Events["c_button"], func(data interface{}) {
|
|
|
|
fmt.Println("c")
|
|
|
|
})
|
|
|
|
|
|
|
|
gobot.On(wiichuck.Events["z_button"], func(data interface{}) {
|
|
|
|
fmt.Println("z")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-05-23 10:22:14 +08:00
|
|
|
gbot.Robots = append(gbot.Robots,
|
|
|
|
gobot.NewRobot("chuck", []gobot.Connection{firmataAdaptor}, []gobot.Device{wiichuck}, work))
|
2014-04-26 18:11:51 +08:00
|
|
|
|
2014-05-23 10:22:14 +08:00
|
|
|
gbot.Start()
|
2014-04-26 18:11:51 +08:00
|
|
|
}
|