FastLED 3.9.15
Loading...
Searching...
No Matches
CFastLED Class Reference

Detailed Description

High level controller interface for FastLED.

This class manages controllers, global settings, and trackings such as brightness and refresh rates, and provides access functions for driving led data to controllers via the show() / showColor() / clear() methods. This is instantiated as a global object with the name FastLED.

Definition at line 610 of file FastLED.h.

#include <FastLED.h>

+ Collaboration diagram for CFastLED:

Classes

struct  ClockedChipsetHelper
 

Public Member Functions

 CFastLED ()
 
void addListener (fl::EngineEvents::Listener *listener)
 
void clear (bool writeData=false)
 Clear the leds, wiping the local array of data.
 
void clearData ()
 Clear out the local data array.
 
int count ()
 Get how many controllers have been registered.
 
void countFPS (int nFrames=25)
 For debugging, this will keep track of time between calls to countFPS().
 
void delay (unsigned long ms)
 Delay for the given number of milliseconds.
 
fl::size getDriverCount () const
 Get count of registered channel drivers.
 
fl::span< const fl::DriverInfogetDriverInfos () const
 Get full state of all registered channel drivers.
 
fl::u32 getEstimatedPowerInMilliWatts (bool apply_limiter=true) const
 Get estimated power consumption in milliwatts.
 
fl::u16 getFPS ()
 Get the number of frames/second being written out.
 
PowerModelRGB getPowerModel () const
 Get current RGB power model.
 
fl::u32 getWaitSpinBudgetUs () const FL_NOEXCEPT
 Get the current tiered-wait spin budget (microseconds).
 
void init ()
 Initialize platform-specific subsystems.
 
bool isDriverEnabled (const char *name) const
 Check if a driver is enabled by name.
 
CRGBleds ()
 Get a pointer to led data for the first controller.
 
void onEndFrame ()
 
CLEDControlleroperator[] (int x)
 Get a reference to a registered controller.
 
void removeListener (fl::EngineEvents::Listener *listener)
 
void setCorrection (const CRGB &correction)
 Set a global color correction.
 
void setDither (fl::u8 ditherMode=BINARY_DITHER)
 Set the dithering mode.
 
template<fl::Bus B>
void setExclusiveDriver () FL_NOEXCEPT
 Register a single driver at a priority above the platform default (compile-time TU-linking variant).
 
bool setExclusiveDriver (fl::Bus bus)
 Enable only one driver exclusively, runtime form (disables all others)
 
void setMaxPowerInMilliWatts (fl::u32 milliwatts)
 Set the maximum power to be used, given in milliwatts.
 
void setMaxPowerInVoltsAndMilliamps (fl::u8 volts, fl::u32 milliamps)
 Set the maximum power to be used, given in volts and milliamps.
 
void setMaxRefreshRate (fl::u16 refresh, bool constrain=false)
 Set the maximum refresh rate.
 
void setPowerModel (const PowerModelRGBW &model)
 
void setPowerModel (const PowerModelRGBWW &model)
 
void setTemperature (const CRGB &temp)
 Set a global color temperature.
 
void setWaitSpinBudgetUs (fl::u32 budget_us) FL_NOEXCEPT
 Override the channel-manager tiered-wait spin budget (microseconds).
 
void show ()
 Update all our controllers with the current led colors.
 
void show (fl::u8 scale)
 Update all our controllers with the current led colors, using the passed in brightness.
 
void showColor (const CRGB &color)
 Set all leds on all controllers to the given color.
 
void showColor (const CRGB &color, fl::u8 scale)
 Set all leds on all controllers to the given color/scale.
 
int size ()
 Get the number of leds in the first controller.
 
void wait ()
 Wait for all channel bus transmissions to complete.
 
bool wait (fl::u32 timeout_ms)
 Wait for all channel bus transmissions to complete with timeout.
 

Static Public Member Functions

