hybridgroup.gobot/platforms/chip
deadprogram cd6d46d8a4 core: Refactor C.H.I.P. platform for new Adaptor creation signature
Signed-off-by: deadprogram <ron@hybridgroup.com>
2016-09-25 20:19:19 +02:00
..
LICENSE misc: update all LICENSE files for current year 2016-08-27 13:12:47 +02:00
README.md core: Refactor C.H.I.P. platform for new Adaptor creation signature 2016-09-25 20:19:19 +02:00
chip_adaptor.go core: Refactor C.H.I.P. platform for new Adaptor creation signature 2016-09-25 20:19:19 +02:00
chip_adaptor_test.go core: Refactor C.H.I.P. platform for new Adaptor creation signature 2016-09-25 20:19:19 +02:00
doc.go Add support for the CHIP platform 2016-02-17 12:25:14 -08:00

README.md

CHIP

The CHIP is a small, inexpensive ARM based single board computer, with many different IO interfaces available on the pin headers.

For documentation about the CHIP platform click here.

How to Install

go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/chip

Cross compiling for the CHIP

If you're using Go version earlier than 1.5, you must first configure your Go environment for ARM linux cross compiling.

$ cd $GOROOT/src
$ GOOS=linux GOARCH=arm ./make.bash --no-clean

The above step is not required for Go >= 1.5

Then compile your Gobot program with

$ GOARM=7 GOARCH=arm GOOS=linux go build examples/chip_button.go

Then you can simply upload your program to the CHIP and execute it with

$ scp chip_button root@192.168.1.xx:
$ ssh -t root@192.168.1.xx "./chip_button"

How to Use

package main

import (
    "fmt"

    "github.com/hybridgroup/gobot"
    "github.com/hybridgroup/gobot/platforms/chip"
    "github.com/hybridgroup/gobot/drivers/gpio"
)

func main() {
    gbot := gobot.NewGobot()

    chipAdaptor := chip.NewAdaptor()
    button := gpio.NewButtonDriver(chipAdaptor, "XIO-P0")

    work := func() {
        gobot.On(button.Event("push"), func(data interface{}) {
            fmt.Println("button pressed")
        })

        gobot.On(button.Event("release"), func(data interface{}) {
            fmt.Println("button released")
        })
    }

    robot := gobot.NewRobot("buttonBot",
        []gobot.Connection{chipAdaptor},
        []gobot.Device{button},
        work,
    )
    gbot.AddRobot(robot)
    gbot.Start()
}