chip

package
v0.0.0-...-5340811 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2016 License: Apache-2.0, Apache-2.0 Imports: 2 Imported by: 0

README

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/platforms/gpio"
)

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

    chipAdaptor := chip.NewChipAdaptor("chip")
    button := gpio.NewButtonDriver(chipAdaptor, "button", "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()
}

Documentation

Overview

Package chip contains the Gobot adaptor for the CHIP

For further information refer to the chip README: https://github.com/hybridgroup/gobot/blob/master/platforms/chip/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChipAdaptor

type ChipAdaptor struct {
	// contains filtered or unexported fields
}

func NewChipAdaptor

func NewChipAdaptor(name string) *ChipAdaptor

NewChipAdaptor creates a ChipAdaptor with the specified name

func (*ChipAdaptor) Connect

func (c *ChipAdaptor) Connect() (errs []error)

Connect initializes the board

func (*ChipAdaptor) DigitalRead

func (c *ChipAdaptor) DigitalRead(pin string) (val int, err error)

DigitalRead reads digital value from the specified pin. Valids pins are XIO-P0 through XIO-P7 (pins 13-20 on header 14).

func (*ChipAdaptor) DigitalWrite

func (c *ChipAdaptor) DigitalWrite(pin string, val byte) (err error)

DigitalWrite writes digital value to the specified pin. Valids pins are XIO-P0 through XIO-P7 (pins 13-20 on header 14).

func (*ChipAdaptor) Finalize

func (c *ChipAdaptor) Finalize() (errs []error)

Finalize closes connection to board and pins

func (*ChipAdaptor) I2cRead

func (c *ChipAdaptor) I2cRead(address int, size int) (data []byte, err error)

I2cRead returns value from i2c device using specified size

func (*ChipAdaptor) I2cStart

func (c *ChipAdaptor) I2cStart(address int) (err error)

I2cStart starts an i2c device in specified address. This assumes that the bus used is /dev/i2c-1, which corresponds to pins labeled TWI1-SDA and TW1-SCK (pins 9 and 11 on header 13).

func (*ChipAdaptor) I2cWrite

func (c *ChipAdaptor) I2cWrite(address int, data []byte) (err error)

I2cWrite writes data to i2c device

func (*ChipAdaptor) Name

func (c *ChipAdaptor) Name() string

Name returns the name of the ChipAdaptor

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL