Package com.diozero.ws281xj
Interface LedDriverInterface
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
Apa102LedDriver,WS281x,WS281xSpi
public interface LedDriverInterface extends AutoCloseable
-
Method Summary
Modifier and Type Method Description voidallOff()Turn off all pixels and render.voidclose()default intgetBlueComponent(int pixel)Get the 8-bit blue component value for the specified pixel.default intgetGreenComponent(int pixel)Get the 8-bit green component value for the specified pixel.intgetNumPixels()intgetPixelColour(int pixel)Get the current colour for the specified pixel.default intgetRedComponent(int pixel)Get the 8-bit red component value for the specified pixel.voidrender()Push any updated colours to the LED strip.default voidsetBlueComponent(int pixel, int blue)Set the 8-bit blue component value for the specified pixel.default voidsetGreenComponent(int pixel, int green)Set the 8-bit green component value for the specified pixel.voidsetPixelColour(int pixel, int colour)Set the colour for the specified pixel.default voidsetPixelColourHSB(int pixel, float hue, float saturation, float brightness)Set the colour for the specified pixel using Hue Saturation Brightness (HSB) values.default voidsetPixelColourHSL(int pixel, float hue, float saturation, float luminance)Set the colour for the specified pixel using Hue Saturation Luminance (HSL) values.default voidsetPixelColourRGB(int pixel, int red, int green, int blue)Set the colour for the specified pixel using individual red / green / blue 8-bit values.default voidsetRedComponent(int pixel, int red)Set the 8-bit red component value for the specified pixel.
-
Method Details
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-
getNumPixels
int getNumPixels() -
render
void render()Push any updated colours to the LED strip. -
allOff
void allOff()Turn off all pixels and render. -
getPixelColour
int getPixelColour(int pixel)Get the current colour for the specified pixel.- Parameters:
pixel- Pixel number.- Returns:
- 24-bit RGB colour value.
-
setPixelColour
void setPixelColour(int pixel, int colour)Set the colour for the specified pixel.- Parameters:
pixel- Pixel number.colour- Colour represented as a 24bit RGB integer (0x0RGB).
-
setPixelColourRGB
default void setPixelColourRGB(int pixel, int red, int green, int blue)Set the colour for the specified pixel using individual red / green / blue 8-bit values.- Parameters:
pixel- Pixel number.red- 8-bit value for the red component.green- 8-bit value for the green component.blue- 8-bit value for the blue component.
-
setPixelColourHSB
default void setPixelColourHSB(int pixel, float hue, float saturation, float brightness)Set the colour for the specified pixel using Hue Saturation Brightness (HSB) values.- Parameters:
pixel- Pixel number.hue- Float value in the range 0..1 representing the hue.saturation- Float value in the range 0..1 representing the colour saturation.brightness- Float value in the range 0..1 representing the colour brightness.
-
setPixelColourHSL
default void setPixelColourHSL(int pixel, float hue, float saturation, float luminance)Set the colour for the specified pixel using Hue Saturation Luminance (HSL) values.
HSL colour mapping code taken from this HSL Color class by Rob Camick.
- Parameters:
pixel- Pixel number.hue- Represents the colour (think colours of the rainbow), specified in degrees from 0 - 360. Red is 0, green is 120 and blue is 240.saturation- Represents the purity of the colour. Range is 0..1 with 1 fully saturated and 0 gray.luminance- Represents the brightness of the colour. Range is 0..1 with 1 white 0 black.
-
getRedComponent
default int getRedComponent(int pixel)Get the 8-bit red component value for the specified pixel.- Parameters:
pixel- Pixel number.- Returns:
- 8-bit red component value.
-
setRedComponent
default void setRedComponent(int pixel, int red)Set the 8-bit red component value for the specified pixel.- Parameters:
pixel- Pixel number.red- 8-bit red component value.
-
getGreenComponent
default int getGreenComponent(int pixel)Get the 8-bit green component value for the specified pixel.- Parameters:
pixel- Pixel number.- Returns:
- 8-bit green component value.
-
setGreenComponent
default void setGreenComponent(int pixel, int green)Set the 8-bit green component value for the specified pixel.- Parameters:
pixel- Pixel number.green- 8-bit green component value.
-
getBlueComponent
default int getBlueComponent(int pixel)Get the 8-bit blue component value for the specified pixel.- Parameters:
pixel- Pixel number.- Returns:
- 8-bit blue component value.
-
setBlueComponent
default void setBlueComponent(int pixel, int blue)Set the 8-bit blue component value for the specified pixel.- Parameters:
pixel- Pixel number.blue- 8-bit blue component value.
-