FastLED 3.10.6
Loading...
Searching...
No Matches
color_managed_source.h
Go to the documentation of this file.
1#pragma once
2
3// Streaming colour-managed pixel source (P6, #4040).
4//
5// The last stage of the wiring: something a `PixelIterator` can be built
6// over that runs the pipeline per pixel instead of the legacy scale.
7//
8// It is a source, not a buffer, and that is the point. C2 asks for the
9// per-pixel work to happen inside the existing iteration with no RGB16
10// framebuffer, and B3 forbids an intermediate RGB8 one. `showPixels`
11// already has a place that rewrites pixels -- the XYMap path materializes a
12// thread-local `CRGB` vector -- and putting the pipeline there would break
13// both rules at once. This reads one pixel, transforms it, and yields the
14// bytes; nothing is held between pixels.
15//
16// `PixelIterator`'s constructor is templated over its source, so this only
17// has to provide the same members `PixelController` does. It is not itself
18// templated on colour order: the order is applied to the three outputs at
19// the end, which avoids six near-identical instantiations for something
20// decided at bind time.
21
22#include "fl/gfx/pipeline.h"
23#include "fl/channels/options.h" // FL_COLOR_PIPELINE_SHARED
24#include "fl/channels/color_profile.h" // IWYU pragma: keep (EmitterProfile)
25#include "fl/stl/int.h"
26#include "fl/stl/noexcept.h"
27#include "fl/gfx/eorder.h"
28#include "fl/gfx/rgbw.h"
29#include "fl/gfx/rgbww.h"
30#include "pixel_controller.h"
31
32namespace fl {
33
34#if FL_COLOR_PIPELINE_SHARED
36#else
38#endif
39
46 public:
52 ColorPipelineFrameRef pipeline,
53 u8 dither_phase) FL_NO_EXCEPT;
56
61
70 void loadAndScaleRGB(u8* b0_out, u8* b1_out, u8* b2_out) FL_NO_EXCEPT;
71
72#if !FL_PLATFORM_HAS_TINY_MEMORY
80 void loadAndScaleRGB16(u16* b0_out, u16* b1_out, u16* b2_out) FL_NO_EXCEPT;
81#endif
82
85 void loadAndScaleRGBW(const Rgbw& rgbw, u8* b0_out, u8* b1_out, u8* b2_out,
86 u8* b3_out) FL_NO_EXCEPT;
87
90 void loadAndScaleRGBWW(Rgbww rgbww, u8* b0_out, u8* b1_out, u8* b2_out,
91 u8* b3_out, u8* b4_out) FL_NO_EXCEPT;
92
93#if FASTLED_HD_COLOR_MIXING
100 void loadRGBScaleAndBrightness(u8* c0, u8* c1, u8* c2,
102#endif
103
106 void stepDithering() FL_NO_EXCEPT { mController.stepDithering(); }
107
108 void advanceData() FL_NO_EXCEPT { mController.advanceData(); }
109 int size() const FL_NO_EXCEPT { return mController.size(); }
110 bool has(int n) FL_NO_EXCEPT { return mController.has(n); }
111
112 private:
117 static u8 quantize(i32 drive) FL_NO_EXCEPT;
118
123 static u8 quantizeDithered(i32 drive, u8 threshold) FL_NO_EXCEPT;
124
131
132#if !FL_PLATFORM_HAS_TINY_MEMORY
135 static u16 quantize16(i32 drive) FL_NO_EXCEPT;
136#endif
137
139#if FL_COLOR_PIPELINE_SHARED
141#else
143#endif
148};
149
150} // namespace fl
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
CLEDController * controller
Rgbw rgbw
void loadAndScaleRGB(u8 *b0_out, u8 *b1_out, u8 *b2_out) FL_NO_EXCEPT
The colour-managed path.
bool has(int n) FL_NO_EXCEPT
void loadAndScaleRGBW(const Rgbw &rgbw, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out) FL_NO_EXCEPT
Physical RGBW solve when a matching profile is bound; otherwise the legacy RGB-to-RGBW conversion.
StreamingPipelineQ16 & mPipeline
bool temporalDitherEnabled() const FL_NO_EXCEPT
True when the channel asked for dither this frame.
ColorManagedPixelSource(PixelController< RGB > &controller, EOrder order, ColorPipelineFrameRef pipeline, u8 dither_phase) FL_NO_EXCEPT
dither_phase is where this frame sits in the temporal-dither cycle.
void setFlux(u8 brightness) FL_NO_EXCEPT
Frame-local brightness is applied to the source's owned pipeline on shared tiers; only managed iterat...
static u8 quantize(i32 drive) FL_NO_EXCEPT
s16.16 drive to an 8-bit code, rounding to nearest.
int size() const FL_NO_EXCEPT
static u16 quantize16(i32 drive) FL_NO_EXCEPT
quantize onto the 16-bit wire.
void loadAndScaleRGB16(u16 *b0_out, u16 *b1_out, u16 *b2_out) FL_NO_EXCEPT
The same pixel, quantized once to 16 bits instead of to 8 (P8, #4042).
void stepDithering() FL_NO_EXCEPT
The legacy offsets are the wrapped controller's to toggle; this source never reads them (C5).
PixelController< RGB > & mController
void loadAndScaleRGBWW(Rgbww rgbww, u8 *b0_out, u8 *b1_out, u8 *b2_out, u8 *b3_out, u8 *b4_out) FL_NO_EXCEPT
Physical two-white solve when a matching RGBWW profile is bound; otherwise the legacy conversion.
static u8 quantizeDithered(i32 drive, u8 threshold) FL_NO_EXCEPT
quantize with the pipeline's temporal dither (P8, C5): floor(x) or floor(x) + 1 of the exact code x,...
A linear flux scalar in s16.16.
Definition flux_scalar.h:21
Functions for red, green, blue, white (RGBW) output.
unsigned char u8
Definition stdint.h:131
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:13
StreamingPipelineQ16 & ColorPipelineFrameRef
Base definition for an LED controller.
Definition crgb.hpp:179
Everything the per-pixel path needs, derived once when a profile binds.
Definition pipeline.h:73
Low level pixel data writing class.
5-channel RGB + warm-W + cool-W (RGBWW / RGBCCT) configuration types (issue #2558,...
Pixel controller class.
Per-strip RGBWW configuration.
Definition rgbww.h:60