chip

package
v1.0.0 Latest Latest
Warning

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

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

README

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

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"

Documentation

Overview

Package chip contains the Gobot adaptor for the CHIP

For further information refer to the chip README: https://gobot.io/x/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 Adaptor added in v1.0.0

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

Adaptor represents a Gobot Adaptor for a C.H.I.P.

func NewAdaptor added in v1.0.0

func NewAdaptor() *Adaptor

NewAdaptor creates a C.H.I.P. Adaptor

func (*Adaptor) Connect added in v1.0.0

func (c *Adaptor) Connect() (err error)

Connect initializes the board

func (*Adaptor) DigitalRead added in v1.0.0

func (c *Adaptor) 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 (*Adaptor) DigitalWrite added in v1.0.0

func (c *Adaptor) 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 (*Adaptor) Finalize added in v1.0.0

func (c *Adaptor) Finalize() (err error)

Finalize closes connection to board and pins

func (*Adaptor) I2cRead added in v1.0.0

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

I2cRead returns value from i2c device using specified size

func (*Adaptor) I2cStart added in v1.0.0

func (c *Adaptor) 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 (*Adaptor) I2cWrite added in v1.0.0

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

I2cWrite writes data to i2c device

func (*Adaptor) Name added in v1.0.0

func (c *Adaptor) Name() string

Name returns the name of the Adaptor

func (*Adaptor) SetName added in v1.0.0

func (c *Adaptor) SetName(n string)

SetName sets the name of the Adaptor

Jump to

Keyboard shortcuts

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