A class for driving addressable LEDs, such as WS2812B, WS2815, and NeoPixels. More...
#include <frc/AddressableLED.h>
Classes | |
class | LEDData |
Public Types | |
enum | ColorOrder { kRGB = HAL_ALED_RGB , kRBG = HAL_ALED_RBG , kBGR = HAL_ALED_BGR , kBRG = HAL_ALED_BRG , kGBR = HAL_ALED_GBR , kGRB = HAL_ALED_GRB } |
Order that color data is sent over the wire. More... | |
Public Member Functions | |
AddressableLED (int port) | |
Constructs a new driver for a specific port. | |
AddressableLED (AddressableLED &&)=default | |
AddressableLED & | operator= (AddressableLED &&)=default |
void | SetColorOrder (ColorOrder order) |
Sets the color order for this AddressableLED. | |
void | SetLength (int length) |
Sets the length of the LED strip. | |
void | SetData (std::span< const LEDData > ledData) |
Sets the led output data. | |
void | SetData (std::initializer_list< LEDData > ledData) |
Sets the led output data. | |
void | SetBitTiming (units::nanosecond_t highTime0, units::nanosecond_t lowTime0, units::nanosecond_t highTime1, units::nanosecond_t lowTime1) |
Sets the bit timing. | |
void | SetSyncTime (units::microsecond_t syncTime) |
Sets the sync time. | |
void | Start () |
Starts the output. | |
void | Stop () |
Stops the output. | |
A class for driving addressable LEDs, such as WS2812B, WS2815, and NeoPixels.
By default, the timing supports WS2812B and WS2815 LEDs, but is configurable using SetBitTiming()
Some LEDs use a different color order than the default GRB. The color order is configurable using SetColorOrder().
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.
|
explicit |
Constructs a new driver for a specific port.
port | the output port to use (Must be a PWM header) |
|
default |
|
default |
void frc::AddressableLED::SetBitTiming | ( | units::nanosecond_t | highTime0, |
units::nanosecond_t | lowTime0, | ||
units::nanosecond_t | highTime1, | ||
units::nanosecond_t | lowTime1 ) |
Sets the bit timing.
By default, the driver is set up to drive WS2812B and WS2815, so nothing needs to be set for those.
highTime0 | high time for 0 bit (default 400ns) |
lowTime0 | low time for 0 bit (default 900ns) |
highTime1 | high time for 1 bit (default 900ns) |
lowTime1 | low time for 1 bit (default 600ns) |
void frc::AddressableLED::SetColorOrder | ( | ColorOrder | order | ) |
Sets the color order for this AddressableLED.
The default order is GRB.
This will take effect on the next call to SetData().
order | the color order |
void frc::AddressableLED::SetData | ( | std::initializer_list< LEDData > | ledData | ) |
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.
ledData | the buffer to write |
void frc::AddressableLED::SetData | ( | std::span< const LEDData > | ledData | ) |
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.
ledData | the buffer to write |
void frc::AddressableLED::SetLength | ( | int | length | ) |
Sets the length of the LED strip.
Calling this is an expensive call, so its best to call it once, then just update data.
The max length is 5460 LEDs.
length | the strip length |
void frc::AddressableLED::SetSyncTime | ( | units::microsecond_t | syncTime | ) |
Sets the sync time.
The sync time is the time to hold output so LEDs enable. Default set for WS2812B and WS2815.
syncTime | the sync time (default 280us) |
void frc::AddressableLED::Start | ( | ) |
Starts the output.
The output writes continuously.
void frc::AddressableLED::Stop | ( | ) |
Stops the output.