dotstar

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: 2 Imported by: 7

README

DotStar RGB LED

GoDoc

Manufacturer info

DotStar LEDs are 5050-sized LEDs with an embedded microcontroller inside the LED. You can set the color/brightness of each LED to 24-bit color (8 bits each red green and blue). Each LED acts like a shift register, reading incoming color data on the input pins, and then shifting the previous color data out on the output pin. By sending a long string of data, you can control an infinite number of LEDs, just tack on more or cut off unwanted LEDs at the end.

Adafruit DotStar

##Datasheets:

Documentation

Overview

Package dotstar implements a driver for the dotstar LEDs.

Example
package main

import (
	"github.com/goiot/devices/dotstar"
	"golang.org/x/exp/io/spi"
)

func main() {
	d, err := dotstar.Open( // a strip with 5 LEDs
		&spi.Devfs{Dev: "/dev/spi0.1", Mode: spi.Mode3}, 5)
	if err != nil {
		panic(err)
	}

	d.SetRGBA(0, dotstar.RGBA{255, 0, 0, 16}) // Red
	d.SetRGBA(1, dotstar.RGBA{0, 255, 0, 16}) // Green
	d.SetRGBA(2, dotstar.RGBA{0, 0, 255, 16}) // Blue
	d.SetRGBA(3, dotstar.RGBA{255, 0, 0, 8})  // Half dim red
	d.SetRGBA(4, dotstar.RGBA{0, 0, 255, 8})  // Half dim blue

	if err := d.Draw(); err != nil {
		panic(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LEDs

type LEDs struct {
	// Device is the underlying SPI bus that is used to communicate the
	// LED strip. Most users don't have to access this field.
	Device *spi.Device
	// contains filtered or unexported fields
}

LEDs represent a strip of dotstar LEDs.

func Open

func Open(o driver.Opener, n int) (*LEDs, error)

Open opens a new LED strip with n dotstar LEDs. An LED strip must be closed if no longer in use.

func (*LEDs) Close

func (d *LEDs) Close() error

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

func (*LEDs) Draw

func (d *LEDs) Draw() error

Draw displays the RGBA values set on the actual LED strip.

func (*LEDs) SetRGBA

func (d *LEDs) SetRGBA(i int, v RGBA)

SetRGBA sets the ith LED's color to the given RGBA value. A call to Draw is required to transmit the new value to the LED strip.

type RGBA

type RGBA struct {
	R byte // R represents the red intensity.
	G byte // G represents the green intensity.
	B byte // B represents the blue intensity.
	A byte // A is the brightness of the LED. Must be between 0 and 15.
}

RGBA represents the color of a dostar LED.

Directories

Path Synopsis
examples
helloworld
Package main contains a program that drives a dotstar LED strip.
Package main contains a program that drives a dotstar LED strip.
random
Package main contains a program that drives a dotstar LED strip.
Package main contains a program that drives a dotstar LED strip.

Jump to

Keyboard shortcuts

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