WPILibC++ 2024.3.2
frc::AddressableLED Class Reference

A class for driving addressable LEDs, such as WS2812Bs and NeoPixels. More...

#include <frc/AddressableLED.h>

Classes

class  LEDData
 

Public Member Functions

 AddressableLED (int port)
 Constructs a new driver for a specific port. More...
 
 ~AddressableLED ()
 
void SetLength (int length)
 Sets the length of the LED strip. More...
 
void SetData (std::span< const LEDData > ledData)
 Sets the led output data. More...
 
void SetData (std::initializer_list< LEDData > ledData)
 Sets the led output data. More...
 
void SetBitTiming (units::nanosecond_t highTime0, units::nanosecond_t lowTime0, units::nanosecond_t highTime1, units::nanosecond_t lowTime1)
 Sets the bit timing. More...
 
void SetSyncTime (units::microsecond_t syncTime)
 Sets the sync time. More...
 
void Start ()
 Starts the output. More...
 
void Stop ()
 Stops the output. More...
 

Detailed Description

A class for driving addressable LEDs, such as WS2812Bs and NeoPixels.

By default, the timing supports WS2812B LEDs, but is configurable using SetBitTiming()

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.

Constructor & Destructor Documentation

◆ AddressableLED()

frc::AddressableLED::AddressableLED ( int  port)
explicit

Constructs a new driver for a specific port.

Parameters
portthe output port to use (Must be a PWM header)

◆ ~AddressableLED()

frc::AddressableLED::~AddressableLED ( )

Member Function Documentation

◆ SetBitTiming()

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 WS2812Bs, so nothing needs to be set for those.

Parameters
highTime0high time for 0 bit (default 400ns)
lowTime0low time for 0 bit (default 900ns)
highTime1high time for 1 bit (default 900ns)
lowTime1low time for 1 bit (default 600ns)

◆ SetData() [1/2]

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.

Parameters
ledDatathe buffer to write

◆ SetData() [2/2]

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.

Parameters
ledDatathe buffer to write

◆ SetLength()

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.

Parameters
lengththe strip length

◆ SetSyncTime()

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.

Parameters
syncTimethe sync time (default 280us)

◆ Start()

void frc::AddressableLED::Start ( )

Starts the output.

The output writes continuously.

◆ Stop()

void frc::AddressableLED::Stop ( )

Stops the output.


The documentation for this class was generated from the following file: