piglow

package module
v0.0.0-...-a160f48 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2014 License: MIT Imports: 2 Imported by: 2

README

piglow

go-piglow is a small lib for controlling the Piglow from Go on your Raspberry Pi.

See the Piglow github page for details on how to set up your Raspberry Pi for this to work.

Example

package main

import (
	"github.com/wjessop/go-piglow"
	"log"
)

func main() {
	var p *piglow.Piglow
	var err error

	// Create a new Piglow
	p, err = piglow.NewPiglow(); if err != nil {
		log.Fatal("Couldn't create a Piglow: ", err)
	}

	p.SetLED(0, 255) // Set LED 0 to 255 (max brightness)
	p.SetLED(1, 128) // Set LED 1 to half brightness
	err = p.Apply(); if err != nil { // Apply the changes
		log.Fatal("Couldn't apply changes: ", err)
	}
}

Cross compile for the Raspberry pi with:

GOOS=linux GOARM=6 GOARCH=arm go build

See examples/example.go for a list of functions you can use. The other files in examples/* are more complex/fun examples of how to use the lib.

Notes

  • The LEDs aren't in order, experiment to find out which is which
  • Setting all LEDs to 255 will probably hurt your eyes, I don't recommend it
  • The lib isn't thread-safe (It could be, but I don't see the point) , so only create one instance of Piglow

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Author

Documentation

Index

Constants

View Source
const (
	CMD_ENABLE_OUTPUT  byte = 0x00
	CMD_ENABLE_LEDS    byte = 0x13
	CMD_SET_PWM_VALUES byte = 0x01
	CMD_UPDATE         byte = 0x16
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Piglow

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

func NewPiglow

func NewPiglow() (piglow *Piglow, err error)

func (*Piglow) Apply

func (p *Piglow) Apply() (err error)

func (*Piglow) DisplayValueOnTentacle

func (p *Piglow) DisplayValueOnTentacle(tentacle int, val float64, max_val float64, brightness uint8, direction bool)

Display a value on a tentacle. tentacle: 0-2, the tentacle to display the value val: the value to display max_val: the range in which to display the value. If val equals, or goes above this all LEDs will be lit. brightness: What the max brightness should be for fully list LEDs direction: start the display from the centre out, or the outside in

func (*Piglow) SetAll

func (p *Piglow) SetAll(brightness uint8)

Set all LEDs to brightness

func (*Piglow) SetBlue

func (p *Piglow) SetBlue(brightness uint8)

func (*Piglow) SetGreen

func (p *Piglow) SetGreen(brightness uint8)

func (*Piglow) SetLED

func (p *Piglow) SetLED(n int8, brightness uint8)

Set LED n to brightness n must be 0 through 17 brightness must be 0 through 255

func (*Piglow) SetOrange

func (p *Piglow) SetOrange(brightness uint8)

func (*Piglow) SetRed

func (p *Piglow) SetRed(brightness uint8)

func (*Piglow) SetTentacle

func (p *Piglow) SetTentacle(tentacle int, brightness uint8)

Set all LEDs along the whole of a tentacle to brightness

func (*Piglow) SetWhite

func (p *Piglow) SetWhite(brightness uint8)

func (*Piglow) SetYellow

func (p *Piglow) SetYellow(brightness uint8)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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