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 TypeMethodDescriptionintGet the current brightness value of the stripintgetDma()intintintGet the number of LEDs in this striplonggetPixel(int pixel) Get the color of a pixelintbooleanisInvert()voidrender()Render the current values to the physical light strip.voidsetBrightness(int brightness) Set the brightness value from 0-255voidsetPixel(int pixel, int red, int green, int blue) Set the color of an individual pixelvoidSet the color of an individual pixelvoidsetStrip(int red, int green, int blue) Set all LEDs in the strip to one colorvoidSet 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_ws281xConstantsWs281xLedStrip(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_ws281xConstantsclearOnExit- 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:LedStripSet the brightness value from 0-255- Specified by:
setBrightnessin interfaceLedStrip- Parameters:
brightness- The brightnes to set the strip to
-
getLedsCount
public int getLedsCount()Description copied from interface:LedStripGet the number of LEDs in this strip- Specified by:
getLedsCountin 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:LedStripGet the current brightness value of the strip- Specified by:
getBrightnessin interfaceLedStrip- Returns:
- The current brightness value
-
getPwmChannel
public int getPwmChannel() -
isInvert
public boolean isInvert() -
getStripType
-