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

Detailed Description

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 723 of file FastLED.h.

#include <FastLED.h>

Classes

struct  ClockedChipsetHelper
 

Public Member Functions

 CFastLED () FL_NO_EXCEPT
 
void addListener (fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
 
void clear (bool writeData=false) FL_NO_EXCEPT
 Clear the leds, wiping the local array of data.
 
void clearData () FL_NO_EXCEPT
 Clear out the local data array.
 
bool colorManagementStrict () const FL_NO_EXCEPT
 
int count () FL_NO_EXCEPT
 Get how many controllers have been registered.
 
void countFPS (int nFrames=25) FL_NO_EXCEPT
 For debugging, this will keep track of time between calls to countFPS().
 
const fl::SourceProfile & defaultSourceProfile () const FL_NO_EXCEPT
 
void delay (unsigned long ms) FL_NO_EXCEPT
 Delay for the given number of milliseconds.
 
fl::u8 getBrightness () FL_NO_EXCEPT
 Get the current global brightness setting.
 
fl::u16 getFPS () FL_NO_EXCEPT
 Get the number of frames/second being written out.
 
fl::u8 getHdFieldFloor () const FL_NO_EXCEPT
 
fl::u8 getLastShowBrightness () const FL_NO_EXCEPT
 Brightness the most recent show() / showColor() actually applied, after the power limiter set by setMaxPowerInMilliWatts().
 
void init () FL_NO_EXCEPT
 Initialize platform-specific subsystems.
 
bool isPowerLimited () const FL_NO_EXCEPT
 True if the power limiter lowered the brightness of the most recent show() / showColor() below what it was asked for.
 
CRGB * leds () FL_NO_EXCEPT
 Get a pointer to led data for the first controller.
 
void onEndFrame () FL_NO_EXCEPT
 
CLEDController & operator[] (int x) FL_NO_EXCEPT
 Get a reference to a registered controller.
 
void removeListener (fl::EngineEvents::Listener *listener) FL_NO_EXCEPT
 
void setBrightness (fl::u8 scale) FL_NO_EXCEPT
 Set the global brightness scaling.
 
void setColorManagementStrict (bool strict) FL_NO_EXCEPT
 In strict mode a channel that requests color management without an emitter profile reports a rejected binding instead of silent fallback.
 
void setCorrection (const CRGB &correction) FL_NO_EXCEPT
 Set a global color correction.
 
void setDefaultSourceProfile (const fl::SourceProfile &profile) FL_NO_EXCEPT
 
void setDither (fl::u8 ditherMode=BINARY_DITHER) FL_NO_EXCEPT
 Set the dithering mode.
 
void setHdFieldFloor (fl::u8 min_field) FL_NO_EXCEPT
 Lowest 5-bit current field the colour-managed APA102-HD path may use (B1's flicker floor, #4042).
 
void setMaxPowerInMilliWatts (fl::u32 milliwatts) FL_NO_EXCEPT
 Set the maximum power to be used, given in milliwatts.
 
void setMaxPowerInVoltsAndMilliamps (fl::u8 volts, fl::u32 milliamps) FL_NO_EXCEPT
 Set the maximum power to be used, given in volts and milliamps.
 
void setMaxRefreshRate (fl::u16 refresh, bool constrain=false) FL_NO_EXCEPT
 Set the maximum refresh rate.
 
void setTemperature (const CRGB &temp) FL_NO_EXCEPT
 Set a global color temperature.
 
void show () FL_NO_EXCEPT
 Update all our controllers with the current led colors.
 
void show (fl::u8 scale) FL_NO_EXCEPT
 Update all our controllers with the current led colors, using the passed in brightness.
 
void showColor (const CRGB &color) FL_NO_EXCEPT
 Set all leds on all controllers to the given color.
 
void showColor (const CRGB &color, fl::u8 scale) FL_NO_EXCEPT
 Set all leds on all controllers to the given color/scale.
 
int size () FL_NO_EXCEPT
 Get the number of leds in the first controller.
 
void wait () FL_NO_EXCEPT
 Wait for all channel bus transmissions to complete.
 
bool wait (fl::u32 timeout_ms) FL_NO_EXCEPT
 Wait for all channel bus transmissions to complete with timeout.
 

Static Public Member Functions

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

Static Private Member Functions

static fl::vector< fl::ChannelPtr > & channels () FL_NO_EXCEPT
 stored ChannelPtrs to keep them alive
 

Private Attributes

fl::u8 mLastRequestedScale
 brightness the last show()/showColor() was asked for
 
fl::u8 mLastShownScale
 brightness the last show()/showColor() applied, after the power limiter
 
fl::u16 mMaxRefreshHz
 frame-rate cap in Hz, 0 = unlimited (u16 saves 2 B over micros, #4788)
 
fl::u16 mNFPS
 tracking for current frames per second (FPS) value
 
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
 

Friends

fl::PowerCodecPolicy fl::powerChannelCodecPolicy (const fl::CLEDController &controller) FL_NO_EXCEPT
 

Power Model Configuration

Configure LED power consumption for accurate power management

static void _setWaitSpinBudgetUs (fl::u32 budget_us) FL_NO_EXCEPT
 
static fl::u32 _getWaitSpinBudgetUs () FL_NO_EXCEPT
 
void setPowerModel (const PowerModelRGB &model) FL_NO_EXCEPT
 
void setPowerScalingExponent (float exponent) FL_NO_EXCEPT
 Set a non-linear brightness-to-power response exponent.
 
float getPowerScalingExponent () const FL_NO_EXCEPT
 Get the configured brightness-to-power response exponent.
 
void setWaitSpinBudgetUs (fl::u32 budget_us) FL_NO_EXCEPT
 Override the channel-manager tiered-wait spin budget (microseconds).
 
fl::u32 getWaitSpinBudgetUs () const FL_NO_EXCEPT
 Get the current tiered-wait spin budget (microseconds).
 
void setPowerModel (const PowerModelRGBW &model) FL_NO_EXCEPT
 
void setPowerModel (const PowerModelRGBWW &model) FL_NO_EXCEPT
 
PowerModelRGB getPowerModel () const FL_NO_EXCEPT
 Get current RGB power model.
 
fl::u32 getEstimatedPowerInMilliWatts (bool apply_limiter=true) const FL_NO_EXCEPT
 Get estimated power consumption in milliwatts.
 

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 () FL_NO_EXCEPT
 Manually trigger the begin frame event.
 
void onEndShowLeds () FL_NO_EXCEPT
 Manually trigger the end show LEDs event.
 

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
 _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(MY9221
 
LPD8806Controller WS2803Controller MY9221Controller _FL_MAP_CLOCKED_CHIPSET (P9813, P9813Controller) _FL_MAP_CLOCKED_CHIPSET(DOTSTAR
 
LPD8806Controller WS2803Controller MY9221Controller APA102Controller _FL_MAP_CLOCKED_CHIPSET (APA102, APA102Controller) _FL_MAP_CLOCKED_CHIPSET(DOTSTARHD
 
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD _FL_MAP_CLOCKED_CHIPSET (APA102HD, APA102ControllerHD) _FL_MAP_CLOCKED_CHIPSET(HD107
 
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD APA102Controller _FL_MAP_CLOCKED_CHIPSET (HD107HD, APA102ControllerHD) _FL_MAP_CLOCKED_CHIPSET(HD108
 
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD APA102Controller HD108Controller _FL_MAP_CLOCKED_CHIPSET (SK9822, SK9822Controller) _FL_MAP_CLOCKED_CHIPSET(SK9822HD
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
::CLEDController & addLedsSpiChannel (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController via Channel API.
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
::CLEDController & addLedsSpiChannel (CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) FL_NO_EXCEPT
 Add an SPI controller with an explicit ESP-IDF SPI host.
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
::CLEDController & addLedsSpiChannel (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController via Channel API (default speed).
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController instance to the world (legacy path).
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::u32 SPI_DATA_RATE, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLeds, fl::Esp32SpiBus spiBus) FL_NO_EXCEPT
 Add an SPI controller on a selected ESP-IDF host.
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController instance to the world (legacy path).
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT, fl::EOrder RGB_ORDER, fl::Bus B, fl::u8 B_WHICH>
LPD8806Controller WS2803Controller MY9221Controller APA102Controller APA102ControllerHD APA102Controller HD108Controller SK9822ControllerHD ::CLEDController & addLedsSpiDispatch (CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::true_type) FL_NO_EXCEPT
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::u32 RATE, int VARIANT, fl::EOrder RGB_ORDER, fl::Bus B, fl::u8 B_WHICH>
::CLEDController & addLedsSpiDispatch (CRGB *data, int nLedsOrOffset, int nLedsIfOffset, const fl::SpiChipsetConfig &spiCfg, fl::false_type) FL_NO_EXCEPT
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO, fl::u8 B_WHICH = 0>
::CLEDController & addLedsSpiChannel (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController via Channel API (default RGB order and speed).
 
template<ESPIChipsets CHIPSET, fl::u8 DATA_PIN, fl::u8 CLOCK_PIN, fl::Bus B = fl::Bus::AUTO>
static ::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add an SPI based CLEDController instance to the world (legacy path).
 

Channel Bus Manager Controls

Configure platform-specific channel bus drivers

void setDriverEnabled (const char *name, bool enabled) FL_NO_EXCEPT
 Enable or disable a channel driver by name at runtime.
 
template<fl::Bus B, fl::u8 Which = 0>
void setExclusiveDriver () FL_NO_EXCEPT
 Register a single driver at a priority above the platform default (compile-time TU-linking variant).
 
bool setExclusiveDriver (fl::Bus bus, fl::u8 which=0) FL_NO_EXCEPT
 Enable only one driver exclusively, runtime form (disables all others)
 
bool isDriverEnabled (const char *name) const FL_NO_EXCEPT
 Check if a driver is enabled by name.
 
fl::size getDriverCount () const FL_NO_EXCEPT
 Get count of registered channel drivers.
 
fl::span< const fl::DriverInfo > getDriverInfos () const FL_NO_EXCEPT
 Get full state of all registered channel drivers.
 

RGBW Colorimetric Fallback Configuration

Legacy process-wide fallback wrappers around fl::set_rgbw_colorimetric_profile / fl::get_rgbw_colorimetric_profile.

Prefer passing a profile on the per-controller fl::Rgbw setting for new sketches. 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_NO_EXCEPT
 Install a legacy fallback RGBW diode chromaticity profile for scalar colorimetric calls.
 
const fl::DiodeProfile * getRgbwColorimetricProfile () const FL_NO_EXCEPT
 Currently active RGBW colorimetric profile (defaults to &fl::kRgbwDefaultProfile).
 

Channel API

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

Adding analog PWM controllers

Add a three-pin PWM controller for a non-addressable RGB LED or strip.

The controller uses the first CRGB value and applies global brightness, color correction, and color temperature during FastLED.show().

Parameters
datapointer to one CRGB value for the complete analog output
nLedsOrOffsetnumber of CRGB values, or offset with nLedsIfOffset
nLedsIfOffsetnumber of CRGB values when an offset is supplied
Template Parameters
CHIPSETthree-pin controller template, normally ANALOG_RGB
RED_PINPWM pin connected to the red channel
GREEN_PINPWM pin connected to the green channel
BLUE_PINPWM pin connected to the blue channel
template<template< fl::u8, fl::u8, fl::u8 > class CHIPSET, fl::u8 RED_PIN, fl::u8 GREEN_PIN, fl::u8 BLUE_PIN>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 

Adding 3rd party library controllers

Add a 3rd party library 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. This class includes the SmartMatrix and OctoWS2811 based controllers

This method also takes 1 to 2 template parameters for identifying the specific chipset and RGB ordering.

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 (required)
RGB_ORDERthe rgb ordering for the leds (e.g. what order red, green, and blue data is written out in)
Returns
a reference to the added controller
template<template< fl::EOrder RGB_ORDER > class CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add a 3rd party library based CLEDController instance to the world.
 
template<template< fl::EOrder RGB_ORDER > class CHIPSET, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0) FL_NO_EXCEPT
 Add a 3rd party library based CLEDController instance to the world.
 
template<OWS2811 CHIPSET, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a OCTOWS2811 based CLEDController instance to the world.
 
template<OWS2811 CHIPSET, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a OCTOWS2811 library based CLEDController instance to the world.
 
template<SWS2812 CHIPSET, int DATA_PIN, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a WS2812Serial library based CLEDController instance to the world.
 
template<ESM CHIPSET, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a SmartMatrix library based CLEDController instance to the world.
 

Adding parallel output controllers

Add a block 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.

This method also takes a 2 to 3 template parameters for identifying the specific chipset and rgb ordering RGB ordering, and SPI data rate

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/port type (required)
NUM_LANEShow many parallel lanes of output to write
RGB_ORDERthe rgb ordering for the leds (e.g. what order red, green, and blue data is written out in)
Returns
a reference to the added controller
template<EBlockChipsets CHIPSET, int NUM_LANES, fl::EOrder RGB_ORDER, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a block based parallel output CLEDController instance to the world.
 
template<EBlockChipsets CHIPSET, int NUM_LANES, fl::Bus B = fl::Bus::AUTO>
::CLEDController & addLeds (CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a block based parallel output CLEDController instance to the world.
 

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