MCPcopy Create free account
hub / github.com/FastLED/FastLED / buildExpectedUCS7604

Function buildExpectedUCS7604

examples/AutoResearch/AutoResearchTest.cpp:129–167  ·  view source on GitHub ↗

@brief Build expected UCS7604 encoded bytes from LED data @param leds LED data span @param encoder Encoder selector identifying the UCS7604 variant @return Vector of expected encoded bytes (preamble + padding + pixel data)

Source from the content-addressed store, hash-verified

127/// @param encoder Encoder selector identifying the UCS7604 variant
128/// @return Vector of expected encoded bytes (preamble + padding + pixel data)
129static fl::vector<uint8_t> buildExpectedUCS7604(fl::span<CRGB> leds, fl::ClocklessEncoder encoder) {
130 fl::vector<uint8_t> expected;
131
132 // Map encoder to UCS7604Mode
133 fl::UCS7604Mode mode;
134 switch (encoder) {
135 case fl::ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_8BIT:
136 mode = fl::UCS7604Mode::UCS7604_MODE_8BIT_800KHZ;
137 break;
138 case fl::ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT:
139 mode = fl::UCS7604Mode::UCS7604_MODE_16BIT_800KHZ;
140 break;
141 case fl::ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT_1600:
142 mode = fl::UCS7604Mode::UCS7604_MODE_16BIT_1600KHZ;
143 break;
144 default:
145 return expected;
146 }
147
148 // Default current control (0x0F for all channels) matching channel.cpp.hpp defaults
149 fl::UCS7604CurrentControl current; // defaults to 0xF for all channels
150
151 // Create PixelIterator from LED data (RGB order, no color adjustment, no dithering)
152 PixelController<RGB> pc(leds.data(), leds.size(), ColorAdjustment::noAdjustment(), DISABLE_DITHER);
153 auto pixel_iter = pc.as_iterator(RgbwInvalid());
154
155 // For 16-bit modes, use default gamma 2.8
156 fl::shared_ptr<const fl::Gamma8> gamma;
157 bool use_gamma = (mode != fl::UCS7604Mode::UCS7604_MODE_8BIT_800KHZ);
158 if (use_gamma) {
159 gamma = fl::Gamma8::getOrCreate(2.8f);
160 }
161
162 // Encode using the same function the driver uses
163 fl::encodeUCS7604(pixel_iter, leds.size(), fl::back_inserter(expected),
164 mode, current, false /* is_rgbw */, gamma.get());
165
166 return expected;
167}
168
169// Decode SPI bit stream from raw RMT edges into LED RGB bytes
170// The SPI data pin carries APA102 encoded data clocked by PCLK.

Callers 2

runTestFunction · 0.85
runMultiTestFunction · 0.85

Calls 6

RgbwInvalidClass · 0.85
encodeUCS7604Function · 0.85
back_inserterFunction · 0.85
dataMethod · 0.45
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected