raspi

package
v0.0.0-...-1595f01 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2014 License: Apache-2.0 Imports: 8 Imported by: 0

README

Raspi

This package contains the Gobot adaptor for the Raspberry Pi.

Getting Started

First you must install the appropriate Go packages

go get -d -u github.com/hybridgroup/gobot/... && go install github.com/hybridgroup/gobot/platforms/raspi
Cross compiling for the Raspberry Pi

You must first configure your Go environment for linux cross compiling

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

Then compile your Gobot program with

$ GOARM=6 GOARCH=arm GOOS=linux examples/raspi_blink.go

Then you can simply upload your program over the network from your host computer to the Raspi

$ scp raspi_blink pi@192.168.1.xxx:/home/pi/

and execute it on your Raspberry Pi with

$ ./raspi_blink

Example

package main

import (
        "time"

        "github.com/hybridgroup/gobot"
        "github.com/hybridgroup/gobot/platforms/gpio"
        "github.com/hybridgroup/gobot/platforms/raspi"
)

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

        r := raspi.NewRaspiAdaptor("raspi")
        led := gpio.NewLedDriver(r, "led", "7")

        work := func() {
                gobot.Every(1*time.Second, func() {
                        led.Toggle()
                })
        }

        robot := gobot.NewRobot("blinkBot",
                []gobot.Connection{r},
                []gobot.Device{led},
                work,
        )

        gbot.AddRobot(robot)

        gbot.Start()
}

Documentation

Overview

Package raspi contains the Gobot adaptor for the Raspberry Pi.

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RaspiAdaptor

type RaspiAdaptor struct {
	gobot.Adaptor
	// contains filtered or unexported fields
}

func NewRaspiAdaptor

func NewRaspiAdaptor(name string) *RaspiAdaptor

NewRaspiAdaptor creates a RaspiAdaptor with specified name and

func (*RaspiAdaptor) Connect

func (r *RaspiAdaptor) Connect() bool

Connect starts conection with board and creates digitalPins and pwmPins adaptor maps

func (*RaspiAdaptor) DigitalRead

func (r *RaspiAdaptor) DigitalRead(pin string) (i int)

DigitalRead reads digital value from pin

func (*RaspiAdaptor) DigitalWrite

func (r *RaspiAdaptor) DigitalWrite(pin string, val byte)

DigitalWrite writes digital value to specified pin

func (*RaspiAdaptor) Finalize

func (r *RaspiAdaptor) Finalize() bool

Finalize closes connection to board and pins

func (*RaspiAdaptor) I2cRead

func (r *RaspiAdaptor) I2cRead(size uint) []byte

I2cRead returns value from i2c device using specified size

func (*RaspiAdaptor) I2cStart

func (r *RaspiAdaptor) I2cStart(address byte)

I2cStart starts a i2c device in specified address

func (*RaspiAdaptor) I2cWrite

func (r *RaspiAdaptor) I2cWrite(data []byte)

I2CWrite writes data to i2c device

func (*RaspiAdaptor) PwmWrite

func (r *RaspiAdaptor) PwmWrite(pin string, val byte)

PwmWrite Not Implemented

Jump to

Keyboard shortcuts

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