|
WPILibC++
2020.3.2
|
A class for driving addressable LEDs, such as WS2812s and NeoPixels. More...
#include <AddressableLED.h>
Classes | |
| class | LEDData |
Public Member Functions | |
| AddressableLED (int port) | |
| Constructs a new driver for a specific port. More... | |
| void | SetLength (int length) |
| Sets the length of the LED strip. More... | |
| void | SetData (wpi::ArrayRef< 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 lowTime0, units::nanosecond_t highTime0, units::nanosecond_t lowTime1, units::nanosecond_t highTime1) |
| 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. | |
Public Member Functions inherited from frc::ErrorBase | |
| ErrorBase (const ErrorBase &)=default | |
| ErrorBase & | operator= (const ErrorBase &)=default |
| ErrorBase (ErrorBase &&)=default | |
| ErrorBase & | operator= (ErrorBase &&)=default |
| virtual Error & | GetError () |
| Retrieve the current error. More... | |
| virtual const Error & | GetError () const |
| Retrieve the current error. More... | |
| virtual void | ClearError () const |
| Clear the current error information associated with this sensor. | |
| virtual void | SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set error information associated with a C library call that set an error to the "errno" global variable. More... | |
| virtual void | SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated from the nivision Imaq API. More... | |
| virtual void | SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | CloneError (const ErrorBase &rhs) const |
| virtual bool | StatusIsFatal () const |
| Check if the current error code represents a fatal error. More... | |
| void | ClearGlobalErrors () |
| Clear global errors. | |
Additional Inherited Members | |
Static Public Member Functions inherited from frc::ErrorBase | |
| static void | SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
| static void | SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
| static Error | GetGlobalError () |
| Retrieve the last global error. | |
| static std::vector< Error > | GetGlobalErrors () |
| Retrieve all global errors. | |
Protected Attributes inherited from frc::ErrorBase | |
| Error | m_error |
A class for driving addressable LEDs, such as WS2812s and NeoPixels.
Only 1 LED driver is currently supported by the roboRIO.
|
explicit |
Constructs a new driver for a specific port.
| port | the output port to use (Must be a PWM header) |
| void frc::AddressableLED::SetBitTiming | ( | units::nanosecond_t | lowTime0, |
| units::nanosecond_t | highTime0, | ||
| units::nanosecond_t | lowTime1, | ||
| units::nanosecond_t | highTime1 | ||
| ) |
Sets the bit timing.
By default, the driver is set up to drive WS2812s, so nothing needs to be set for those.
| lowTime0 | low time for 0 bit |
| highTime0 | high time for 0 bit |
| lowTime1 | low time for 1 bit |
| highTime1 | high time for 1 bit |
| 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 | ( | wpi::ArrayRef< 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 WS2812.
| syncTimeMicroSeconds | the sync time |
| void frc::AddressableLED::Start | ( | ) |
Starts the output.
The output writes continously.