Class AddressableLED
- All Implemented Interfaces:
AutoCloseable
By default, the timing supports WS2812B and WS2815 LEDs, but is configurable using setBitTiming(int, int, int, int)
Some LEDs use a different color order than the default GRB. The color order is configurable
using setColorOrder(ColorOrder)
.
Only 1 LED driver is currently supported by the roboRIO. However, multiple LED strips can be connected in series and controlled from the single driver.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Order that color data is sent over the wire. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
setBitTiming
(int highTime0NanoSeconds, int lowTime0NanoSeconds, int highTime1NanoSeconds, int lowTime1NanoSeconds) Sets the bit timing.void
Sets the color order for this AddressableLED.void
setData
(AddressableLEDBuffer buffer) Sets the LED output data.void
setLength
(int length) Sets the length of the LED strip.void
setSyncTime
(int syncTimeMicroSeconds) Sets the sync time.void
start()
Starts the output.void
stop()
Stops the output.
-
Constructor Details
-
AddressableLED
Constructs a new driver for a specific port.- Parameters:
port
- the output port to use (Must be a PWM header, not on MXP)
-
-
Method Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
setColorOrder
Sets the color order for this AddressableLED. The default order is GRB.This will take effect on the next call to
setData(AddressableLEDBuffer)
.- Parameters:
order
- the color order
-
setLength
Sets the length of the LED strip.Calling this is an expensive call, so it's best to call it once, then just update data.
The max length is 5460 LEDs.
- Parameters:
length
- the strip length
-
setData
Sets the LED output data.If the output is enabled, this will start writing the next data cycle. It is safe to call, even while output is enabled.
- Parameters:
buffer
- the buffer to write
-
setBitTiming
public void setBitTiming(int highTime0NanoSeconds, int lowTime0NanoSeconds, int highTime1NanoSeconds, int lowTime1NanoSeconds) Sets the bit timing.By default, the driver is set up to drive WS2812B and WS2815, so nothing needs to be set for those.
- Parameters:
highTime0NanoSeconds
- high time for 0 bit (default 400ns)lowTime0NanoSeconds
- low time for 0 bit (default 900ns)highTime1NanoSeconds
- high time for 1 bit (default 900ns)lowTime1NanoSeconds
- low time for 1 bit (default 600ns)
-
setSyncTime
Sets the sync time.The sync time is the time to hold output so LEDs enable. Default set for WS2812B and WS2815.
- Parameters:
syncTimeMicroSeconds
- the sync time (default 280us)
-
start
Starts the output.The output writes continuously.
-
stop
Stops the output.
-