Documentation ¶
Overview ¶
Package nrzled is a driver for LEDs ws2811/ws2812/ws2812b and compatible devices like sk6812 and ucs1903 that uses a single wire NRZ encoded communication protocol.
Note that some ICs are 7 bits with the least significant bit ignored, others are using a real 8 bits PWM. The PWM frequency varies across ICs.
Datasheet ¶
This directory contains datasheets for ws2812, ws2812b, ucs190x and various sk6812.
https://github.com/cpldcpu/light_ws2812/tree/master/Datasheets
UCS1903 datasheet ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOpts = Opts{ NumPixels: 150, Channels: 3, Freq: 800 * physic.KiloHertz, }
DefaultOpts is the recommended default options.
Functions ¶
func NRZ ¶
NRZ converts a byte into the MSB-first Non-Return-to-Zero encoded 24 bits.
The upper 8 bits are zeros and shall be ignored.
The Non-return-to-zero protocol is a self-clocking signal that enables one-way communication without the need of a dedicated clock signal, unlike SPI driven LEDs like the apa102.
See https://en.wikipedia.org/wiki/Non-return-to-zero for more technical details.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is a handle to the LED strip.
func New ¶
func New(p gpiostream.PinOut, opts *Opts) (*Dev, error)
New opens a handle to a compatible LED strip.
func (*Dev) Draw ¶
Draw implements display.Drawer.
Using something else than image.NRGBA is 10x slower and is not recommended. When using image.NRGBA, the alpha channel is ignored in RGB mode and used as White channel in RGBW mode.
A back buffer is kept so that partial updates are supported, albeit the full LED strip is updated synchronously.
type Opts ¶
type Opts struct { // NumPixels is the number of pixels to control. If too short, the following // pixels will be corrupted. If too long, the pixels will be drawn // unnecessarily but not visible issue will occur. NumPixels int // Channels is 1 for single color LEDs, 3 for RGB LEDs and 4 for RGBW (white) // LEDs. Channels int // Freq is the frequency to use to drive the LEDs. It should be either 800kHz // for fast ICs and 400kHz for the slow ones. Freq physic.Frequency }
Opts defines the options for the device.