README

Gopherbrick

brickpi provides BrickPi-specific functions for the Go ev3dev interface

Build Status Coverage Status GoDoc

github.com/ev3go/ev3dev depends on ev3dev stretch.

Example code

package main

import (
	"log"
	"time"

	"github.com/ev3go/brickpi"
)

func main() {
	var bright byte
	var err error
	for i := 0; i < 10; i++ {
		err = brickpi.Blue1.SetBrightness(int(bright)).Err()
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(time.Second)

		bright = ^bright

		err = brickpi.Blue2.SetBrightness(int(bright)).Err()
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(time.Second)
	}
}

Documentation

Overview

Package brickpi provides brickpi-specific and higher level access to the ev3dev control and sensor drivers.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Blue1 and Blue2 are the blue LEDs on
	// the BrickPi board.
	Blue1 = &ev3dev.LED{Name: brickPiLED(1)}
	Blue2 = &ev3dev.LED{Name: brickPiLED(2)}

	// Green and Red are the green and red LEDs
	// on the Raspberry Pi board.
	//
	// These LED devices are normally writable
	// only by root, so permissions will need
	// to be correctly set prior to use.
	Green = &ev3dev.LED{Name: raspberryPiLED(0)}
	Red   = &ev3dev.LED{Name: raspberryPiLED(1)}
)

LED handles for BrickPi devices.

Functions

func SensorFor

func SensorFor(port, driver string) (*ev3dev.Sensor, error)

SensorFor returns an ev3dev.Sensor for the given BrickPi port name and driver. SensorFor uses the default address for the device. When the sensor is no longer being used, Unregister should be called for the port.

BrickPi and BrickPi+ sensor port names are:

- serial0-0:S1
- serial0-0:S2
- serial0-0:S3
- serial0-0:S4

BrickPi3 sensor port names are:

- spi0.1:S1
- spi0.1:S2
- spi0.1:S3
- spi0.1:S4

func SensorForAddr

func SensorForAddr(port, driver string, addr int) (*ev3dev.Sensor, error)

SensorForAddr returns an ev3dev.Sensor for the given BrickPi port name, driver and address. When the sensor is no longer being used, Unregister should be called for the port.

func Unregister

func Unregister(port string) error

Unregister sets the lego-port mode to "none".

Types

This section is empty.

Notes

Bugs

  • Device drivers for NXT/I2C devices with special operations will not work with the BrickPi.

  • EV3 UART sensors do not work correctly, apparently due to timing problems in the Dexter Industries firmware for the BrickPi devices.

    See https://github.com/DexterInd/BrickPi/issues/24

Directories

Path Synopsis
examples
motor
motor demonstrates using a motor on a BrickPi.
motor demonstrates using a motor on a BrickPi.
sensor
sensor demonstrates using a sensor on a BrickPi.
sensor demonstrates using a sensor on a BrickPi.