java.lang.Object
com.github.mbelling.ws281x.Ws281xLedStrip
- All Implemented Interfaces:
LedStrip
Basic class to interface with the rpi_ws281x native library
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with the following settings: ledCount = 100 gpioPin = 18 frequenchHz = 800000 dma = 10 brightness = 255 pwmChannel = 0 invert = false stripType = WS2811_STRIP_RGBWs281xLedStrip
(int ledsCount, int gpioPin, int frequencyHz, int dma, boolean invert, LedStripType stripType, boolean clearOnExit) Create an LED strip with the given settings -
Method Summary
Modifier and TypeMethodDescriptionint
Get the current brightness value of the stripint
getDma()
int
int
int
Get the number of LEDs in this striplong
getPixel
(int pixel) Get the color of a pixelint
boolean
isInvert()
void
render()
Render the current values to the physical light strip.void
setBrightness
(int brightness) Set the brightness value from 0-255void
setPixel
(int pixel, int red, int green, int blue) Set the color of an individual pixelvoid
Set the color of an individual pixelvoid
setStrip
(int red, int green, int blue) Set all LEDs in the strip to one colorvoid
Set all LEDs in the strip to one color
-
Constructor Details
-
Ws281xLedStrip
public Ws281xLedStrip()Default constructor with the following settings:- ledCount = 100
- gpioPin = 18
- frequenchHz = 800000
- dma = 10
- brightness = 255
- pwmChannel = 0
- invert = false
- stripType = WS2811_STRIP_RGB
- See Also:
-
rpi_ws281xConstants
Ws281xLedStrip(int, int, int, int, boolean, LedStripType, boolean)
-
Ws281xLedStrip
public Ws281xLedStrip(int ledsCount, int gpioPin, int frequencyHz, int dma, boolean invert, LedStripType stripType, boolean clearOnExit) Create an LED strip with the given settings- Parameters:
ledsCount
- The number of LEDs in the stripgpioPin
- The Raspberry Pi GPIO pinfrequencyHz
- Frequency of updates in Hertzdma
- DMA to useinvert
- Whether or not to invert color valuesstripType
- The type of LED Striprpi_ws281xConstants
clearOnExit
- Clear LEDs on exit
-
-
Method Details
-
setPixel
public void setPixel(int pixel, int red, int green, int blue) Set the color of an individual pixel -
setPixel
Set the color of an individual pixel -
setStrip
public void setStrip(int red, int green, int blue) Set all LEDs in the strip to one color -
setStrip
Set all LEDs in the strip to one color -
getPixel
public long getPixel(int pixel) Get the color of a pixel -
render
public void render()Render the current values to the physical light strip.This method needs to be called after any previous setPixel calls to make the lights change to those colors.
-
setBrightness
public void setBrightness(int brightness) Description copied from interface:LedStrip
Set the brightness value from 0-255- Specified by:
setBrightness
in interfaceLedStrip
- Parameters:
brightness
- The brightnes to set the strip to
-
getLedsCount
public int getLedsCount()Description copied from interface:LedStrip
Get the number of LEDs in this strip- Specified by:
getLedsCount
in interfaceLedStrip
- Returns:
- The number of LEDs
-
getGpioPin
public int getGpioPin() -
getFrequencyHz
public int getFrequencyHz() -
getDma
public int getDma() -
getBrightness
public int getBrightness()Description copied from interface:LedStrip
Get the current brightness value of the strip- Specified by:
getBrightness
in interfaceLedStrip
- Returns:
- The current brightness value
-
getPwmChannel
public int getPwmChannel() -
isInvert
public boolean isInvert() -
getStripType
-