piglow

package
v0.0.0-...-09d1226 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2016 License: Apache-2.0 Imports: 3 Imported by: 3

README

#PiGlow

GoDoc

Manufacturer info

PiGlow

The PiGlow is a small add on board for the Raspberry Pi that provides 18 individually controllable LEDs. This board uses the SN3218 8-bit 18-channel PWM chip to drive 18 surface mount LEDs. Communication is done via I2C over the GPIO header with a bus address of 0x54. Each LED can be set to a PWM value of between 0 and 255.

##Datasheet:

Documentation

Overview

Package piglow implements a driver for the Pimoroni PiGlow.

Example
package main

import (
	"time"

	"github.com/goiot/devices/piglow"
	"golang.org/x/exp/io/i2c"
)

func main() {
	p, err := piglow.Open(&i2c.Devfs{Dev: "/dev/i2c-1"})
	if err != nil {
		panic(err)
	}

	if err := p.Setup(); err != nil {
		panic(err)
	}

	brightness := 0
	for i := 0; i < 10; i++ {
		brightness ^= 1
		p.SetBrightness(brightness)
		time.Sleep(300 * time.Millisecond)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PiGlow

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

PiGlow represents a PiGlow device

func Open

func Open(o driver.Opener) (*PiGlow, error)

Open opens a new PiGlow. A PiGlow must be closed if no longer in use. If the PiGlow has not been powered down since last use, it will be opened with it's last programmed state.

func (*PiGlow) Blue

func (p *PiGlow) Blue(level int) error

Blue sets all the blue LEDs to the level of 0-255.

func (*PiGlow) Close

func (p *PiGlow) Close() error

Close frees the underlying resources. It must be called once the PiGlow is no longer in use.

func (*PiGlow) Enable

func (p *PiGlow) Enable() error

Enable enables the PiGlow for normal operations

func (*PiGlow) Green

func (p *PiGlow) Green(level int) error

Green sets all the green LEDs to the level of 0-255.

func (*PiGlow) Orange

func (p *PiGlow) Orange(level int) error

Orange sets all the orange LEDs to the level of 0-255.

func (*PiGlow) Red

func (p *PiGlow) Red(level int) error

Red sets all the red LEDs to the level of 0-255.

func (*PiGlow) Reset

func (p *PiGlow) Reset() error

Reset resets the internal registers

func (*PiGlow) SetBrightness

func (p *PiGlow) SetBrightness(level int) error

SetBrightness sets all the LEDs to the level 0-255.

func (*PiGlow) SetLEDBrightness

func (p *PiGlow) SetLEDBrightness(led, level int) error

SetLEDBrightness sets the led 1-18 to the level 0-255.

func (*PiGlow) SetLEDControlRegister

func (p *PiGlow) SetLEDControlRegister(register, enables int) error

SetLEDControlRegister sets the control register 1-3 to the bitmask enables.

bitmask definition:
0 - LED disabled
1 - LED enabled
LED Control Register 1 - LED channel 1  to 6   bits 0-5
LED Control Register 2 - LED channel 7  to 12  bits 0-5
LED Control Register 3 - LED channel 13 to 18  bits 0-5

func (*PiGlow) Setup

func (p *PiGlow) Setup() error

Setup enables normal operations, resets the internal registers, and enables all LED control registers

func (*PiGlow) Shutdown

func (p *PiGlow) Shutdown() error

Shutdown sets the software shutdown mode of the PiGlow

func (*PiGlow) White

func (p *PiGlow) White(level int) error

White sets all the white LEDs to the level of 0-255.

func (*PiGlow) Yellow

func (p *PiGlow) Yellow(level int) error

Yellow sets all the yellow LEDs to the level of 0-255.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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