FastLED 3.9.15
Loading...
Searching...
No Matches
pixel_iterator.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "fl/stl/stdint.h"
7#include "fl/stl/string.h"
8#include "fl/stl/iterator.h"
10#include "fl/gfx/rgbw.h"
11#include "fl/gfx/rgbww.h"
12#include "crgb.h"
13#include "fl/math/intmap.h"
24
25// Include adapter class definitions (but not implementations yet)
26// This provides the full definitions of ScaledPixelIterator* classes
27// and makeScaledPixelRange* helper functions
29#include "fl/stl/noexcept.h"
30
31namespace fl {
32
33// Forward declaration
34class PixelIterator;
35
36// NOTE: FASTLED_PIXEL_ITERATOR_HAS_APA102_HD flag removed - HD functions moved to encoder files
37// loadAndScale_APA102_HD() moved to src/fl/chipsets/encoders/apa102.h
38// loadAndScale_WS2816_HD() moved to src/fl/chipsets/encoders/ws2816.h
39
40// Due to to the template nature of the PixelController class, the only way we can make
41// it a concrete polymorphic class is to manually bind the functions and make our own
42// vtable. The PixelControllerVtable is cheaper than doing fl::function<>.
43template<typename PixelControllerT>
45 static void loadAndScaleRGBW(void* pixel_controller, Rgbw rgbw, u8* b0_out, u8* b1_out, u8* b2_out, u8* b3_out) FL_NOEXCEPT {
46 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
47 pc->loadAndScaleRGBW(rgbw, b0_out, b1_out, b2_out, b3_out);
48 }
49
50 // 5-channel RGBWW path (issue #2558, Phase C of #2545). Same vtable
51 // pattern as loadAndScaleRGBW but produces 5 output bytes (RGB + warm-W
52 // + cool-W) per pixel in EOrder + EOrderWW wire order.
53 static void loadAndScaleRGBWW(void* pixel_controller, Rgbww rgbww,
54 u8* b0_out, u8* b1_out, u8* b2_out,
55 u8* b3_out, u8* b4_out) FL_NOEXCEPT {
56 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
57 pc->loadAndScaleRGBWW(rgbww, b0_out, b1_out, b2_out, b3_out, b4_out);
58 }
59
60 static void loadAndScaleRGB(void* pixel_controller, u8* r_out, u8* g_out, u8* b_out) FL_NOEXCEPT {
61 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
62 pc->loadAndScaleRGB(r_out, g_out, b_out);
63 }
64
65 // NOTE: loadAndScale_APA102_HD() removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
66 // NOTE: loadAndScale_WS2816_HD() removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
67
68 static void stepDithering(void* pixel_controller) FL_NOEXCEPT {
69 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
70 pc->stepDithering();
71 }
72
73 static void advanceData(void* pixel_controller) FL_NOEXCEPT {
74 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
75 pc->advanceData();
76 }
77
78 static int size(void* pixel_controller) FL_NOEXCEPT {
79 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
80 return pc->size();
81 }
82 static bool has(void* pixel_controller, int n) FL_NOEXCEPT {
83 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
84 return pc->has(n);
85 }
86
87 // function for loadRGBScaleAndBrightness
88 #if FASTLED_HD_COLOR_MIXING
89 static void loadRGBScaleAndBrightness(void* pixel_controller, u8* c0, u8* c1, u8* c2, u8* brightness) FL_NOEXCEPT {
90 PixelControllerT* pc = static_cast<PixelControllerT*>(pixel_controller);
91 pc->loadRGBScaleAndBrightness(c0, c1, c2, brightness);
92 }
93
94 // Deprecated: for backwards compatibility
95 static void getHdScale(void* pixel_controller, u8* c0, u8* c1, u8* c2, u8* brightness) FL_NOEXCEPT {
96 loadRGBScaleAndBrightness(pixel_controller, c0, c1, c2, brightness);
97 }
98 #endif
99};
100
101typedef void (*loadAndScaleRGBWFunction)(void* pixel_controller, Rgbw rgbw, u8* b0_out, u8* b1_out, u8* b2_out, u8* b3_out);
102typedef void (*loadAndScaleRGBWWFunction)(void* pixel_controller, Rgbww rgbww, u8* b0_out, u8* b1_out, u8* b2_out, u8* b3_out, u8* b4_out);
103typedef void (*loadAndScaleRGBFunction)(void* pixel_controller, u8* r_out, u8* g_out, u8* b_out);
104// NOTE: loadAndScale_APA102_HDFunction removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
105// NOTE: loadAndScale_WS2816_HDFunction removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
106typedef void (*stepDitheringFunction)(void* pixel_controller);
107typedef void (*advanceDataFunction)(void* pixel_controller);
108typedef int (*sizeFunction)(void* pixel_controller);
109typedef bool (*hasFunction)(void* pixel_controller, int n);
110typedef u8 (*globalBrightness)(void* pixel_controller);
111typedef void (*loadRGBScaleAndBrightnessFunction)(void* pixel_controller, u8* c0, u8* c1, u8* c2, u8* brightness);
112typedef void (*getHdScaleFunction)(void* pixel_controller, u8* c0, u8* c1, u8* c2, u8* brightness);
113
114
115// PixelIterator is turns a PixelController<> into a concrete object that can be used to iterate
116// over pixels and transform them into driver data. See PixelController<>::as_iterator() for how
117// to create a PixelIterator.
118// Note: This is designed for micro-controllers with a lot of memory. DO NOT use this in the core library
119// as a PixelIterator consumes a *lot* more instruction data than an instance of PixelController<RGB_ORDER>.
120// This iterator is designed for code in src/platforms/**.
122 public:
123 template<typename PixelControllerT>
124 PixelIterator(PixelControllerT* pc, Rgbw rgbw,
126 : mPixelController(pc), mRgbw(rgbw), mRgbww(rgbww) {
127 // Manually build up a vtable.
128 // Wait... what? Stupid nerds trying to show off how smart they are...
129 // Why not just use a virtual function?!
130 //
131 // Before you think this then you should know that the alternative straight
132 // forward way is to have a virtual interface class that PixelController inherits from.
133 // ...and that was already tried. And if you try to do this yourself
134 // this then let me tell you what is going to happen...
135 //
136 // EVERY SINGLE PLATFORM THAT HAS A COMPILED BINARY SIZE CHECK WILL IMMEDIATELY
137 // FAIL AS THE BINARY BLOWS UP BY 10-30%!!! It doesn't matter if only one PixelController
138 // with a vtable is used, gcc seems not to de-virtualize the calls. And we really care
139 // about binary size since FastLED needs to run on those tiny little microcontrollers like
140 // the Attiny85 (and family) which are in the sub $1 range used for commercial products.
141 //
142 // So to satisfy these tight memory requirements we make the dynamic dispatch used in PixelIterator
143 // an optional zero-cost abstraction which doesn't affect the binary size for platforms that
144 // don't use it. So that's why we are using this manual construction of the vtable that is built
145 // up using template magic. If your platform has lots of memory then you'll gladly trade
146 // a sliver of memory for the convenience of having a concrete implementation of
147 // PixelController that you can use without having to make all your driver code a template.
148 //
149 // Btw, this pattern in C++ is called the "type-erasure pattern". It allows non virtual
150 // polymorphism by leveraging the C++ template system to ensure type safety.
152 mLoadAndScaleRGBW = &Vtable::loadAndScaleRGBW;
153 mLoadAndScaleRGBWW = &Vtable::loadAndScaleRGBWW;
154 mLoadAndScaleRGB = &Vtable::loadAndScaleRGB;
155 // NOTE: mLoadAndScale_APA102_HD removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
156 // NOTE: mLoadAndScale_WS2816_HD removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
157 mStepDithering = &Vtable::stepDithering;
158 mAdvanceData = &Vtable::advanceData;
159 mSize = &Vtable::size;
160 mHas = &Vtable::has;
161 #if FASTLED_HD_COLOR_MIXING
162 mLoadRGBScaleAndBrightness = &Vtable::loadRGBScaleAndBrightness;
163 mGetHdScale = &Vtable::getHdScale;
164 #endif
165 }
166
167 bool has(int n) FL_NOEXCEPT { return mHas(mPixelController, n); }
168 void loadAndScaleRGBW(u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *w_out) FL_NOEXCEPT {
169 mLoadAndScaleRGBW(mPixelController, mRgbw, b0_out, b1_out, b2_out, w_out);
170 }
171 void loadAndScaleRGBWW(u8 *b0_out, u8 *b1_out, u8 *b2_out,
172 u8 *b3_out, u8 *b4_out) FL_NOEXCEPT {
173 mLoadAndScaleRGBWW(mPixelController, mRgbww, b0_out, b1_out, b2_out, b3_out, b4_out);
174 }
175 void loadAndScaleRGB(u8 *r_out, u8 *g_out, u8 *b_out) FL_NOEXCEPT {
176 mLoadAndScaleRGB(mPixelController, r_out, g_out, b_out);
177 }
178 // NOTE: loadAndScale_APA102_HD() removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
179 // NOTE: loadAndScale_WS2816_HD() removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
183
185 Rgbw get_rgbw() const FL_NOEXCEPT { return mRgbw; }
186
187 void set_rgbww(Rgbww rgbww) FL_NOEXCEPT { mRgbww = rgbww; }
188 Rgbww get_rgbww() const FL_NOEXCEPT { return mRgbww; }
189
190 #if FASTLED_HD_COLOR_MIXING
191 void loadRGBScaleAndBrightness(u8* c0, u8* c1, u8* c2, u8* brightness) FL_NOEXCEPT {
192 mLoadRGBScaleAndBrightness(mPixelController, c0, c1, c2, brightness);
193 }
194
195 FL_DEPRECATED("Use loadRGBScaleAndBrightness() instead") FL_NOEXCEPT
196 void getHdScale(u8* c0, u8* c1, u8* c2, u8* brightness) {
197 loadRGBScaleAndBrightness(c0, c1, c2, brightness);
198 }
199 #endif
200
201 template <typename CONTAINER_UIN8_T>
202 void writeWS2812(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
203 auto back_ins = fl::back_inserter(*out);
204 // (#2558) Dispatch order: RGBWW > RGBW > RGB. The variant migration
205 // makes these mutually exclusive — at most one alternative is active.
206 if (mRgbww.active()) {
207 auto range = makeScaledPixelRangeRGBWW(this);
208 encodeWS2812_RGBWW(range.first, range.second, back_ins);
209 } else if (mRgbw.active()) {
210 auto range = makeScaledPixelRangeRGBW(this);
211 encodeWS2812_RGBW(range.first, range.second, back_ins);
212 } else {
213 auto range = makeScaledPixelRangeRGB(this);
214 encodeWS2812_RGB(range.first, range.second, back_ins);
215 }
216 }
217
222 template <typename CONTAINER_UIN8_T>
223 void writeAPA102(CONTAINER_UIN8_T* out, bool hd_gamma = false) FL_NOEXCEPT {
224 auto back_ins = fl::back_inserter(*out);
225
226 #if FASTLED_HD_COLOR_MIXING
227 if (hd_gamma) {
228 // HD gamma mode: per-LED brightness
229 auto pixel_range = makeScaledPixelRangeRGB(this);
230 auto brightness_range = makeScaledBrightnessRange(this);
231 encodeAPA102_HD(pixel_range.first, pixel_range.second,
232 brightness_range.first, back_ins);
233 return;
234 }
235 #endif
236
237 #if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
238 // Global brightness mode: extract from first pixel
239 auto pixel_range = makeScaledPixelRangeRGB(this);
240 encodeAPA102_AutoBrightness(pixel_range.first, pixel_range.second,
241 back_ins);
242 #else
243 // Full brightness mode
244 auto pixel_range = makeScaledPixelRangeRGB(this);
245 encodeAPA102(pixel_range.first, pixel_range.second,
246 back_ins, 31);
247 #endif
248 }
249
254 template <typename CONTAINER_UIN8_T>
255 void writeSK9822(CONTAINER_UIN8_T* out, bool hd_gamma = false) FL_NOEXCEPT {
256 auto back_ins = fl::back_inserter(*out);
257
258 #if FASTLED_HD_COLOR_MIXING
259 if (hd_gamma) {
260 // HD gamma mode: per-LED brightness
261 auto pixel_range = makeScaledPixelRangeRGB(this);
262 auto brightness_range = makeScaledBrightnessRange(this);
263 encodeSK9822_HD(pixel_range.first, pixel_range.second,
264 brightness_range.first, back_ins);
265 return;
266 }
267 #endif
268
269 #if FASTLED_USE_GLOBAL_BRIGHTNESS == 1
270 // Global brightness mode: extract from first pixel
271 auto pixel_range = makeScaledPixelRangeRGB(this);
272 encodeSK9822_AutoBrightness(pixel_range.first, pixel_range.second,
273 back_ins);
274 #else
275 // Full brightness mode
276 auto pixel_range = makeScaledPixelRangeRGB(this);
277 encodeSK9822(pixel_range.first, pixel_range.second,
278 back_ins, 31);
279 #endif
280 }
281
282 // ========== SPI Chipset Encoders ==========
283 // Refactored to use standalone encoder functions in src/fl/chipsets/encoders/
284
289 template <typename CONTAINER_UIN8_T>
290 void writeWS2801(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
291 auto back_ins = fl::back_inserter(*out);
292 auto pixel_range = makeScaledPixelRangeRGB(this);
293 encodeWS2801(pixel_range.first, pixel_range.second, back_ins);
294 }
295
300 template <typename CONTAINER_UIN8_T>
301 void writeWS2803(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
302 auto back_ins = fl::back_inserter(*out);
303 auto pixel_range = makeScaledPixelRangeRGB(this);
304 encodeWS2803(pixel_range.first, pixel_range.second, back_ins);
305 }
306
310 template <typename CONTAINER_UIN8_T>
311 void writeP9813(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
312 auto back_ins = fl::back_inserter(*out);
313 auto pixel_range = makeScaledPixelRangeRGB(this);
314 encodeP9813(pixel_range.first, pixel_range.second, back_ins);
315 }
316
320 template <typename CONTAINER_UIN8_T>
321 void writeLPD8806(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
322 auto back_ins = fl::back_inserter(*out);
323 auto pixel_range = makeScaledPixelRangeRGB(this);
324 encodeLPD8806(pixel_range.first, pixel_range.second, back_ins);
325 }
326
330 template <typename CONTAINER_UIN8_T>
331 void writeLPD6803(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
332 auto back_ins = fl::back_inserter(*out);
333 auto pixel_range = makeScaledPixelRangeRGB(this);
334 encodeLPD6803(pixel_range.first, pixel_range.second, back_ins);
335 }
336
340 template <typename CONTAINER_UIN8_T>
341 void writeSM16716(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
342 auto back_ins = fl::back_inserter(*out);
343 auto pixel_range = makeScaledPixelRangeRGB(this);
344 encodeSM16716(pixel_range.first, pixel_range.second, back_ins);
345 }
346
350 template <typename CONTAINER_UIN8_T>
351 void writeHD108(CONTAINER_UIN8_T* out) FL_NOEXCEPT {
352 auto back_ins = fl::back_inserter(*out);
353
354 #if FASTLED_HD_COLOR_MIXING
355 // HD mode: per-LED brightness
356 auto pixel_range = makeScaledPixelRangeRGB(this);
357 auto brightness_range = makeScaledBrightnessRange(this);
358 encodeHD108_HD(pixel_range.first, pixel_range.second,
359 brightness_range.first, back_ins);
360 #else
361 // Standard mode: global brightness (255 = full)
362 auto pixel_range = makeScaledPixelRangeRGB(this);
363 encodeHD108(pixel_range.first, pixel_range.second,
364 back_ins, 255);
365 #endif
366 }
367
368 private:
369 // vtable emulation
370 void* mPixelController = nullptr;
376 // NOTE: mLoadAndScale_APA102_HD removed - use fl::loadAndScale_APA102_HD<RGB_ORDER>() from apa102.h encoder
377 // NOTE: mLoadAndScale_WS2816_HD removed - use fl::loadAndScale_WS2816_HD<RGB_ORDER>() from ws2816.h encoder
381 hasFunction mHas = nullptr;
382 #if FASTLED_HD_COLOR_MIXING
383 loadRGBScaleAndBrightnessFunction mLoadRGBScaleAndBrightness = nullptr;
384 getHdScaleFunction mGetHdScale = nullptr;
385 #endif
386};
387
388
389// ===========================================================================
390// Implementation of adapter advance() methods
391// ===========================================================================
392// These implementations are defined here (after PixelIterator is complete)
393// because they require calling methods on the fully-defined PixelIterator type.
394
395namespace detail {
396
397// ScaledPixelIteratorRGB implementation
399 if (!mPixels) {
400 mHasValue = false;
401 return;
402 }
403
404 if (mPixels->has(1)) {
405 u8 b0, b1, b2;
406 mPixels->loadAndScaleRGB(&b0, &b1, &b2);
407 mCurrent = array<u8, 3>{{b0, b1, b2}}; // Wire order bytes
408 mPixels->stepDithering();
409 mPixels->advanceData();
410 mHasValue = true;
411 } else {
412 mHasValue = false;
413 }
414}
415
416// ScaledPixelIteratorRGBW implementation
418 if (!mPixels) {
419 mHasValue = false;
420 return;
421 }
422
423 if (mPixels->has(1)) {
424 u8 b0, b1, b2, b3;
425 mPixels->loadAndScaleRGBW(&b0, &b1, &b2, &b3);
426 mCurrent = array<u8, 4>{{b0, b1, b2, b3}}; // Wire order bytes
427 mPixels->stepDithering();
428 mPixels->advanceData();
429 mHasValue = true;
430 } else {
431 mHasValue = false;
432 }
433}
434
435// ScaledPixelIteratorRGBWW implementation (issue #2558)
437 if (!mPixels) {
438 mHasValue = false;
439 return;
440 }
441
442 if (mPixels->has(1)) {
443 u8 b0, b1, b2, b3, b4;
444 mPixels->loadAndScaleRGBWW(&b0, &b1, &b2, &b3, &b4);
445 mCurrent = array<u8, 5>{{b0, b1, b2, b3, b4}}; // Wire-order 5 bytes
446 mPixels->stepDithering();
447 mPixels->advanceData();
448 mHasValue = true;
449 } else {
450 mHasValue = false;
451 }
452}
453
454// ScaledPixelIteratorBrightness implementation
456 if (!mPixels) {
457 mHasValue = false;
458 return;
459 }
460
461 if (mPixels->has(1)) {
462 #if FASTLED_HD_COLOR_MIXING
463 u8 r, g, b, brightness;
464 mPixels->loadRGBScaleAndBrightness(&r, &g, &b, &brightness);
466 #else
467 // Fallback: compute brightness from max RGB component
468 u8 r, g, b;
469 mPixels->loadAndScaleRGB(&r, &g, &b);
470 // Use sequential comparisons to avoid nested fl::max (helps AVR register allocation)
471 u8 max_rg = (r > g) ? r : g;
472 mCurrent = (max_rg > b) ? max_rg : b;
473 #endif
474 mPixels->stepDithering();
475 mPixels->advanceData();
476 mHasValue = true;
477 } else {
478 mHasValue = false;
479 }
480}
481
482// ScaledPixelIteratorRGB16 implementation
484 if (!mPixels) {
485 mHasValue = false;
486 return;
487 }
488
489 if (mPixels->has(1)) {
490 // Get wire-ordered, color-corrected RGB bytes from PixelIterator (RGB reordering already applied)
491 u8 b0, b1, b2;
493
494 #if FASTLED_HD_COLOR_MIXING
495 // HD mode: RGB is color-corrected but NOT brightness-scaled
496 mPixels->loadRGBScaleAndBrightness(&b0, &b1, &b2, &brightness);
497 #else
498 // Standard mode: RGB is color-corrected AND brightness-scaled (premixed)
499 mPixels->loadAndScaleRGB(&b0, &b1, &b2);
500 brightness = 255; // No separate brightness scaling needed
501 #endif
502
503 // Map 8-bit → 16-bit RGB (color correction already applied)
504 u16 r16 = fl::map8_to_16(b0);
505 u16 g16 = fl::map8_to_16(b1);
506 u16 b16 = fl::map8_to_16(b2);
507
508 // Apply brightness scaling in HD mode (brightness not yet applied by loadRGBScaleAndBrightness)
509 if (brightness != 255) {
510 r16 = scale16by8(r16, brightness);
511 g16 = scale16by8(g16, brightness);
512 b16 = scale16by8(b16, brightness);
513 }
514
515 mCurrent = array<u16, 3>{{r16, g16, b16}}; // Wire order 16-bit channels
516 mPixels->stepDithering();
517 mPixels->advanceData();
518 mHasValue = true;
519 } else {
520 mHasValue = false;
521 }
522}
523
524} // namespace detail
525
526
527} // namespace fl
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
Rgbw rgbw
void writeHD108(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in HD108 format (zero allocation)
void writeAPA102(CONTAINER_UIN8_T *out, bool hd_gamma=false) FL_NOEXCEPT
Encode pixels in APA102/DOTSTAR format (zero allocation)
void writeP9813(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in P9813 format (zero allocation)
void writeWS2801(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in WS2801 format (zero allocation)
int size() FL_NOEXCEPT
void set_rgbww(Rgbww rgbww) FL_NOEXCEPT
stepDitheringFunction mStepDithering
void loadAndScaleRGBWW(u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out, u8 *b4_out) FL_NOEXCEPT
advanceDataFunction mAdvanceData
bool has(int n) FL_NOEXCEPT
void loadAndScaleRGBW(u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *w_out) FL_NOEXCEPT
void writeSM16716(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in SM16716 format (zero allocation)
void advanceData() FL_NOEXCEPT
void set_rgbw(Rgbw rgbw) FL_NOEXCEPT
loadAndScaleRGBWWFunction mLoadAndScaleRGBWW
loadAndScaleRGBFunction mLoadAndScaleRGB
void loadAndScaleRGB(u8 *r_out, u8 *g_out, u8 *b_out) FL_NOEXCEPT
void writeLPD6803(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in LPD6803 format (zero allocation)
void writeWS2812(CONTAINER_UIN8_T *out) FL_NOEXCEPT
void writeSK9822(CONTAINER_UIN8_T *out, bool hd_gamma=false) FL_NOEXCEPT
Encode pixels in SK9822 format (zero allocation)
Rgbw get_rgbw() const FL_NOEXCEPT
void stepDithering() FL_NOEXCEPT
Rgbww get_rgbww() const FL_NOEXCEPT
void writeWS2803(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in WS2803 format (zero allocation)
loadAndScaleRGBWFunction mLoadAndScaleRGBW
PixelIterator(PixelControllerT *pc, Rgbw rgbw, Rgbww rgbww=RgbwwInvalid::value()) FL_NOEXCEPT
void writeLPD8806(CONTAINER_UIN8_T *out) FL_NOEXCEPT
Encode pixels in LPD8806 format (zero allocation)
A fixed-size array implementation similar to std::array.
Definition array.h:27
bool mHasValue
true if current value is valid
u8 mCurrent
Current brightness value (cached)
PixelIterator * mPixels
Underlying PixelIterator.
void advance() FL_NOEXCEPT
Advance to next brightness value (or mark as end)
PixelIterator * mPixels
Underlying PixelIterator.
array< u16, 3 > mCurrent
Current pixel value (cached, wire order, 16-bit)
void advance() FL_NOEXCEPT
Advance to next pixel (or mark as end)
bool mHasValue
true if current pixel is valid
PixelIterator * mPixels
Underlying PixelIterator.
void advance() FL_NOEXCEPT
Advance to next pixel (or mark as end)
array< u8, 3 > mCurrent
Current pixel value (cached, wire order)
bool mHasValue
true if current pixel is valid
array< u8, 4 > mCurrent
Current pixel value (cached, wire order)
void advance() FL_NOEXCEPT
Advance to next pixel (or mark as end)
bool mHasValue
true if current pixel is valid
PixelIterator * mPixels
Underlying PixelIterator.
APA102/DOTSTAR SPI chipset encoder.
HD108 SPI chipset encoder.
P9813 SPI chipset encoder.
SM16716 SPI chipset encoder.
WS2801/WS2803 SPI chipset encoder.
Functions for red, green, blue, white (RGBW) output.
Integer mapping functions between different integer sizes.
u16 map8_to_16(u8 x) FL_NOEXCEPT
Definition intmap.h:48
unsigned char u8
Definition stdint.h:131
LPD6803 SPI chipset encoder.
LPD8806 SPI chipset encoder.
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
pair< detail::ScaledPixelIteratorRGB, detail::ScaledPixelIteratorRGB > makeScaledPixelRangeRGB(PixelIterator *pixels) FL_NOEXCEPT
Create RGB input iterator range from PixelIterator.
unsigned char u8
Definition stdint.h:131
void(* stepDitheringFunction)(void *pixel_controller)
void encodeWS2812_RGBWW(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode 5-byte pixel data in WS2812 format (issue #2558, RGBWW).
Definition ws2812.h:86
pair< detail::ScaledPixelIteratorRGBWW, detail::ScaledPixelIteratorRGBWW > makeScaledPixelRangeRGBWW(PixelIterator *pixels) FL_NOEXCEPT
Create RGBWW input iterator range from PixelIterator (issue #2558)
void encodeWS2801(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in WS2801/WS2803 format.
Definition ws2801.h:41
void encodeAPA102(InputIterator first, InputIterator last, OutputIterator out, u8 global_brightness=31) FL_NOEXCEPT
Encode pixel data in APA102 format with global brightness.
Definition apa102.h:45
int(* sizeFunction)(void *pixel_controller)
back_insert_iterator< Container > back_inserter(Container &c) FL_NOEXCEPT
Helper function to create a back_insert_iterator.
Definition iterator.h:139
void(* loadAndScaleRGBWFunction)(void *pixel_controller, Rgbw rgbw, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out)
FL_NO_INLINE_IF_AVR void encodeSK9822_AutoBrightness(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in SK9822 format (auto-detected brightness from first pixel)
Definition sk9822.h:121
void encodeWS2812_RGB(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode 3-byte pixel data in WS2812 format.
Definition ws2812.h:35
void encodeWS2803(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in WS2803 format (alias for WS2801)
Definition ws2803.h:31
void(* getHdScaleFunction)(void *pixel_controller, u8 *c0, u8 *c1, u8 *c2, u8 *brightness)
FL_NO_INLINE_IF_AVR FL_OPTIMIZE_O2 void encodeAPA102_AutoBrightness(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in APA102 format (auto-detected brightness from first pixel)
Definition apa102.h:131
void encodeLPD6803(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in LPD6803 format.
Definition lpd6803.h:35
pair< detail::ScaledPixelIteratorBrightness, detail::ScaledPixelIteratorBrightness > makeScaledBrightnessRange(PixelIterator *pixels) FL_NOEXCEPT
Create brightness input iterator range from PixelIterator.
pair< detail::ScaledPixelIteratorRGBW, detail::ScaledPixelIteratorRGBW > makeScaledPixelRangeRGBW(PixelIterator *pixels) FL_NOEXCEPT
Create RGBW input iterator range from PixelIterator.
bool(* hasFunction)(void *pixel_controller, int n)
void encodeSM16716(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in SM16716 format.
Definition sm16716.h:32
void encodeWS2812_RGBW(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode 4-byte pixel data in WS2812 format.
Definition ws2812.h:53
void(* loadAndScaleRGBFunction)(void *pixel_controller, u8 *r_out, u8 *g_out, u8 *b_out)
void encodeHD108_HD(InputIterator first, InputIterator last, BrightnessIterator brightness_first, OutputIterator out) FL_NOEXCEPT
Encode pixel data in HD108 format with per-LED brightness.
Definition hd108.h:90
void(* loadAndScaleRGBWWFunction)(void *pixel_controller, Rgbww rgbww, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out, u8 *b4_out)
u8(* globalBrightness)(void *pixel_controller)
void(* advanceDataFunction)(void *pixel_controller)
void(* loadRGBScaleAndBrightnessFunction)(void *pixel_controller, u8 *c0, u8 *c1, u8 *c2, u8 *brightness)
void encodeLPD8806(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in LPD8806 format.
Definition lpd8806.h:33
void encodeAPA102_HD(InputIterator first, InputIterator last, BrightnessIterator brightness_first, OutputIterator out) FL_NOEXCEPT
Encode pixel data in APA102 format with per-LED brightness.
Definition apa102.h:86
void encodeHD108(InputIterator first, InputIterator last, OutputIterator out, u8 global_brightness=255) FL_NOEXCEPT
Encode pixel data in HD108 format with global brightness.
Definition hd108.h:38
void encodeP9813(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in P9813 format.
Definition p9813.h:33
void encodeSK9822_HD(InputIterator first, InputIterator last, BrightnessIterator brightness_first, OutputIterator out) FL_NOEXCEPT
Encode pixel data in SK9822 format with per-LED brightness.
Definition sk9822.h:78
void encodeSK9822(InputIterator first, InputIterator last, OutputIterator out, u8 global_brightness=31) FL_NOEXCEPT
Encode pixel data in SK9822 format with global brightness.
Definition sk9822.h:38
Base definition for an LED controller.
Definition crgb.hpp:179
Adapter layer bridging PixelIterator to encoder input iterators.
5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) configuration types (issue #2558,...
#define FL_DEPRECATED(msg)
#define FL_NOEXCEPT
SK9822 SPI chipset encoder.
static void loadAndScaleRGBW(void *pixel_controller, Rgbw rgbw, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out) FL_NOEXCEPT
static bool has(void *pixel_controller, int n) FL_NOEXCEPT
static void advanceData(void *pixel_controller) FL_NOEXCEPT
static void loadAndScaleRGBWW(void *pixel_controller, Rgbww rgbww, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out, u8 *b4_out) FL_NOEXCEPT
static int size(void *pixel_controller) FL_NOEXCEPT
static void stepDithering(void *pixel_controller) FL_NOEXCEPT
static void loadAndScaleRGB(void *pixel_controller, u8 *r_out, u8 *g_out, u8 *b_out) FL_NOEXCEPT
Per-strip RGBWW configuration.
Definition rgbww.h:60
static Rgbww value() FL_NOEXCEPT
Definition rgbww.h:90
WS2803 SPI chipset encoder (WS2801 alias)
WS2812/WS2812B/WS2813/NeoPixel encoder.