hybridgroup.gobot/platforms/chip
deadprogram d405b7a5c7 test: remove test code no longer being called
Signed-off-by: deadprogram <ron@hybridgroup.com>
2017-04-02 15:57:23 +02:00
..
LICENSE license: update license year to include 2017 2017-01-02 22:25:17 +01:00
README.md Updated README 2017-03-23 21:46:47 +01:00
chip_adaptor.go Added PWM0 support to c.h.i.p 2017-03-13 21:43:50 +01:00
chip_adaptor_test.go test: remove test code no longer being called 2017-04-02 15:57:23 +02:00
chip_pwm.go Added more tests for PWM 2017-03-14 00:11:06 +01:00
doc.go docs: correct C.H.I.P. readme link 2016-12-21 10:51:24 +01:00

README.md

C.H.I.P.

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

We recommend updating to the latest Debian OS when using the C.H.I.P., however Gobot should also support older versions of the OS, should your application require this.

For documentation about the C.H.I.P. platform click here.

How to Install

go get -d -u gobot.io/x/gobot/... && go install gobot.io/x/gobot/platforms/chip

PWM support

Note that PWM might not be available in your kernel. In that case, you can install the required device tree overlay from the command line using Gort CLI commands on the C.H.I.P device. Here are the steps:

Install the required patched device tree compiler as described in the C.H.I.P docs:

gort chip install dtc

Now, install the pwm overlay to activate pwm on the PWM0 pin:

gort chip install pwm

Reboot the device to make sure the init script loads the overlay on boot.

How to Use

The pin numbering used by your Gobot program should match the way your board is labeled right on the board itself.

package main

import (
    "fmt"

    "gobot.io/x/gobot"
    "gobot.io/x/gobot/drivers/gpio"
    "gobot.io/x/gobot/platforms/chip"
)

func main() {
    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,
    )

    robot.Start()
}

How to Connect

Compiling

Compile your Gobot program like this:

$ 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"