FastLED  3.1
CFastLED Class Reference

High level controller interface for FastLED. More...

#include <FastLED.h>

Public Member Functions

void setBrightness (uint8_t scale)
 Set the global brightness scaling. More...
 
uint8_t getBrightness ()
 Get the current global brightness setting. More...
 
void setMaxPowerInVoltsAndMilliamps (uint8_t volts, uint32_t milliamps)
 Set the maximum power to be used, given in volts and milliamps. More...
 
void setMaxPowerInMilliWatts (uint32_t milliwatts)
 Set the maximum power to be used, given in milliwatts. More...
 
void show (uint8_t scale)
 Update all our controllers with the current led colors, using the passed in brightness. More...
 
void show ()
 Update all our controllers with the current led colors.
 
void clear (boolean writeData=false)
 clear the leds, optionally wiping the local array of data as well More...
 
void clearData ()
 clear out the local data array
 
void showColor (const struct CRGB &color, uint8_t scale)
 Set all leds on all controllers to the given color/scale. More...
 
void showColor (const struct CRGB &color)
 Set all leds on all controllers to the given color. More...
 
void delay (unsigned long ms)
 Delay for the given number of milliseconds. More...
 
void setTemperature (const struct CRGB &temp)
 Set a global color temperature. More...
 
void setCorrection (const struct CRGB &correction)
 Set a global color correction. More...
 
void setDither (uint8_t ditherMode=BINARY_DITHER)
 Set the dithering mode. More...
 
void setMaxRefreshRate (uint16_t refresh, bool constrain=false)
 Set the maximum refresh rate. More...
 
void countFPS (int nFrames=25)
 for debugging, will keep track of time between calls to countFPS, and every nFrames calls, it will update an internal counter for the current FPS. More...
 
uint16_t getFPS ()
 Get the number of frames/second being written out. More...
 
int count ()
 Get how many controllers have been registered. More...
 
CLEDControlleroperator[] (int x)
 Get a reference to a registered controller. More...
 
int size ()
 Get the number of leds in the first controller. More...
 
CRGBleds ()
 Get a pointer to led data for the first controller. More...
 

Static Public Member Functions

