Package com.diozero.ws281xj.spi
Class WS281xSpi
- java.lang.Object
-
- com.diozero.ws281xj.spi.WS281xSpi
-
- All Implemented Interfaces:
LedDriverInterface,AutoCloseable
public class WS281xSpi extends Object implements LedDriverInterface
References: https://os.mbed.com/users/JacobBramley/code/PixelArray/file/47802e75974e/neopixel.cpp https://github.com/jgarff/rpi_ws281x/blob/master/ws2811.c
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWS281xSpi.Protocol
-
Constructor Summary
Constructors Constructor Description WS281xSpi(int controller, int chipSelect, WS281xSpi.Protocol protocol, StripType stripType, int numLeds, int brightness)WS281xSpi(int controller, int chipSelect, StripType stripType, int numLeds, int brightness)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidallOff()Turn off all pixels and render.voidclose()intgetNumPixels()intgetPixelColour(int pixel)Get the current colour for the specified pixel.voidrender()Pixels are sent as follows: - The first transmitted pixel is the pixel closest to the transmitter.voidsetPixelColour(int pixel, int colour)Set the colour for the specified pixel.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.diozero.ws281xj.LedDriverInterface
getBlueComponent, getGreenComponent, getRedComponent, setBlueComponent, setGreenComponent, setPixelColourHSB, setPixelColourHSL, setPixelColourRGB, setRedComponent
-
-
-
-
Constructor Detail
-
WS281xSpi
public WS281xSpi(int controller, int chipSelect, StripType stripType, int numLeds, int brightness)
-
WS281xSpi
public WS281xSpi(int controller, int chipSelect, WS281xSpi.Protocol protocol, StripType stripType, int numLeds, int brightness)
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceLedDriverInterface
-
getNumPixels
public int getNumPixels()
- Specified by:
getNumPixelsin interfaceLedDriverInterface
-
getPixelColour
public int getPixelColour(int pixel)
Description copied from interface:LedDriverInterfaceGet the current colour for the specified pixel.- Specified by:
getPixelColourin interfaceLedDriverInterface- Parameters:
pixel- Pixel number.- Returns:
- 24-bit RGB colour value.
-
setPixelColour
public void setPixelColour(int pixel, int colour)Description copied from interface:LedDriverInterfaceSet the colour for the specified pixel.- Specified by:
setPixelColourin interfaceLedDriverInterface- Parameters:
pixel- Pixel number.colour- Colour represented as a 24bit RGB integer (0x0RGB).
-
render
public void render()
Pixels are sent as follows: - The first transmitted pixel is the pixel closest to the transmitter. - The most significant bit is always sent first. g7,g6,g5,g4,g3,g2,g1,g0,r7,r6,r5,r4,r3,r2,r1,r0,b7,b6,b5,b4,b3,b2,b1,b0 \_____________________________________________________________________/ | _________________... | / __________________... | / / ___________________... | / / / GRB,GRB,GRB,GRB,... For BYTE_ORDER_RGB, the order of the first two bytes are reversed.- Specified by:
renderin interfaceLedDriverInterface
-
allOff
public void allOff()
Description copied from interface:LedDriverInterfaceTurn off all pixels and render.- Specified by:
allOffin interfaceLedDriverInterface
-
-