FastLED NeoPixel  1e90134
FastLED_NeoPixel< NumLeds, DataPin, RgbOrder > Class Template Reference

FastLED implementation of the Adafruit_NeoPixel class for WS2812B strips, with data. More...

#include <FastLED_NeoPixel.h>

Inheritance diagram for FastLED_NeoPixel< NumLeds, DataPin, RgbOrder >:
FastLED_NeoPixel_Variant

Public Member Functions

void begin ()
 
uint8_t getPin () const
 
void begin (CLEDController &ctrl)
 
void show ()
 
void setPixelColor (uint16_t n, uint8_t r, uint8_t g, uint8_t b)
 
void setPixelColor (uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
 
void setPixelColor (uint16_t n, uint32_t c)
 
void fill (uint32_t c=0, uint16_t first=0, uint16_t count=0)
 
void setBrightness (uint8_t bright)
 
void clear ()
 
bool canShow ()
 
uint8_t * getPixels () const
 
uint8_t getBrightness () const
 
uint16_t numPixels () const
 
uint32_t getPixelColor (uint16_t n) const
 
CRGBgetLeds () const
 
CLEDControllergetController () const
 
void setBlendWhite (bool blend)
 
void setPin (uint16_t p)
 
void updateLength (uint16_t n)
 
void updateType (neoPixelType T)
 

Static Public Member Functions

static uint8_t sine8 (uint8_t x)
 
static uint8_t gamma8 (uint8_t x)
 
static uint32_t Color (uint8_t r, uint8_t g, uint8_t b)
 
static uint32_t Color (uint8_t r, uint8_t g, uint8_t b, uint8_t w)
 
static uint32_t Color (const CRGB &c)
 
static uint32_t ColorHSV (uint16_t hue, uint8_t sat=255, uint8_t val=255)
 
static uint32_t gamma32 (uint32_t x)
 

Detailed Description

template<uint16_t NumLeds, uint8_t DataPin, uint32_t RgbOrder = GRB>
class FastLED_NeoPixel< NumLeds, DataPin, RgbOrder >

FastLED implementation of the Adafruit_NeoPixel class for WS2812B strips, with data.

This is templated for a few reasons:

  • It allows the user to create a FastLED_NeoPixel class with (almost) the same syntax as Adafruit_NeoPixel (using template args instead of function arguments):
    Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
    FastLED_NeoPixel<LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800> strip;
    
    For ease of use this is preferable to splitting the arguments (LED_COUNT) between template and function.
  • It allows allocating a static CRGB array for the LED data, so we don't have to use heap allocation with new()
  • It allows us to create a begin() function that calls FastLED.addLeds "automatically" without any other input or arguments. Just like Adafruit_NeoPixel!

The one downside is that this splits the FastLED_NeoPixel and FastLED_NeoPixel_Variant classes, so static calls to FastLED_NeoPixel will fail for lack of template arguments. But that's how the cookie crumbles.

Template Parameters
NumLedsthe number of LEDs in the strip
DataPinthe number for the data pin connected to the strip
RgbOrderthe RGB channel order for the strips, either as a NeoPixel define (e.g. NEO_GRB) or a FastLED EOrder enum value (e.g. GRB). By default this is GRB, which is the typical color order for most NeoPixel (WS2812B) strips.
See also
Adafruit_NeoPixel
New Functions
Unimplemented Functions
Examples
Blink.ino, and Strandtest.ino.

Member Function Documentation

◆ begin() [1/2]

template<uint16_t NumLeds, uint8_t DataPin, uint32_t RgbOrder = GRB>
void FastLED_NeoPixel< NumLeds, DataPin, RgbOrder >::begin ( void  )
inline

Creates and saves the CLEDController object for the strip, using WS2812B as the strip type.

◆ begin() [2/2]

void FastLED_NeoPixel_Variant::begin ( CLEDController ctrl)
inherited

This function assigns a CLEDController instance, used for sending the LED data to the strip, to the internal controller pointer. This must be done before any LED data can be written.

To obtain a CLEDController object, call the FastLED.addLeds() function using the relevant template parameters (strip type, data pin(s), and RGB color order) and function parameters (CRGB array pointer and number of LEDs in the strip). E.g.:

FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);

The addLeds function returns a reference to a static instance of a CLEDController object. The addLeds call can be used directly as an argument for the begin() function.

This is purposefully not done through the constructor to avoid a static initialization order fiasco, as the "FastLED" instance (CFastLED class) that contains the linked list of controllers exists in a separate compilation unit from the main Arduino .ino file.

Parameters
ctrlreference to assign to the internal controller pointer
See also
Adafruit_NeoPixel::begin()

◆ canShow()

bool FastLED_NeoPixel_Variant::canShow ( void  )
inherited

◆ clear()

void FastLED_NeoPixel_Variant::clear ( void  )
inherited

◆ Color() [1/2]

static uint32_t FastLED_NeoPixel_Variant::Color ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inlinestaticinherited

◆ Color() [2/2]

static uint32_t FastLED_NeoPixel_Variant::Color ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  w 
)
inlinestaticinherited

◆ ColorHSV()

static uint32_t FastLED_NeoPixel_Variant::ColorHSV ( uint16_t  hue,
uint8_t  sat = 255,
uint8_t  val = 255 
)
inlinestaticinherited

◆ fill()

void FastLED_NeoPixel_Variant::fill ( uint32_t  c = 0,
uint16_t  first = 0,
uint16_t  count = 0 
)
inherited

◆ gamma32()

static uint32_t FastLED_NeoPixel_Variant::gamma32 ( uint32_t  x)
inlinestaticinherited

◆ gamma8()

static uint8_t FastLED_NeoPixel_Variant::gamma8 ( uint8_t  x)
inlinestaticinherited

◆ getBrightness()

uint8_t FastLED_NeoPixel_Variant::getBrightness ( ) const
inlineinherited

◆ getPin()

template<uint16_t NumLeds, uint8_t DataPin, uint32_t RgbOrder = GRB>
uint8_t FastLED_NeoPixel< NumLeds, DataPin, RgbOrder >::getPin ( ) const
inline

◆ getPixelColor()

uint32_t FastLED_NeoPixel_Variant::getPixelColor ( uint16_t  n) const
inherited

◆ getPixels()

uint8_t * FastLED_NeoPixel_Variant::getPixels ( ) const
inlineinherited

◆ numPixels()

uint16_t FastLED_NeoPixel_Variant::numPixels ( ) const
inlineinherited

◆ setBrightness()

void FastLED_NeoPixel_Variant::setBrightness ( uint8_t  bright)
inlineinherited

◆ setPixelColor() [1/3]

void FastLED_NeoPixel_Variant::setPixelColor ( uint16_t  n,
uint32_t  c 
)
inherited

◆ setPixelColor() [2/3]

void FastLED_NeoPixel_Variant::setPixelColor ( uint16_t  n,
uint8_t  r,
uint8_t  g,
uint8_t  b 
)
inherited

◆ setPixelColor() [3/3]

void FastLED_NeoPixel_Variant::setPixelColor ( uint16_t  n,
uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  w 
)
inherited

◆ show()

void FastLED_NeoPixel_Variant::show ( void  )
inherited

◆ sine8()

static uint8_t FastLED_NeoPixel_Variant::sine8 ( uint8_t  x)
inlinestaticinherited

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