static CLEDControlleraddLeds (CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a CLEDController instance to the world. More...
 

Adding SPI based controllers

template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE>
CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add an SPI based CLEDController instance to the world. More...
 
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<ESPIChipsets CHIPSET>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<ESPIChipsets CHIPSET, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<ESPIChipsets CHIPSET, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 

Adding 3-wire led controllers

template<template< uint8_t DATA_PIN, EOrder RGB_ORDER > class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a clockless (aka 3wire, also DMX) based CLEDController instance to the world. More...
 
template<template< uint8_t DATA_PIN, EOrder RGB_ORDER > class CHIPSET, uint8_t DATA_PIN>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<template< uint8_t DATA_PIN > class CHIPSET, uint8_t DATA_PIN>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<EClocklessChipsets CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER = RGB>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 

Adding 3rd party library controllers

template<template< EOrder RGB_ORDER > class CHIPSET, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a 3rd party library based CLEDController instance to the world. More...
 
template<template< EOrder RGB_ORDER > class CHIPSET>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<OWS2811 CHIPSET, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<OWS2811 CHIPSET>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 
template<ESM CHIPSET>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 

adding parallel output controllers

template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 Add a block based CLEDController instance to the world. More...
 
template<EBlockChipsets CHIPSET, int NUM_LANES>
static CLEDControlleraddLeds (struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
 

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.

Definition at line 157 of file FastLED.h.

Member Function Documentation

CLEDController & CFastLED::addLeds ( CLEDController pLed,
struct CRGB data,
int  nLedsOrOffset,
int  nLedsIfOffset = 0 
)
static

Add a CLEDController instance to the world.

Exposed to the public to allow people to implement their own CLEDController objects or instances. There are two ways to call this method (as well as the other addLeds) variations. The first is with 3 arguments, in which case the arguments are the controller, a pointer to led data, and the number of leds used by this controller. The second is with 4 arguments, in which case the first two arguments are the same, the third argument is an offset into the CRGB data where this controller's CRGB data begins, and the fourth argument is the number of leds for this controller object.

Parameters
pLed- the led controller being added
data- base point to an array of CRGB data structures
nLedsOrOffset- number of leds (3 argument version) or offset into the data array
nLedsIfOffset- number of leds (4 argument version)
Returns
a reference to the added controller

Definition at line 30 of file FastLED.cpp.

template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint8_t SPI_DATA_RATE>
CLEDController& CFastLED::addLeds ( struct CRGB data,
int  nLedsOrOffset,
int  nLedsIfOffset = 0 
)
inline

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.

This method also takes a 1 to 5 template parameters for identifying the specific chipset, data and clock pins, RGB ordering, and SPI data rate

Parameters
data- base point to an array of CRGB data structures
nLedsOrOffset- number of leds (3 argument version) or offset into the data array
nLedsIfOffset- number of leds (4 argument version)
Template Parameters
CHIPSET- the chipset type
DATA_PIN- the optional data pin for the leds (if omitted, will default to the first hardware SPI MOSI pin)
CLOCK_PIN- the optional clock pin for the leds (if omitted, will default to the first hardware SPI clock pin)
RGB_ORDER- the rgb ordering for the leds (e.g. what order red, green, and blue data is written out in)
SPI_DATA_RATE- the 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

Definition at line 202 of file FastLED.h.

template<template< uint8_t DATA_PIN, EOrder RGB_ORDER > class CHIPSET, uint8_t DATA_PIN, EOrder RGB_ORDER>
static CLEDController& CFastLED::addLeds ( struct CRGB data,
int  nLedsOrOffset,
int  nLedsIfOffset = 0 
)
inlinestatic

Add a clockless (aka 3wire, also DMX) 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, data pin, and rgb ordering RGB ordering, and SPI data rate

Parameters
data- base point to an array of CRGB data structures
nLedsOrOffset- number of leds (3 argument version) or offset into the data array
nLedsIfOffset- number of leds (4 argument version)
Template Parameters
CHIPSET- the chipset type (required)
DATA_PIN- the optional data pin for the leds (required)
RGB_ORDER- the 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

Definition at line 277 of file FastLED.h.

template<template< EOrder RGB_ORDER > class CHIPSET, EOrder RGB_ORDER>
static CLEDController& CFastLED::addLeds ( struct CRGB data,
int  nLedsOrOffset,
int  nLedsIfOffset = 0 
)
inlinestatic

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 a 1 to 2 template parameters for identifying the specific chipset and rgb ordering RGB ordering, and SPI data rate

Parameters
data- base point to an array of CRGB data structures
nLedsOrOffset- number of leds (3 argument version) or offset into the data array
nLedsIfOffset- number of leds (4 argument version)
Template Parameters
CHIPSET- the chipset type (required)
RGB_ORDER- the 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

Definition at line 325 of file FastLED.h.

template<EBlockChipsets CHIPSET, int NUM_LANES, EOrder RGB_ORDER>
static CLEDController& CFastLED::addLeds ( struct CRGB data,
int  nLedsOrOffset,
int  nLedsIfOffset = 0 
)
inlinestatic

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
data- base point to an array of CRGB data structures
nLedsOrOffset- number of leds (3 argument version) or offset into the data array
nLedsIfOffset- number of leds (4 argument version)
Template Parameters
CHIPSET- the chipset/port type (required)
NUM_LANES- how many parallel lanes of output to write
RGB_ORDER- the 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

Definition at line 387 of file FastLED.h.

void CFastLED::clear ( boolean  writeData = false)

clear the leds, optionally wiping the local array of data as well

Parameters
writeDatawhether or not to write into the local data array as well

Definition at line 105 of file FastLED.cpp.

int CFastLED::count ( )

Get how many controllers have been registered.

Returns
the number of controllers (strips) that have been added with addLeds

Definition at line 63 of file FastLED.cpp.

void CFastLED::countFPS ( int  nFrames = 25)

for debugging, will keep track of time between calls to countFPS, and every nFrames calls, it will update an internal counter for the current FPS.

Todo:
make this a rolling counter
Parameters
nFrames- how many frames to time for determining FPS

Definition at line 205 of file FastLED.cpp.

void CFastLED::delay ( unsigned long  ms)

Delay for the given number of milliseconds.

Provided to allow the library to be used on platforms that don't have a delay function (to allow code to be more portable). Note: this will call show constantly to drive the dithering engine (and will call show at least once).

Parameters
msthe number of milliseconds to pause for

Definition at line 120 of file FastLED.cpp.

uint8_t CFastLED::getBrightness ( )
inline

Get the current global brightness setting.

Returns
the current global brightness value

Definition at line 435 of file FastLED.h.

uint16_t CFastLED::getFPS ( )
inline

Get the number of frames/second being written out.

Returns
the most recently computed FPS value

Definition at line 507 of file FastLED.h.

CRGB* CFastLED::leds ( )
inline

Get a pointer to led data for the first controller.

Returns
pointer to the CRGB buffer for the first controller

Definition at line 523 of file FastLED.h.

CLEDController & CFastLED::operator[] ( int  x)

Get a reference to a registered controller.

Returns
a reference to the Nth controller

Definition at line 73 of file FastLED.cpp.

void CFastLED::setBrightness ( uint8_t  scale)
inline

Set the global brightness scaling.

Parameters
scalea 0-255 value for how much to scale all leds before writing them out

Definition at line 431 of file FastLED.h.

void CFastLED::setCorrection ( const struct CRGB correction)

Set a global color correction.

Sets the color correction for all added led strips, overriding whatever previous color correction those controllers may have had.

Parameters
correctionA CRGB structure describin the color correction.

Definition at line 144 of file FastLED.cpp.

void CFastLED::setDither ( uint8_t  ditherMode = BINARY_DITHER)

Set the dithering mode.

Sets the dithering mode for all added led strips, overriding whatever previous dithering option those controllers may have had.

Parameters
ditherMode- what type of dithering to use, either BINARY_DITHER or DISABLE_DITHER

Definition at line 152 of file FastLED.cpp.

void CFastLED::setMaxPowerInMilliWatts ( uint32_t  milliwatts)
inline

Set the maximum power to be used, given in milliwatts.

Parameters
milliwatts- the max power draw desired, in milliwatts

Definition at line 444 of file FastLED.h.

void CFastLED::setMaxPowerInVoltsAndMilliamps ( uint8_t  volts,
uint32_t  milliamps 
)
inline

Set the maximum power to be used, given in volts and milliamps.

Parameters
volts- how many volts the leds are being driven at (usually 5)
milliamps- the maximum milliamps of power draw you want

Definition at line 440 of file FastLED.h.

void CFastLED::setMaxRefreshRate ( uint16_t  refresh,
bool  constrain = false 
)

Set the maximum refresh rate.

This is global for all leds. Attempts to call show faster than this rate will simply wait. Note that the refresh rate defaults to the slowest refresh rate of all the leds added through addLeds. If you wish to set/override this rate, be sure to call setMaxRefreshRate after adding all of your leds.

Parameters
refresh- maximum refresh rate in hz
constrain- constrain refresh rate to the slowest speed yet set

Definition at line 218 of file FastLED.cpp.

void CFastLED::setTemperature ( const struct CRGB temp)

Set a global color temperature.

Sets the color temperature for all added led strips, overriding whatever previous color temperature those controllers may have had

Parameters
tempA CRGB structure describing the color temperature

Definition at line 136 of file FastLED.cpp.

void CFastLED::show ( uint8_t  scale)

Update all our controllers with the current led colors, using the passed in brightness.

Parameters
scaletemporarily override the scale

Definition at line 42 of file FastLED.cpp.

void CFastLED::showColor ( const struct CRGB color,
uint8_t  scale 
)

Set all leds on all controllers to the given color/scale.

Parameters
colorwhat color to set the leds to
scalewhat brightness scale to show at

Definition at line 85 of file FastLED.cpp.

void CFastLED::showColor ( const struct CRGB color)
inline

Set all leds on all controllers to the given color.

Parameters
colorwhat color to set the leds to

Definition at line 467 of file FastLED.h.

int CFastLED::size ( )
inline

Get the number of leds in the first controller.

Returns
the number of LEDs in the first controller

Definition at line 519 of file FastLED.h.


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