::CLEDControlleraddLeds (::CLEDController *pLed, CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a CLEDController instance to the world.
 
static fl::ChannelEventschannelEvents ()
 Access the channel event system.
 
static void clear (ClearFlags flags)
 Clear/reset FastLED state based on the provided flags.
 
static fl::Watchdogwatchdog ()
 Access the unified cross-platform watchdog timer.
 

Public Attributes

LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus int fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int DATA_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus int NUM_LANES
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus int NUM_LANES
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder RGB_ORDER
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder RGB_ORDER
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder RGB_ORDER
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder fl::Bus fl::EOrder fl::Bus fl::Bus fl::EOrder fl::Bus fl::Bus int fl::EOrder fl::Bus fl::Bus int fl::EOrder RGB_ORDER
 

Static Private Member Functions

static fl::u32 _getWaitSpinBudgetUs () FL_NOEXCEPT
 
static void _setWaitSpinBudgetUs (fl::u32 budget_us) FL_NOEXCEPT
 
static fl::vector< fl::ChannelPtr > & channels ()
 stored ChannelPtrs to keep them alive
 

Private Attributes

fl::u16 mNFPS
 tracking for current frames per second (FPS) value
 
fl::u32 mNMinMicros
 minimum µs between frames, used for capping frame rates
 
fl::u32 mNPowerData
 max power use parameter
 
power_func mPPowerFunc
 function for overriding brightness when using FastLED.show();
 
fl::u8 mScale
 the current global brightness scale setting
 

Adding SPI-based controllers

Add an SPI based CLEDController instance to the world.

There are two ways to call this method (as well as the other addLeds() variations). The first is with 2 arguments, in which case the arguments are a pointer to led data, and the number of leds used by this controller. The second is with 3 arguments, in which case the first argument is the same, the second argument is an offset into the CRGB data where this controller's CRGB data begins, and the third argument is the number of leds for this controller object.

Parameters
database pointer to an array of CRGB data structures
nLedsOrOffsetnumber of leds (3 argument version) or offset into the data array
nLedsIfOffsetnumber of leds (4 argument version)
Template Parameters
CHIPSETthe chipset type
DATA_PINthe optional data pin for the leds (if omitted, will default to the first hardware SPI MOSI pin)
CLOCK_PINthe optional clock pin for the leds (if omitted, will default to the first hardware SPI clock pin)
RGB_ORDERthe rgb ordering for the leds (e.g. what order red, green, and blue data is written out in)
SPI_DATA_RATEthe data rate to drive the SPI clock at, defined using DATA_RATE_MHZ or DATA_RATE_KHZ macros
Returns
a reference to the added controller
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 DATA_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 CLOCK_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder RGB_ORDER
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 SPI_DATA_RATE
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 DATA_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 CLOCK_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus B
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 DATA_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 CLOCK_PIN
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller fl::u8 fl::u8 fl::EOrder fl::u32 fl::Bus fl::u8 fl::u8 fl::Bus fl::u8 fl::u8 fl::EOrder RGB_ORDER
 
 _FL_MAP_CLOCKED_CHIPSET (LPD6803, LPD6803Controller) _FL_MAP_CLOCKED_CHIPSET(LPD8806
 
LPD8806Controller _FL_MAP_CLOCKED_CHIPSET (WS2801, WS2801Controller) _FL_MAP_CLOCKED_CHIPSET(WS2803
 
LPD8806Controller WS2803Controller _FL_MAP_CLOCKED_CHIPSET (SM16716, SM16716Controller) _FL_MAP_CLOCKED_CHIPSET(P9813
 
LPD8806Controller WS2803Controller P9813Controller _FL_MAP_CLOCKED_CHIPSET (DOTSTAR, APA102Controller) _FL_MAP_CLOCKED_CHIPSET(APA102
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller _FL_MAP_CLOCKED_CHIPSET (DOTSTARHD, APA102ControllerHD) _FL_MAP_CLOCKED_CHIPSET(APA102HD
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD _FL_MAP_CLOCKED_CHIPSET (HD107, APA102Controller) _FL_MAP_CLOCKED_CHIPSET(HD107HD
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD _FL_MAP_CLOCKED_CHIPSET (HD108, HD108Controller) _FL_MAP_CLOCKED_CHIPSET(SK9822
 
LPD8806Controller WS2803Controller P9813Controller APA102Controller APA102ControllerHD APA102ControllerHD SK9822Controller _FL_MAP_CLOCKED_CHIPSET (SK9822HD, SK9822ControllerHD) template< ESPIChipsets CHIPSET
 Add an SPI based CLEDController instance to the world (legacy path).
 

Manual Engine Events

When FASTLED_MANUAL_ENGINE_EVENTS is defined, these methods allow manual control of engine events.

When FASTLED_MANUAL_ENGINE_EVENTS is not defined, these events are triggered automatically by show().

void onBeginFrame ()
 Manually trigger the begin frame event.
 
void onEndShowLeds ()
 Manually trigger the end show LEDs event.
 

Power Model Configuration

Configure LED power consumption for accurate power management

void setPowerModel (const PowerModelRGB &model)
 
void setPowerScalingExponent (float exponent)
 Set a non-linear brightness-to-power response exponent.
 
float getPowerScalingExponent () const
 Get the configured brightness-to-power response exponent.
 

RGBW Input Gamut Configuration

God-instance wrappers around fl::set_input_gamut (#2710).

See agents/docs/cpp-standards.md → "Public Settings Pattern" for the rule that global setters live here, not as bare fl:: free functions.

void setInputGamut (fl::DiodeProfile *profile, fl::InputGamut g) FL_NOEXCEPT
 Reconfigure profile's input gamut to one of the named source chromaticity sets (Native / Rec709 / Rec2020 / DCI-P3 D65 / D60).
 
void setInputGamut (fl::DiodeProfile *profile, fl::InputGamut g, const float white_xy[2]) FL_NOEXCEPT
 Same as above with an explicit input white-point override.
 

RGBW Colorimetric Configuration

God-instance wrappers around fl::set_rgbw_colorimetric_profile / fl::get_rgbw_colorimetric_profile.

See agents/docs/cpp-standards.md → "Public Settings Pattern" for the rule that global setters live here, not as bare fl:: free functions.

void setRgbwColorimetricProfile (const fl::DiodeProfile *profile) FL_NOEXCEPT
 Install a user-supplied RGBW diode chromaticity profile for the colorimetric modes.
 
const fl::DiodeProfilegetRgbwColorimetricProfile () const FL_NOEXCEPT
 Currently active RGBW colorimetric profile (defaults to &fl::kRgbwDefaultProfile).
 

Channel API

static void add (fl::ChannelPtr channel)
 Add a Channel-based LED controller (from ChannelPtr)
 
static fl::ChannelPtr add (const fl::ChannelConfig &config)
 Add LED channel with runtime configuration (from ChannelConfig)
 
static fl::vector< fl::ChannelPtr > add (fl::span< const fl::ChannelConfig > configs)
 Add multiple LED channels from a config array.
 
static fl::vector< fl::ChannelPtr > add (fl::initializer_list< fl::ChannelConfig > configs)
 Add multiple LED channels from an initializer list.
 
static fl::vector< fl::ChannelPtr > add (const fl::MultiChannelConfig &multiConfig)
 Add multiple LED channels from a MultiChannelConfig.
 
static fl::RxChannelPtr addRx (const fl::RxChannelConfig &config)
 Add an RX channel with runtime configuration.
 
static fl::shared_ptr< fl::audio::Processoradd (const fl::audio::Config &config)
 Add an audio input and return an auto-pumped Processor.
 
static fl::shared_ptr< fl::audio::Processoradd (fl::shared_ptr< fl::audio::IInput > input)
 Add a pre-created audio input and return an auto-pumped Processor.
 
static fl::shared_ptr< fl::audio::Processoradd (fl::UIAudio &uiAudio)
 Add a UIAudio element and return an auto-pumped Processor.
 
static void enableAllDrivers ()
 Enroll every channel driver available on this platform with ChannelManager.
 
static void remove (fl::ChannelPtr channel)
 Remove a channel from the LED controller list.
 
static void remove (fl::shared_ptr< fl::audio::Processor > processor)
 Remove the audio processor.
 

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