Package com.tinkerforge
Class BrickletLEDStrip
- java.lang.Object
-
- com.tinkerforge.DeviceBase
-
- com.tinkerforge.Device
-
- com.tinkerforge.BrickletLEDStrip
-
public class BrickletLEDStrip extends Device
Controls up to 320 RGB LEDs
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BrickletLEDStrip.FrameRenderedListener
This listener is triggered directly after a new frame is rendered.class
BrickletLEDStrip.RGBValues
class
BrickletLEDStrip.RGBWValues
-
Nested classes/interfaces inherited from class com.tinkerforge.Device
Device.Identity
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BrickletLEDStrip(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Adds a FrameRendered listener.void
disableFrameRenderedCallback()
Disables theBrickletLEDStrip.FrameRenderedListener
listener.void
enableFrameRenderedCallback()
Enables theBrickletLEDStrip.FrameRenderedListener
listener.short
getChannelMapping()
Returns the currently used channel mapping as set bysetChannelMapping(short)
.int
getChipType()
Returns the currently used chip type as set bysetChipType(int)
.long
getClockFrequency()
Returns the currently used clock frequency as set bysetClockFrequency(long)
.int
getFrameDuration()
Returns the frame duration as set bysetFrameDuration(int)
.Device.Identity
getIdentity()
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.BrickletLEDStrip.RGBValues
getRGBValues(int index, short length)
Returns *length* R, G and B values starting from the given LED *index*.BrickletLEDStrip.RGBWValues
getRGBWValues(int index, short length)
Returns *length* RGBW values starting from the given *index*.int
getSupplyVoltage()
Returns the current supply voltage of the LEDs.boolean
isFrameRenderedCallbackEnabled()
Returns *true* if theBrickletLEDStrip.FrameRenderedListener
listener is enabled, *false* otherwise.void
removeFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Removes a FrameRendered listener.void
setChannelMapping(short mapping)
Sets the channel mapping for the connected LEDs.void
setChipType(int chip)
Sets the type of the LED driver chip.void
setClockFrequency(long frequency)
Sets the frequency of the clock.void
setFrameDuration(int duration)
Sets the frame duration.void
setRGBValues(int index, short length, short[] r, short[] g, short[] b)
Sets *length* RGB values for the LEDs starting from *index*.void
setRGBWValues(int index, short length, short[] r, short[] g, short[] b, short[] w)
Sets *length* RGBW values for the LEDs starting from *index*.-
Methods inherited from class com.tinkerforge.DeviceBase
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
-
-
-
-
Field Detail
-
DEVICE_IDENTIFIER
public static final int DEVICE_IDENTIFIER
- See Also:
- Constant Field Values
-
DEVICE_DISPLAY_NAME
public static final java.lang.String DEVICE_DISPLAY_NAME
- See Also:
- Constant Field Values
-
FUNCTION_SET_RGB_VALUES
public static final byte FUNCTION_SET_RGB_VALUES
- See Also:
- Constant Field Values
-
FUNCTION_GET_RGB_VALUES
public static final byte FUNCTION_GET_RGB_VALUES
- See Also:
- Constant Field Values
-
FUNCTION_SET_FRAME_DURATION
public static final byte FUNCTION_SET_FRAME_DURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_FRAME_DURATION
public static final byte FUNCTION_GET_FRAME_DURATION
- See Also:
- Constant Field Values
-
FUNCTION_GET_SUPPLY_VOLTAGE
public static final byte FUNCTION_GET_SUPPLY_VOLTAGE
- See Also:
- Constant Field Values
-
FUNCTION_SET_CLOCK_FREQUENCY
public static final byte FUNCTION_SET_CLOCK_FREQUENCY
- See Also:
- Constant Field Values
-
FUNCTION_GET_CLOCK_FREQUENCY
public static final byte FUNCTION_GET_CLOCK_FREQUENCY
- See Also:
- Constant Field Values
-
FUNCTION_SET_CHIP_TYPE
public static final byte FUNCTION_SET_CHIP_TYPE
- See Also:
- Constant Field Values
-
FUNCTION_GET_CHIP_TYPE
public static final byte FUNCTION_GET_CHIP_TYPE
- See Also:
- Constant Field Values
-
FUNCTION_SET_RGBW_VALUES
public static final byte FUNCTION_SET_RGBW_VALUES
- See Also:
- Constant Field Values
-
FUNCTION_GET_RGBW_VALUES
public static final byte FUNCTION_GET_RGBW_VALUES
- See Also:
- Constant Field Values
-
FUNCTION_SET_CHANNEL_MAPPING
public static final byte FUNCTION_SET_CHANNEL_MAPPING
- See Also:
- Constant Field Values
-
FUNCTION_GET_CHANNEL_MAPPING
public static final byte FUNCTION_GET_CHANNEL_MAPPING
- See Also:
- Constant Field Values
-
FUNCTION_ENABLE_FRAME_RENDERED_CALLBACK
public static final byte FUNCTION_ENABLE_FRAME_RENDERED_CALLBACK
- See Also:
- Constant Field Values
-
FUNCTION_DISABLE_FRAME_RENDERED_CALLBACK
public static final byte FUNCTION_DISABLE_FRAME_RENDERED_CALLBACK
- See Also:
- Constant Field Values
-
FUNCTION_IS_FRAME_RENDERED_CALLBACK_ENABLED
public static final byte FUNCTION_IS_FRAME_RENDERED_CALLBACK_ENABLED
- See Also:
- Constant Field Values
-
FUNCTION_GET_IDENTITY
public static final byte FUNCTION_GET_IDENTITY
- See Also:
- Constant Field Values
-
CHIP_TYPE_WS2801
public static final int CHIP_TYPE_WS2801
- See Also:
- Constant Field Values
-
CHIP_TYPE_WS2811
public static final int CHIP_TYPE_WS2811
- See Also:
- Constant Field Values
-
CHIP_TYPE_WS2812
public static final int CHIP_TYPE_WS2812
- See Also:
- Constant Field Values
-
CHIP_TYPE_LPD8806
public static final int CHIP_TYPE_LPD8806
- See Also:
- Constant Field Values
-
CHIP_TYPE_APA102
public static final int CHIP_TYPE_APA102
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RGB
public static final short CHANNEL_MAPPING_RGB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RBG
public static final short CHANNEL_MAPPING_RBG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BRG
public static final short CHANNEL_MAPPING_BRG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BGR
public static final short CHANNEL_MAPPING_BGR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GRB
public static final short CHANNEL_MAPPING_GRB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GBR
public static final short CHANNEL_MAPPING_GBR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RGBW
public static final short CHANNEL_MAPPING_RGBW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RGWB
public static final short CHANNEL_MAPPING_RGWB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RBGW
public static final short CHANNEL_MAPPING_RBGW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RBWG
public static final short CHANNEL_MAPPING_RBWG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RWGB
public static final short CHANNEL_MAPPING_RWGB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_RWBG
public static final short CHANNEL_MAPPING_RWBG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GRWB
public static final short CHANNEL_MAPPING_GRWB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GRBW
public static final short CHANNEL_MAPPING_GRBW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GBWR
public static final short CHANNEL_MAPPING_GBWR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GBRW
public static final short CHANNEL_MAPPING_GBRW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GWBR
public static final short CHANNEL_MAPPING_GWBR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_GWRB
public static final short CHANNEL_MAPPING_GWRB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BRGW
public static final short CHANNEL_MAPPING_BRGW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BRWG
public static final short CHANNEL_MAPPING_BRWG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BGRW
public static final short CHANNEL_MAPPING_BGRW
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BGWR
public static final short CHANNEL_MAPPING_BGWR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BWRG
public static final short CHANNEL_MAPPING_BWRG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_BWGR
public static final short CHANNEL_MAPPING_BWGR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WRBG
public static final short CHANNEL_MAPPING_WRBG
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WRGB
public static final short CHANNEL_MAPPING_WRGB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WGBR
public static final short CHANNEL_MAPPING_WGBR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WGRB
public static final short CHANNEL_MAPPING_WGRB
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WBGR
public static final short CHANNEL_MAPPING_WBGR
- See Also:
- Constant Field Values
-
CHANNEL_MAPPING_WBRG
public static final short CHANNEL_MAPPING_WBRG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BrickletLEDStrip
public BrickletLEDStrip(java.lang.String uid, IPConnection ipcon)
Creates an object with the unique device ID \c uid. and adds it to the IP Connection \c ipcon.
-
-
Method Detail
-
setRGBValues
public void setRGBValues(int index, short length, short[] r, short[] g, short[] b) throws TinkerforgeException
Sets *length* RGB values for the LEDs starting from *index*. To make the colors show correctly you need to configure the chip type (setChipType(int)
) and a 3-channel channel mapping (setChannelMapping(short)
) according to the connected LEDs. Example: If you set * index to 5, * length to 3, * r to [255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], * g to [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] and * b to [0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] the LED with index 5 will be red, 6 will be green and 7 will be blue. \note Depending on the LED circuitry colors can be permuted. The colors will be transfered to actual LEDs when the next frame duration ends, seesetFrameDuration(int)
. Generic approach: * Set the frame duration to a value that represents the number of frames per second you want to achieve. * Set all of the LED colors for one frame. * Wait for theBrickletLEDStrip.FrameRenderedListener
listener. * Set all of the LED colors for next frame. * Wait for theBrickletLEDStrip.FrameRenderedListener
listener. * and so on. This approach ensures that you can change the LED colors with a fixed frame rate. The actual number of controllable LEDs depends on the number of free Bricklet ports. See :ref:`here <led_strip_bricklet_ram_constraints>` for more information. A call ofsetRGBValues(int, short, short[], short[], short[])
with index + length above the bounds is ignored completely.- Throws:
TinkerforgeException
-
getRGBValues
public BrickletLEDStrip.RGBValues getRGBValues(int index, short length) throws TinkerforgeException
Returns *length* R, G and B values starting from the given LED *index*. The values are the last values that were set bysetRGBValues(int, short, short[], short[], short[])
.- Throws:
TinkerforgeException
-
setFrameDuration
public void setFrameDuration(int duration) throws TinkerforgeException
Sets the frame duration. Example: If you want to achieve 20 frames per second, you should set the frame duration to 50ms (50ms * 20 = 1 second). For an explanation of the general approach seesetRGBValues(int, short, short[], short[], short[])
.- Throws:
TinkerforgeException
-
getFrameDuration
public int getFrameDuration() throws TinkerforgeException
Returns the frame duration as set bysetFrameDuration(int)
.- Throws:
TinkerforgeException
-
getSupplyVoltage
public int getSupplyVoltage() throws TinkerforgeException
Returns the current supply voltage of the LEDs.- Throws:
TinkerforgeException
-
setClockFrequency
public void setClockFrequency(long frequency) throws TinkerforgeException
Sets the frequency of the clock. The Bricklet will choose the nearest achievable frequency, which may be off by a few Hz. You can get the exact frequency that is used by callinggetClockFrequency()
. If you have problems with flickering LEDs, they may be bits flipping. You can fix this by either making the connection between the LEDs and the Bricklet shorter or by reducing the frequency. With a decreasing frequency your maximum frames per second will decrease too. \note The frequency in firmware version 2.0.0 is fixed at 2MHz. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getClockFrequency
public long getClockFrequency() throws TinkerforgeException
Returns the currently used clock frequency as set bysetClockFrequency(long)
. .. versionadded:: 2.0.1$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setChipType
public void setChipType(int chip) throws TinkerforgeException
Sets the type of the LED driver chip. We currently support the chips * WS2801, * WS2811, * WS2812 / SK6812 / NeoPixel RGB, * SK6812RGBW / NeoPixel RGBW (Chip Type = WS2812), * LPD8806 and * APA102 / DotStar. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getChipType
public int getChipType() throws TinkerforgeException
Returns the currently used chip type as set bysetChipType(int)
. .. versionadded:: 2.0.2$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setRGBWValues
public void setRGBWValues(int index, short length, short[] r, short[] g, short[] b, short[] w) throws TinkerforgeException
Sets *length* RGBW values for the LEDs starting from *index*. To make the colors show correctly you need to configure the chip type (setChipType(int)
) and a 4-channel channel mapping (setChannelMapping(short)
) according to the connected LEDs. The maximum length is 12, the index goes from 0 to 239 and the rgbw values have 8 bits each. Example: If you set * index to 5, * length to 4, * r to [255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], * g to [0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], * b to [0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0] and * w to [0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0] the LED with index 5 will be red, 6 will be green, 7 will be blue and 8 will be white. \note Depending on the LED circuitry colors can be permuted. The colors will be transfered to actual LEDs when the next frame duration ends, seesetFrameDuration(int)
. Generic approach: * Set the frame duration to a value that represents the number of frames per second you want to achieve. * Set all of the LED colors for one frame. * Wait for theBrickletLEDStrip.FrameRenderedListener
listener. * Set all of the LED colors for next frame. * Wait for theBrickletLEDStrip.FrameRenderedListener
listener. * and so on. This approach ensures that you can change the LED colors with a fixed frame rate. The actual number of controllable LEDs depends on the number of free Bricklet ports. See :ref:`here <led_strip_bricklet_ram_constraints>` for more information. A call ofsetRGBWValues(int, short, short[], short[], short[], short[])
with index + length above the bounds is ignored completely. The LPD8806 LED driver chips have 7-bit channels for RGB. Internally the LED Strip Bricklets divides the 8-bit values set using this function by 2 to make them 7-bit. Therefore, you can just use the normal value range (0-255) for LPD8806 LEDs. The brightness channel of the APA102 LED driver chips has 5-bit. Internally the LED Strip Bricklets divides the 8-bit values set using this function by 8 to make them 5-bit. Therefore, you can just use the normal value range (0-255) for the brightness channel of APA102 LEDs. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getRGBWValues
public BrickletLEDStrip.RGBWValues getRGBWValues(int index, short length) throws TinkerforgeException
Returns *length* RGBW values starting from the given *index*. The values are the last values that were set bysetRGBWValues(int, short, short[], short[], short[], short[])
. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
setChannelMapping
public void setChannelMapping(short mapping) throws TinkerforgeException
Sets the channel mapping for the connected LEDs.setRGBValues(int, short, short[], short[], short[])
andsetRGBWValues(int, short, short[], short[], short[], short[])
take the data in RGB(W) order. But the connected LED driver chips might have their 3 or 4 channels in a different order. For example, the WS2801 chips typically use BGR order, the WS2812 chips typically use GRB order and the APA102 chips typically use WBGR order. The APA102 chips are special. They have three 8-bit channels for RGB and an additional 5-bit channel for the overall brightness of the RGB LED making them 4-channel chips. Internally the brightness channel is the first channel, therefore one of the Wxyz channel mappings should be used. Then the W channel controls the brightness. If a 3-channel mapping is selected thensetRGBValues(int, short, short[], short[], short[])
has to be used. CallingsetRGBWValues(int, short, short[], short[], short[], short[])
with a 3-channel mapping will produce incorrect results. Vice-versa if a 4-channel mapping is selected thensetRGBWValues(int, short, short[], short[], short[], short[])
has to be used. CallingsetRGBValues(int, short, short[], short[], short[])
with a 4-channel mapping will produce incorrect results. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getChannelMapping
public short getChannelMapping() throws TinkerforgeException
Returns the currently used channel mapping as set bysetChannelMapping(short)
. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
enableFrameRenderedCallback
public void enableFrameRenderedCallback() throws TinkerforgeException
Enables theBrickletLEDStrip.FrameRenderedListener
listener. By default the listener is enabled. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
disableFrameRenderedCallback
public void disableFrameRenderedCallback() throws TinkerforgeException
Disables theBrickletLEDStrip.FrameRenderedListener
listener. By default the listener is enabled. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
isFrameRenderedCallbackEnabled
public boolean isFrameRenderedCallbackEnabled() throws TinkerforgeException
Returns *true* if theBrickletLEDStrip.FrameRenderedListener
listener is enabled, *false* otherwise. .. versionadded:: 2.0.6$nbsp;(Plugin)- Throws:
TinkerforgeException
-
getIdentity
public Device.Identity getIdentity() throws TinkerforgeException
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier. The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at position 'z'. The device identifier numbers can be found :ref:`here <device_identifier>`. |device_identifier_constant|- Specified by:
getIdentity
in classDevice
- Throws:
TinkerforgeException
-
addFrameRenderedListener
public void addFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Adds a FrameRendered listener.
-
removeFrameRenderedListener
public void removeFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Removes a FrameRendered listener.
-
-