public class WS281x extends Object implements LedDriverInterface
Provides support for WS2811B / WS2812B aka Adafriut NeoPixel LEDs via a JNI wrapper around the rpi_ws281x C library.
Also see this implementation.
All colours are represented as 24bit RGB values.
Valid GPIO numbers:
| Constructor and Description |
|---|
WS281x(int gpioNum,
int brightness,
int numPixels) |
WS281x(int frequency,
int dmaNum,
int gpioNum,
int brightness,
int numPixels,
StripType stripType) |
WS281x(int frequency,
int dmaNum,
int gpioNum,
int brightness,
int numPixels,
StripType stripType,
int channel) |
| Modifier and Type | Method and Description |
|---|---|
void |
allOff()
Turn off all pixels and render.
|
void |
close() |
int |
getNumPixels() |
int |
getPixelColour(int pixel)
Get the current colour for the specified pixel.
|
void |
render()
Push any updated colours to the LED strip.
|
void |
setPixelColour(int pixel,
int colour)
Set the colour for the specified pixel.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetBlueComponent, getGreenComponent, getRedComponent, setBlueComponent, setGreenComponent, setPixelColourHSB, setPixelColourHSL, setPixelColourRGB, setRedComponentpublic WS281x(int gpioNum,
int brightness,
int numPixels)
gpioNum - GPIO pin to use to drive the LEDs.brightness - Brightness level (0..255).numPixels - The number of pixels connected.public WS281x(int frequency,
int dmaNum,
int gpioNum,
int brightness,
int numPixels,
StripType stripType)
frequency - Communication frequency, 800,000 or 400,000.dmaNum - DMA number.gpioNum - GPIO pin to use to drive the LEDs.brightness - Brightness level (0..255).numPixels - The number of pixels connected.stripType - Strip typepublic WS281x(int frequency,
int dmaNum,
int gpioNum,
int brightness,
int numPixels,
StripType stripType,
int channel)
frequency - Communication frequency, 800,000 or 400,000.dmaNum - DMA number.gpioNum - GPIO pin to use to drive the LEDs.brightness - Brightness level (0..255).numPixels - The number of pixels connected.stripType - Strip typechannel - PWM channelpublic void close()
close in interface LedDriverInterfaceclose in interface Closeableclose in interface AutoCloseablepublic int getNumPixels()
getNumPixels in interface LedDriverInterfacepublic void render()
LedDriverInterfacerender in interface LedDriverInterfacepublic void allOff()
LedDriverInterfaceallOff in interface LedDriverInterfacepublic int getPixelColour(int pixel)
LedDriverInterfacegetPixelColour in interface LedDriverInterfacepixel - Pixel number.public void setPixelColour(int pixel,
int colour)
LedDriverInterfacesetPixelColour in interface LedDriverInterfacepixel - Pixel number.colour - Colour represented as a 24bit RGB integer (0x0RGB).Copyright © 2016–2018 mattjlewis. All rights reserved.