public class BrickletLEDStrip extends Device
Modifier and Type | Class and Description |
---|---|
static interface |
BrickletLEDStrip.FrameRenderedListener
This listener is triggered directly after a new frame is rendered.
|
class |
BrickletLEDStrip.RGBValues |
class |
BrickletLEDStrip.RGBWValues |
Device.Identity
Constructor and Description |
---|
BrickletLEDStrip(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Adds a FrameRendered listener.
|
void |
disableFrameRenderedCallback()
Disables the
BrickletLEDStrip.FrameRenderedListener listener. |
void |
enableFrameRenderedCallback()
Enables the
BrickletLEDStrip.FrameRenderedListener listener. |
short |
getChannelMapping()
Returns the currently used channel mapping as set by
setChannelMapping(short) . |
int |
getChipType()
Returns the currently used chip type as set by
setChipType(int) . |
long |
getClockFrequency()
Returns the currently used clock frequency as set by
setClockFrequency(long) . |
int |
getFrameDuration()
Returns the frame duration as set by
setFrameDuration(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 the
BrickletLEDStrip.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*.
|
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final java.lang.String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_SET_RGB_VALUES
public static final byte FUNCTION_GET_RGB_VALUES
public static final byte FUNCTION_SET_FRAME_DURATION
public static final byte FUNCTION_GET_FRAME_DURATION
public static final byte FUNCTION_GET_SUPPLY_VOLTAGE
public static final byte FUNCTION_SET_CLOCK_FREQUENCY
public static final byte FUNCTION_GET_CLOCK_FREQUENCY
public static final byte FUNCTION_SET_CHIP_TYPE
public static final byte FUNCTION_GET_CHIP_TYPE
public static final byte FUNCTION_SET_RGBW_VALUES
public static final byte FUNCTION_GET_RGBW_VALUES
public static final byte FUNCTION_SET_CHANNEL_MAPPING
public static final byte FUNCTION_GET_CHANNEL_MAPPING
public static final byte FUNCTION_ENABLE_FRAME_RENDERED_CALLBACK
public static final byte FUNCTION_DISABLE_FRAME_RENDERED_CALLBACK
public static final byte FUNCTION_IS_FRAME_RENDERED_CALLBACK_ENABLED
public static final byte FUNCTION_GET_IDENTITY
public static final int CHIP_TYPE_WS2801
public static final int CHIP_TYPE_WS2811
public static final int CHIP_TYPE_WS2812
public static final int CHIP_TYPE_LPD8806
public static final int CHIP_TYPE_APA102
public static final short CHANNEL_MAPPING_RGB
public static final short CHANNEL_MAPPING_RBG
public static final short CHANNEL_MAPPING_BRG
public static final short CHANNEL_MAPPING_BGR
public static final short CHANNEL_MAPPING_GRB
public static final short CHANNEL_MAPPING_GBR
public static final short CHANNEL_MAPPING_RGBW
public static final short CHANNEL_MAPPING_RGWB
public static final short CHANNEL_MAPPING_RBGW
public static final short CHANNEL_MAPPING_RBWG
public static final short CHANNEL_MAPPING_RWGB
public static final short CHANNEL_MAPPING_RWBG
public static final short CHANNEL_MAPPING_GRWB
public static final short CHANNEL_MAPPING_GRBW
public static final short CHANNEL_MAPPING_GBWR
public static final short CHANNEL_MAPPING_GBRW
public static final short CHANNEL_MAPPING_GWBR
public static final short CHANNEL_MAPPING_GWRB
public static final short CHANNEL_MAPPING_BRGW
public static final short CHANNEL_MAPPING_BRWG
public static final short CHANNEL_MAPPING_BGRW
public static final short CHANNEL_MAPPING_BGWR
public static final short CHANNEL_MAPPING_BWRG
public static final short CHANNEL_MAPPING_BWGR
public static final short CHANNEL_MAPPING_WRBG
public static final short CHANNEL_MAPPING_WRGB
public static final short CHANNEL_MAPPING_WGBR
public static final short CHANNEL_MAPPING_WGRB
public static final short CHANNEL_MAPPING_WBGR
public static final short CHANNEL_MAPPING_WBRG
public BrickletLEDStrip(java.lang.String uid, IPConnection ipcon)
public void setRGBValues(int index, short length, short[] r, short[] g, short[] b) throws TinkerforgeException
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, see setFrameDuration(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 the BrickletLEDStrip.FrameRenderedListener
listener.
* Set all of the LED colors for next frame.
* Wait for the BrickletLEDStrip.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 of setRGBValues(int, short, short[], short[], short[])
with index + length above the
bounds is ignored completely.TinkerforgeException
public BrickletLEDStrip.RGBValues getRGBValues(int index, short length) throws TinkerforgeException
setRGBValues(int, short, short[], short[], short[])
.TinkerforgeException
public void setFrameDuration(int duration) throws TinkerforgeException
setRGBValues(int, short, short[], short[], short[])
.TinkerforgeException
public int getFrameDuration() throws TinkerforgeException
setFrameDuration(int)
.TinkerforgeException
public int getSupplyVoltage() throws TinkerforgeException
TinkerforgeException
public void setClockFrequency(long frequency) throws TinkerforgeException
getClockFrequency()
.
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)TinkerforgeException
public long getClockFrequency() throws TinkerforgeException
setClockFrequency(long)
.
.. versionadded:: 2.0.1$nbsp;(Plugin)TinkerforgeException
public void setChipType(int chip) throws TinkerforgeException
TinkerforgeException
public int getChipType() throws TinkerforgeException
setChipType(int)
.
.. versionadded:: 2.0.2$nbsp;(Plugin)TinkerforgeException
public void setRGBWValues(int index, short length, short[] r, short[] g, short[] b, short[] w) throws TinkerforgeException
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, see setFrameDuration(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 the BrickletLEDStrip.FrameRenderedListener
listener.
* Set all of the LED colors for next frame.
* Wait for the BrickletLEDStrip.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 of setRGBWValues(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)TinkerforgeException
public BrickletLEDStrip.RGBWValues getRGBWValues(int index, short length) throws TinkerforgeException
setRGBWValues(int, short, short[], short[], short[], short[])
.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public void setChannelMapping(short mapping) throws TinkerforgeException
setRGBValues(int, short, short[], short[], short[])
and setRGBWValues(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 then setRGBValues(int, short, short[], short[], short[])
has to be used.
Calling setRGBWValues(int, short, short[], short[], short[], short[])
with a 3-channel mapping will produce incorrect
results. Vice-versa if a 4-channel mapping is selected then
setRGBWValues(int, short, short[], short[], short[], short[])
has to be used. Calling setRGBValues(int, short, short[], short[], short[])
with a
4-channel mapping will produce incorrect results.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public short getChannelMapping() throws TinkerforgeException
setChannelMapping(short)
.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public void enableFrameRenderedCallback() throws TinkerforgeException
BrickletLEDStrip.FrameRenderedListener
listener.
By default the listener is enabled.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public void disableFrameRenderedCallback() throws TinkerforgeException
BrickletLEDStrip.FrameRenderedListener
listener.
By default the listener is enabled.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public boolean isFrameRenderedCallbackEnabled() throws TinkerforgeException
BrickletLEDStrip.FrameRenderedListener
listener is enabled, *false* otherwise.
.. versionadded:: 2.0.6$nbsp;(Plugin)TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
public void removeFrameRenderedListener(BrickletLEDStrip.FrameRenderedListener listener)
Copyright © 2021 Tinkerforge GmbH. All rights reserved.