FastLED 3.10.6
Loading...
Searching...
No Matches

◆ PixelIterator()

template<typename PixelControllerT>
fl::PixelIterator::PixelIterator ( PixelControllerT * pc,
const Rgbw & rgbw,
Rgbww rgbww = RgbwwInvalid::value() )
inline

Definition at line 213 of file pixel_iterator.h.

215 : mPixelController(pc), mRgbw(rgbw), mRgbww(rgbww) {
216 // Manually build up a vtable.
217 // Wait... what? Stupid nerds trying to show off how smart they are...
218 // Why not just use a virtual function?!
219 //
220 // Before you think this then you should know that the alternative straight
221 // forward way is to have a virtual interface class that PixelController inherits from.
222 // ...and that was already tried. And if you try to do this yourself
223 // this then let me tell you what is going to happen...
224 //
225 // EVERY SINGLE PLATFORM THAT HAS A COMPILED BINARY SIZE CHECK WILL IMMEDIATELY
226 // FAIL AS THE BINARY BLOWS UP BY 10-30%!!! It doesn't matter if only one PixelController
227 // with a vtable is used, gcc seems not to de-virtualize the calls. And we really care
228 // about binary size since FastLED needs to run on those tiny little microcontrollers like
229 // the Attiny85 (and family) which are in the sub $1 range used for commercial products.
230 //
231 // So to satisfy these tight memory requirements we make the dynamic dispatch used in PixelIterator
232 // an optional zero-cost abstraction which doesn't affect the binary size for platforms that
233 // don't use it. So that's why we are using this manual construction of the vtable that is built
234 // up using template magic. If your platform has lots of memory then you'll gladly trade
235 // a sliver of memory for the convenience of having a concrete implementation of
236 // PixelController that you can use without having to make all your driver code a template.
237 //
238 // Btw, this pattern in C++ is called the "type-erasure pattern". It allows non virtual
239 // polymorphism by leveraging the C++ template system to ensure type safety.
240 typedef PixelControllerVtable<PixelControllerT> Vtable;
246#if !FL_PLATFORM_HAS_TINY_MEMORY
248#endif
249 // NOTE: mLoadAndScale_APA102_HD removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
250 // NOTE: mLoadAndScale_WS2816_HD removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
254 mHas = &Vtable::has;
255 #if FASTLED_HD_COLOR_MIXING
256 mLoadRGBScaleAndBrightness = &Vtable::loadRGBScaleAndBrightness;
257 mGetHdScale = &Vtable::getHdScale;
258 #endif
259 }
Rgbw rgbw
loadAndScaleRGBWWUnorderedFunction mLoadAndScaleRGBWWUnordered
void advanceData() FL_NO_EXCEPT
int size() FL_NO_EXCEPT
loadAndScaleRGBWUnorderedFunction mLoadAndScaleRGBWUnordered
void loadAndScaleRGB(u8 *r_out, u8 *g_out, u8 *b_out) FL_NO_EXCEPT
stepDitheringFunction mStepDithering
advanceDataFunction mAdvanceData
bool has(int n) FL_NO_EXCEPT
loadAndScaleRGBWWFunction mLoadAndScaleRGBWW
loadAndScaleRGBFunction mLoadAndScaleRGB
loadAndScaleRGB16Function mLoadAndScaleRGB16
loadAndScaleRGBWFunction mLoadAndScaleRGBW
void stepDithering() FL_NO_EXCEPT
static loadAndScaleRGBWWFunction orderedWW() FL_NO_EXCEPT
static loadAndScaleRGBWFunction ordered() FL_NO_EXCEPT
static loadAndScaleRGBWUnorderedFunction unordered() FL_NO_EXCEPT
static loadAndScaleRGBWWUnorderedFunction unorderedWW() FL_NO_EXCEPT
static loadAndScaleRGB16Function get() FL_NO_EXCEPT

References fl::FL_NO_EXCEPT, fl::WideLoadBinder< T, typename >::get(), mAdvanceData, mHas, mLoadAndScaleRGB, mLoadAndScaleRGB16, mLoadAndScaleRGBW, mLoadAndScaleRGBWUnordered, mLoadAndScaleRGBWW, mLoadAndScaleRGBWWUnordered, mPixelController, mRgbw, mRgbww, mSize, mStepDithering, fl::RgbwLoadBinder< T, typename >::ordered(), fl::RgbwLoadBinder< T, typename >::orderedWW(), rgbw, fl::RgbwLoadBinder< T, typename >::unordered(), fl::RgbwLoadBinder< T, typename >::unorderedWW(), and fl::RgbwwInvalid::value().

+ Here is the call graph for this function: