FastLED 3.10.8
Loading...
Searching...
No Matches
pixel_controller.h
Go to the documentation of this file.
1#pragma once
2
5
6// Note that new code should use the PixelIterator concrete object to write out
7// led data.
8// Using this class deep in driver code is deprecated because it's templates will
9// infact everything it touches. PixelIterator is concrete and doesn't have these
10// problems. See PixelController::as_iterator() for how to create a PixelIterator.
11
12
13#include "fl/math/intmap.h"
14#include "fl/system/sketch_macros.h" // IWYU pragma: keep (FL_PLATFORM_HAS_TINY_MEMORY)
15#include "fl/math/math8.h"
16#include "platforms/is_platform.h"
17
18#include "rgbw.h"
19#include "fl/gfx/rgbww.h"
21#include "fl/log/log.h"
24#include "fl/math/scale8.h"
25#include "fl/math/math8.h"
26#include "eorder.h"
27#include "dither_mode.h"
28#include "pixel_iterator.h"
29#include "crgb.h"
30#include "fl/stl/variant.h" // for PixelControllerAny.
31#include "fl/gfx/binary_dither.h" // last: reads NO_DITHERING, like the code it replaced
32#include "fl/stl/noexcept.h"
33
38
39
40
41
42
49#define RO(X) RGB_BYTE(RGB_ORDER, X)
50
57#define RGB_BYTE(RO,X) ((static_cast<int>(RO)>>(3*(2-(X)))) & 0x3)
58
61#define RGB_BYTE0(RO) ((static_cast<int>(RO)>>6) & 0x3)
64#define RGB_BYTE1(RO) ((static_cast<int>(RO)>>3) & 0x3)
67#define RGB_BYTE2(RO) (static_cast<int>(RO) & 0x3)
68
69// operator byte *(struct CRGB[] arr) { return (byte*)arr; }
70
79 #if FASTLED_HD_COLOR_MIXING
80 CRGB color;
82 #endif
83
88 adj.premixed = CRGB(255, 255, 255);
89 #if FASTLED_HD_COLOR_MIXING
90 adj.color = CRGB(255, 255, 255);
91 adj.brightness = 255;
92 #endif
93 return adj;
94 }
95};
96
97
104template<EOrder RGB_ORDER, int LANES=1, fl::u32 MASK=0xFFFFFFFF>
106 const fl::u8 *mData;
107 int mLen;
112 int mOffsets[LANES];
114
115 enum {
116 kLanes = LANES,
117 kMask = MASK
118 };
122 static constexpr EOrder kColorOrder = RGB_ORDER;
123
127
129 #if FASTLED_HD_COLOR_MIXING
130 mColorAdjustment.premixed = CRGB(mColorAdjustment.brightness, mColorAdjustment.brightness, mColorAdjustment.brightness);
131 mColorAdjustment.color = CRGB(0xff, 0xff, 0xff);
132 #endif
133 }
134
138 copy(other);
139 }
140
145 if (this != &other) {
146 copy(other);
147 }
148 return *this;
149 }
150
151 template<EOrder RGB_ORDER_OTHER>
155
156 template<typename PixelControllerT>
157 void copy(const PixelControllerT& other) FL_NO_EXCEPT {
158 FL_STATIC_ASSERT(int(kLanes) == int(PixelControllerT::kLanes), "PixelController lanes must match or mOffsets will be wrong");
159 FL_STATIC_ASSERT(int(kMask) == int(PixelControllerT::kMask), "PixelController mask must match or else one or the other controls different lanes");
160 d[0] = other.d[0];
161 d[1] = other.d[1];
162 d[2] = other.d[2];
163 e[0] = other.e[0];
164 e[1] = other.e[1];
165 e[2] = other.e[2];
166 mData = other.mData;
167 mColorAdjustment = other.mColorAdjustment;
168 mAdvance = other.mAdvance;
169 mLenRemaining = mLen = other.mLen;
170 for(int i = 0; i < LANES; ++i) { mOffsets[i] = other.mOffsets[i]; }
171 }
172
175 void initOffsets(int len) FL_NO_EXCEPT {
176 int nOffset = 0;
177 for(int i = 0; i < LANES; ++i) {
178 mOffsets[i] = nOffset;
179 if((1<<i) & MASK) { nOffset += (len * mAdvance); }
180 }
181 }
182
191 const fl::u8 *d, int len, ColorAdjustment color_adjustment,
192 EDitherMode dither, bool advance, fl::u8 skip)
193 FL_NO_EXCEPT : mData(d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
195 mData += skip;
196 mAdvance = (advance) ? 3+skip : 0;
197 initOffsets(len);
198 }
199
206 const CRGB *d, int len, ColorAdjustment color_adjustment,
208 FL_NO_EXCEPT : mData((const fl::u8*)d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
210 mAdvance = 3;
211 initOffsets(len);
212 }
213
220 const CRGB &d, int len, ColorAdjustment color_adjustment, EDitherMode dither)
221 FL_NO_EXCEPT : mData((const fl::u8*)&d), mLen(len), mLenRemaining(len), mColorAdjustment(color_adjustment) {
223 mAdvance = 0;
224 initOffsets(len);
225 }
226
227 #if FASTLED_HD_COLOR_MIXING
228 fl::u8 global_brightness() const FL_NO_EXCEPT {
229 return mColorAdjustment.brightness;
230 }
231 #endif
232
237 return mData;
238 }
239
240
241 // ------------------------------------------------------------------------
242 // Temporal dithering. The algorithm, its documentation and its tests live
243 // in fl/gfx/binary_dither.h (#4672); these members only bind it to this
244 // controller's `d`/`e` state and brightness. `NO_DITHERING=1` selects
245 // fl::NoDither, under which all of them compile to nothing except the
246 // zeroing of `d`/`e` that hand-written drivers read.
247 // ------------------------------------------------------------------------
248
251 fl::u8 frame = 0;
253#if FL_PLATFORM_HAS_TINY_MEMORY
254 // Tiny targets retain their one-byte local phase counter.
255 static fl::u8 R = 0; // okay static in header: preserves the tiny-target footprint
256 frame = ++R;
257#else
258 // Other targets share a phase once per logical frame.
259 frame = fl::detail::ditherFrame();
260#endif
261 }
262 fl::Dither::init(d, e, mColorAdjustment.premixed.raw, frame);
263 }
264
273
278
283 return mLenRemaining >= n;
284 }
285
289 switch(dither) {
290 case BINARY_DITHER: init_binary_dithering(); break; // Initialize dithering algorithm
291 default: fl::Dither::clear(d, e); break; // Clear dither values (disabled)
292 }
293 }
294
298
302
306
309
313 // Toggles d between two values: if d=2 and e=5, becomes 3, then back to 2, etc.
314 // This spreads dithering spatially along the strip, preventing visible patterns
316 }
317
322
326
330 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 loadByte(PixelController & pc) FL_NO_EXCEPT { return pc.mData[RO(SLOT)]; }
331
336 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 loadByte(PixelController & pc, int lane) FL_NO_EXCEPT { return pc.mData[pc.mOffsets[lane] + RO(SLOT)]; }
337
343 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 dither(PixelController & pc, fl::u8 b) FL_NO_EXCEPT { return fl::Dither::apply(b, pc.d[RO(SLOT)]); }
344
351
357 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 scale(PixelController & pc, fl::u8 b) FL_NO_EXCEPT { return fl::scale8(b, pc.mColorAdjustment.premixed.raw[RO(SLOT)]); }
358
363 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 scale(PixelController & , fl::u8 b, fl::u8 scale) FL_NO_EXCEPT { return fl::scale8(b, scale); }
364
370
371
375 return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc)));
376 }
377
379 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 loadAndScale(PixelController & pc, int lane) FL_NO_EXCEPT {
380 return scale<SLOT>(pc, pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc, lane)));
381 }
382
385 return fl::scale8(pc.dither<SLOT>(pc, pc.loadByte<SLOT>(pc, lane), d), scale);
386 }
387
393 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 loadAndScale(PixelController & pc, int lane, fl::u8 scale) FL_NO_EXCEPT { return fl::scale8(pc.loadByte<SLOT>(pc, lane), scale); }
394
395
398 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 advanceAndLoadAndScale(PixelController & pc) FL_NO_EXCEPT { pc.advanceData(); return pc.loadAndScale<SLOT>(pc); }
399
403 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 advanceAndLoadAndScale(PixelController & pc, int lane) FL_NO_EXCEPT { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane); }
404
409 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 advanceAndLoadAndScale(PixelController & pc, int lane, fl::u8 scale) FL_NO_EXCEPT { pc.advanceData(); return pc.loadAndScale<SLOT>(pc, lane, scale); }
410
412
413
418
424 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 getd(PixelController & pc) FL_NO_EXCEPT { return pc.d[RO(SLOT)]; }
425
431 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 getscale(PixelController & pc) FL_NO_EXCEPT { return pc.mColorAdjustment.premixed.raw[RO(SLOT)]; }
432
434
435
437
438 // Helper functions to get around gcc stupidities
444
450
451 // LoadAndScale0 loads the pixel data in the order specified by RGB_ORDER and then scales it by the color correction values
452 // For example in color order GRB, loadAndScale0() will return the green channel scaled by the color correction value for green.
458
462
463 #if FASTLED_HD_COLOR_MIXING
464 template<int SLOT> FASTLED_FORCE_INLINE static fl::u8 getScaleFullBrightness(PixelController & pc) FL_NO_EXCEPT { return pc.mColorAdjustment.color.raw[RO(SLOT)]; }
465
470 FASTLED_FORCE_INLINE void loadRGBScaleAndBrightness(fl::u8* c0, fl::u8* c1, fl::u8* c2, fl::u8* brightness) FL_NO_EXCEPT {
471 *c0 = getScaleFullBrightness<0>(*this);
472 *c1 = getScaleFullBrightness<1>(*this);
473 *c2 = getScaleFullBrightness<2>(*this);
474 *brightness = mColorAdjustment.brightness;
475 }
476
478 FL_DEPRECATED("Use loadRGBScaleAndBrightness() instead")
479 FASTLED_FORCE_INLINE void getHdScale(fl::u8* c0, fl::u8* c1, fl::u8* c2, fl::u8* brightness) {
480 loadRGBScaleAndBrightness(c0, c1, c2, brightness);
481 }
482
486 return mColorAdjustment.brightness;
487 }
488 #endif
489
490 // NOTE: loadAndScale_APA102_HD() has been moved to src/fl/chipsets/encoders/apa102.h
491 // Use fl::loadAndScale_APA102_HD<RGB_ORDER>(pixels, ...) instead
492
494 fl::u8 *b2_out) FL_NO_EXCEPT {
495 *b0_out = loadAndScale0();
496 *b1_out = loadAndScale1();
497 *b2_out = loadAndScale2();
498 }
499
500 // NOTE: loadAndScale_WS2816_HD() has been moved to src/fl/chipsets/encoders/ws2816.h
501 // Use fl::loadAndScale_WS2816_HD<RGB_ORDER>(pixels, ...) instead
502
509 const fl::u8 b = mData[c];
510 return fl::scale8(fl::Dither::apply(b, d[c]), mColorAdjustment.premixed.raw[c]);
511 }
512
518 const Rgbw& rgbw, fl::u8 *r_out, fl::u8 *g_out, fl::u8 *b_out,
519 fl::u8 *w_out) FL_NO_EXCEPT {
520#ifdef FL_IS_AVR
522 // No RGBW conversion on AVR; W stays black, as in loadAndScaleRGBW.
523 *r_out = loadAndScaleChannel(0);
524 *g_out = loadAndScaleChannel(1);
525 *b_out = loadAndScaleChannel(2);
526 *w_out = 0;
527#else
528 const CRGB rgb(mData[0], mData[1], mData[2]);
529 *w_out = 0;
531 rgb.r, rgb.g, rgb.b,
532 mColorAdjustment.premixed.r, mColorAdjustment.premixed.g, mColorAdjustment.premixed.b,
533 r_out, g_out, b_out, w_out);
534#endif
535 }
536
539 fl::Rgbww rgbww, fl::u8 *r_out, fl::u8 *g_out, fl::u8 *b_out,
540 fl::u8 *ww_out, fl::u8 *wc_out) FL_NO_EXCEPT {
541#ifdef FL_IS_AVR
542 FL_UNUSED(rgbww);
543 FL_WARN_ONCE("RGBWW colorimetric is not supported on AVR -- the warm "
544 "and cool white channels will be black. Use an ESP32 / "
545 "Teensy / RP2040 target for full RGBWW support.");
546 *r_out = loadAndScaleChannel(0);
547 *g_out = loadAndScaleChannel(1);
548 *b_out = loadAndScaleChannel(2);
549 *ww_out = 0;
550 *wc_out = 0;
551#else
552 const CRGB rgb(mData[0], mData[1], mData[2]);
553 *ww_out = 0;
554 *wc_out = 0;
555 fl::rgb_2_rgbww(rgbww,
556 rgb.r, rgb.g, rgb.b,
557 mColorAdjustment.premixed.r,
558 mColorAdjustment.premixed.g,
559 mColorAdjustment.premixed.b,
560 r_out, g_out, b_out, ww_out, wc_out);
561#endif
562 }
563
565 const Rgbw& rgbw, fl::u8 *b0_out, fl::u8 *b1_out,
566 fl::u8 *b2_out, fl::u8 *b3_out) FL_NO_EXCEPT {
567#ifdef FL_IS_AVR
568 // Don't do RGBW conversion for AVR, just set the W pixel to black.
569 fl::u8 out[4] = {
570 // Get the pixels in native order.
574 0,
575 };
576 EOrderW w_placement = rgbw.w_placement;
577 // Apply w-component insertion.
579 w_placement, out[0], out[1], out[2],
580 0, // Pre-ordered RGB data with a 0 white component.
581 b0_out, b1_out, b2_out, b3_out);
582#else
583 const fl::u8 b0_index = RGB_BYTE0(RGB_ORDER); // Needed to re-order RGB back into led native order.
584 const fl::u8 b1_index = RGB_BYTE1(RGB_ORDER);
585 const fl::u8 b2_index = RGB_BYTE2(RGB_ORDER);
586 // Source-order RGB after white extraction, then the wire reorder.
587 CRGB rgb;
588 fl::u8 w = 0;
589 loadAndScaleRGBWUnordered(rgbw, &rgb.r, &rgb.g, &rgb.b, &w);
590 // Now finish the ordering so that the output is in the native led order for all of RGBW.
592 rgbw.w_placement,
593 rgb.raw[b0_index], // in-place re-ordering for the RGB data.
594 rgb.raw[b1_index],
595 rgb.raw[b2_index],
596 w, // The white component is not ordered in this call.
597 b0_out, b1_out, b2_out, b3_out); // RGBW data now in total native led order.
598#endif
599 }
600
606 fl::u8 *b0_out, fl::u8 *b1_out,
607 fl::u8 *b2_out, fl::u8 *b3_out,
608 fl::u8 *b4_out) FL_NO_EXCEPT {
609#ifdef FL_IS_AVR
610 // AVR: float colorimetric math is too expensive on the 8-bit core;
611 // the strip will get RGB-only output with both white channels black.
612 // Surface this with a FL_WARN_ONCE so the silent dropout is visible
613 // when debugging — a user configuring RGBWW on an AVR target almost
614 // certainly didn't expect their warm/cool W channels to be inert.
615 FL_WARN_ONCE("RGBWW colorimetric is not supported on AVR — the warm "
616 "and cool white channels will be black. Use an ESP32 / "
617 "Teensy / RP2040 target for full RGBWW support.");
618 fl::u8 r_pre = loadAndScale0();
619 fl::u8 g_pre = loadAndScale1();
620 fl::u8 b_pre = loadAndScale2();
622 rgbww.w_placement,
623 r_pre, g_pre, b_pre,
624 0, 0,
625 b0_out, b1_out, b2_out, b3_out, b4_out);
626#else
627 const fl::u8 b0_index = RGB_BYTE0(RGB_ORDER);
628 const fl::u8 b1_index = RGB_BYTE1(RGB_ORDER);
629 const fl::u8 b2_index = RGB_BYTE2(RGB_ORDER);
630 CRGB rgb;
631 fl::u8 ww = 0;
632 fl::u8 wc = 0;
633 loadAndScaleRGBWWUnordered(rgbww, &rgb.r, &rgb.g, &rgb.b, &ww, &wc);
635 rgbww.w_placement,
636 rgb.raw[b0_index],
637 rgb.raw[b1_index],
638 rgb.raw[b2_index],
639 ww, wc,
640 b0_out, b1_out, b2_out, b3_out, b4_out);
641#endif
642 }
643};
644
645/*
646using fl::RGB;
647using fl::RBG;
648using fl::GRB;
649using fl::GBR;
650using fl::BRG;
651using fl::BGR;
652*/
653
654
655
656
657
658
659
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
fl::UISlider scale("Scale", 4,.1, 4,.1)
#define RGB_ORDER
Rgbw rgbw
Temporal binary dithering, as one self-contained, testable unit (#4672).
Legacy header.
#define BINARY_DITHER
Enable dithering using binary dithering (only option)
Definition dither_mode.h:16
fl::u8 EDitherMode
The dither setting, either DISABLE_DITHER or BINARY_DITHER.
Definition dither_mode.h:19
Declares dithering options and types.
fl::EOrderW EOrderW
Definition eorder.h:13
fl::EOrder EOrder
Definition eorder.h:12
Defines color channel ordering enumerations.
Declares functions for five-bit gamma correction.
Integer mapping functions between different integer sizes.
Legacy compatibility header for 8-bit math functions.
Legacy compatibility header for 8-bit scaling functions.
fl::CRGB CRGB
Definition crgb.h:25
unsigned char u8
Definition stdint.h:131
#define FL_WARN_ONCE(...)
Definition log.h:439
Centralized logging categories for FastLED hardware interfaces and subsystems.
u8 ditherFrame() FL_NO_EXCEPT
Return the temporal-dither phase shared by all controllers in this frame.
unsigned char u8
Definition stdint.h:131
void rgbww_partial_reorder(EOrderWW ww_placement, u8 b0, u8 b1, u8 b2, u8 ww, u8 wc, u8 *out_b0, u8 *out_b1, u8 *out_b2, u8 *out_b3, u8 *out_b4) FL_NO_EXCEPT
Dispatch RGB->RGBWW for a given mode.
void rgbw_partial_reorder(EOrderW w_placement, u8 b0, u8 b1, u8 b2, u8 w, u8 *out_b0, u8 *out_b1, u8 *out_b2, u8 *out_b3) FL_NO_EXCEPT
Definition rgbw.cpp.hpp:679
FASTLED_FORCE_INLINE void rgb_2_rgbw(const Rgbw &cfg, u8 r, u8 g, u8 b, u8 r_scale, u8 g_scale, u8 b_scale, u8 *out_r, u8 *out_g, u8 *out_b, u8 *out_w) FL_NO_EXCEPT
Converts RGB to RGBW using one of the functions.
Definition rgbw.h:406
signed char i8
Definition stdint.h:130
FASTLED_FORCE_INLINE void rgb_2_rgbww(const Rgbww &cfg, fl::u8 r, fl::u8 g, fl::u8 b, fl::u8 r_scale, fl::u8 g_scale, fl::u8 b_scale, fl::u8 *out_r, fl::u8 *out_g, fl::u8 *out_b, fl::u8 *out_ww, fl::u8 *out_wc) FL_NO_EXCEPT
Definition rgbww.h:194
#define RGB_BYTE2(RO)
Gets the color channel for byte 2.
#define RGB_BYTE1(RO)
Gets the color channel for byte 1.
#define RGB_BYTE0(RO)
Gets the color channel for byte 0.
#define RO(X)
Gets the assigned color channel for a byte's position in the output, using the color order (EOrder) t...
Legacy header.
Functions for red, green, blue, white (RGBW) output.
5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) configuration types (issue #2558,...
#define FL_DISABLE_WARNING_IMPLICIT_INT_CONVERSION
#define FL_STATIC_ASSERT(...)
#define FASTLED_FORCE_INLINE
#define FL_UNUSED(x)
#define FL_DISABLE_WARNING_PUSH
#define FL_DEPRECATED(msg)
#define FL_DISABLE_WARNING_SIGN_CONVERSION
#define FL_DISABLE_WARNING_POP
#define FL_NO_EXCEPT
#define FL_DISABLE_WARNING_FLOAT_CONVERSION
Portable compile-time assertion wrapper.
static ColorAdjustment noAdjustment() FL_NO_EXCEPT
the per-channel scale values premixed with brightness.
Color adjustment structure for pixel output.
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale(PixelController &pc) FL_NO_EXCEPT
A version of loadAndScale() that advances the output data pointer.
FASTLED_FORCE_INLINE int size() const FL_NO_EXCEPT
Get the length of the LED strip.
PixelController(const CRGB &d, int len, ColorAdjustment color_adjustment, EDitherMode dither) FL_NO_EXCEPT
Constructor.
PixelController(const PixelController &other) FL_NO_EXCEPT
Copy constructor.
FASTLED_FORCE_INLINE void loadAndScaleRGBWUnordered(const Rgbw &rgbw, fl::u8 *r_out, fl::u8 *g_out, fl::u8 *b_out, fl::u8 *w_out) FL_NO_EXCEPT
loadAndScaleRGBW before its wire reorder: RGB in source order plus W.
PixelController(const CRGB *d, int len, ColorAdjustment color_adjustment, EDitherMode dither) FL_NO_EXCEPT
Constructor.
PixelController(const fl::u8 *d, int len, ColorAdjustment color_adjustment, EDitherMode dither, bool advance, fl::u8 skip) FL_NO_EXCEPT
Constructor.
static FASTLED_FORCE_INLINE fl::u8 loadAndScale(PixelController &pc) FL_NO_EXCEPT
Complete pipeline: load → dither → scale (THE MAGIC HAPPENS HERE!) Order is critical: pixel + dit...
FASTLED_FORCE_INLINE void loadAndScaleRGBW(const Rgbw &rgbw, fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out, fl::u8 *b3_out) FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0() FL_NO_EXCEPT
FASTLED_FORCE_INLINE bool has(int n) FL_NO_EXCEPT
Do we have n pixels left to process?
int mLenRemaining
counter for the number of LEDs left to process
FASTLED_FORCE_INLINE void loadAndScaleRGBWW(fl::Rgbww rgbww, fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out, fl::u8 *b3_out, fl::u8 *b4_out) FL_NO_EXCEPT
Load + scale a single pixel to 5-channel RGBWW (issue #2558).
FASTLED_FORCE_INLINE fl::u8 getScale2() FL_NO_EXCEPT
non-template alias of getscale<2>()
void disableColorAdjustment() FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 loadByte(PixelController &pc) FL_NO_EXCEPT
Read a byte of LED data.
FASTLED_FORCE_INLINE void stepDithering() FL_NO_EXCEPT
Step the dithering forward - creates triangular wave that toggles between pixels.
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale(PixelController &pc, int lane, fl::u8 scale) FL_NO_EXCEPT
A version of loadAndScale() that advances the output data pointer without dithering.
fl::u8 e[3]
[DITHER] Max dither range per R,G,B channel (inversely proportional to brightness)
FASTLED_FORCE_INLINE fl::u8 loadAndScale0(int lane) FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 loadAndScale1() FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0(int lane, fl::u8 scale) FL_NO_EXCEPT
stepDithering() and advanceAndLoadAndScale0()
PixelController(const PixelController< RGB_ORDER_OTHER, LANES, MASK > &other) FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 loadAndScaleChannel(fl::u8 c) FL_NO_EXCEPT
One source channel, loaded, dithered and scaled – loadAndScale<SLOT> with RO(SLOT) replaced by a runt...
static FASTLED_FORCE_INLINE fl::u8 dither(PixelController &, fl::u8 b, fl::u8 d) FL_NO_EXCEPT
Add explicit dither offset to pixel value (BEFORE scaling).
static FASTLED_FORCE_INLINE fl::u8 getscale(PixelController &pc) FL_NO_EXCEPT
Gets the scale data for the provided output slot.
const fl::u8 * getRawPixelData() const FL_NO_EXCEPT
Get read-only access to the current pixel data Used by encoders to access raw RGB values for HD proce...
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of advanceAndLoadAndScale<0>()
fl::u8 d[3]
[DITHER] Current dither offset per R,G,B channel (toggles via stepDithering)
int mOffsets[LANES]
the number of bytes to offset each lane from the starting pointer
FASTLED_FORCE_INLINE fl::u8 stepAdvanceAndLoadAndScale0(int lane) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale(PixelController &pc, int lane) FL_NO_EXCEPT
A version of loadAndScale() that advances the output data pointer.
static FASTLED_FORCE_INLINE fl::u8 loadAndScale(PixelController &pc, int lane) FL_NO_EXCEPT
Complete pipeline: load → dither → scale (parallel output version)
void initOffsets(int len) FL_NO_EXCEPT
Initialize the PixelController::mOffsets array based on the length of the strip.
ColorAdjustment mColorAdjustment
const fl::u8 * mData
pointer to the underlying LED data
int mLen
number of LEDs in the data for one lane
void enable_dithering(EDitherMode dither) FL_NO_EXCEPT
Toggle dithering enable/disable.
static constexpr EOrder kColorOrder
The colour order this instantiation writes, as a value.
static FASTLED_FORCE_INLINE fl::u8 scale(PixelController &pc, fl::u8 b) FL_NO_EXCEPT
Scale a value using the per-channel scale data.
FASTLED_FORCE_INLINE fl::PixelIterator as_iterator(const Rgbw &rgbw) FL_NO_EXCEPT
FASTLED_FORCE_INLINE void preStepFirstByteDithering() FL_NO_EXCEPT
Some chipsets pre-cycle the first byte, which means we want to cycle byte 0's dithering separately.
FASTLED_FORCE_INLINE int advanceBy() FL_NO_EXCEPT
Get the amount to advance the pointer by.
void init_binary_dithering() FL_NO_EXCEPT
Set up the values for binary dithering from the shared frame phase.
void reseed_binary_dithering(fl::u8 R) FL_NO_EXCEPT
Re-point binary dithering at phase R after construction, leaving the per-channel ranges e[] as init_b...
FASTLED_FORCE_INLINE int lanes() FL_NO_EXCEPT
Get the number of lanes of the Controller.
PixelController & operator=(const PixelController &other) FL_NO_EXCEPT
Copy assignment, through the same copy() as the copy constructor.
FASTLED_FORCE_INLINE void loadAndScaleRGBWWUnordered(fl::Rgbww rgbww, fl::u8 *r_out, fl::u8 *g_out, fl::u8 *b_out, fl::u8 *ww_out, fl::u8 *wc_out) FL_NO_EXCEPT
loadAndScaleRGBWW before its wire reorder. See loadAndScaleRGBWUnordered.
FASTLED_FORCE_INLINE bool ditherActive() const FL_NO_EXCEPT
Is temporal dithering on for this frame? (any channel has a range)
static FASTLED_FORCE_INLINE fl::u8 dither(PixelController &pc, fl::u8 b) FL_NO_EXCEPT
Add dither offset to pixel value (BEFORE scaling).
FASTLED_FORCE_INLINE fl::u8 getScale0() FL_NO_EXCEPT
non-template alias of getscale<0>()
FASTLED_FORCE_INLINE fl::u8 loadAndScale1(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<1>()
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0(int lane) FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 loadAndScale2() FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 loadAndScale(PixelController &pc, int lane, fl::u8 d, fl::u8 scale) FL_NO_EXCEPT
Complete pipeline: load → dither → scale (explicit dither/scale values)
FASTLED_FORCE_INLINE fl::u8 loadAndScale0() FL_NO_EXCEPT
FASTLED_FORCE_INLINE void advanceData() FL_NO_EXCEPT
Advance the data pointer forward, adjust position counter.
FASTLED_FORCE_INLINE fl::u8 loadAndScale1(int lane) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 scale(PixelController &, fl::u8 b, fl::u8 scale) FL_NO_EXCEPT
Scale a value.
void copy(const PixelControllerT &other) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 loadByte(PixelController &pc, int lane) FL_NO_EXCEPT
Read a byte of LED data for parallel output.
FASTLED_FORCE_INLINE fl::u8 loadAndScale0(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<0>()
static FASTLED_FORCE_INLINE fl::u8 getd(PixelController &pc) FL_NO_EXCEPT
Gets the dithering data for the provided output slot.
FASTLED_FORCE_INLINE fl::u8 advanceAndLoadAndScale0() FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 loadAndScale2(int lane, fl::u8 scale) FL_NO_EXCEPT
non-template alias of loadAndScale<2>()
FASTLED_FORCE_INLINE void loadAndScaleRGB(fl::u8 *b0_out, fl::u8 *b1_out, fl::u8 *b2_out) FL_NO_EXCEPT
FASTLED_FORCE_INLINE fl::u8 loadAndScale2(int lane) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::u8 loadAndScale(PixelController &pc, int lane, fl::u8 scale) FL_NO_EXCEPT
Loads and scales a single byte for a given output slot and lane.
fl::i8 mAdvance
how many bytes to advance the pointer by each time. For CRGB this is 3.
FASTLED_FORCE_INLINE fl::u8 getScale1() FL_NO_EXCEPT
non-template alias of getscale<1>()
Pixel controller class.
static FASTLED_FORCE_INLINE bool active(const u8(&e)[3]) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE void stepChannel(u8(&d)[3], const u8(&e)[3], int c) FL_NO_EXCEPT
step for a single channel (drivers that pre-step their first byte).
static FASTLED_FORCE_INLINE void reseed(u8(&d)[3], const u8(&e)[3], u8 frame) FL_NO_EXCEPT
Re-point d at frame, keeping the ranges init left in e.
static FASTLED_FORCE_INLINE void clear(u8(&d)[3], u8(&e)[3]) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE u8 apply(u8 b, u8 d) FL_NO_EXCEPT
Add the offset to a source byte, before scaling. Black is never lifted.
static FASTLED_FORCE_INLINE void init(u8(&d)[3], u8(&e)[3], const u8(&scale)[3], u8 frame) FL_NO_EXCEPT
Set up e from the per-channel brightness scale and d from frame.
static FASTLED_FORCE_INLINE void step(u8(&d)[3], const u8(&e)[3]) FL_NO_EXCEPT
Next pixel: toggle each offset to its complement in [0, e], so neighbours dither in opposite directio...