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

Function writeUCS7604

src/fl/channels/channel.cpp.hpp:320–376  ·  view source on GitHub ↗

@brief Encode UCS7604 pixel data into the channel data buffer @param data Output byte vector (cleared by caller) @param pixelIterator Pixel iterator with color order and RGBW conversion @param encoder ClocklessEncoder value identifying the UCS7604 mode @param settings Channel settings (for gamma override) @param rgbOrder RGB ordering for current control reordering

Source from the content-addressed store, hash-verified

318/// @param settings Channel settings (for gamma override)
319/// @param rgbOrder RGB ordering for current control reordering
320void writeUCS7604(fl::vector_psram<u8>* data, PixelIterator& pixelIterator,
321 ClocklessEncoder encoder, const ChannelOptions& settings,
322 EOrder rgbOrder) {
323 // Map encoder enum to UCS7604Mode
324 UCS7604Mode mode;
325 switch (encoder) {
326 case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_8BIT:
327 mode = UCS7604Mode::UCS7604_MODE_8BIT_800KHZ;
328 break;
329 case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT:
330 mode = UCS7604Mode::UCS7604_MODE_16BIT_800KHZ;
331 break;
332 case ClocklessEncoder::CLOCKLESS_ENCODER_UCS7604_16BIT_1600:
333 mode = UCS7604Mode::UCS7604_MODE_16BIT_1600KHZ;
334 break;
335 default:
336 // Should never happen — caller already checked
337 mode = UCS7604Mode::UCS7604_MODE_16BIT_800KHZ;
338 break;
339 }
340
341 // Get current control from global UCS7604 brightness
342 UCS7604CurrentControl current = ucs7604::brightness();
343
344 // Reorder current control values to match wire order (same logic as UCS7604ControllerT)
345 u8 rgb_currents[3] = {current.r, current.g, current.b};
346 u8 pos0 = (static_cast<int>(rgbOrder) >> 6) & 0x3;
347 u8 pos1 = (static_cast<int>(rgbOrder) >> 3) & 0x3;
348 u8 pos2 = (static_cast<int>(rgbOrder) >> 0) & 0x3;
349 UCS7604CurrentControl wire_current(
350 rgb_currents[pos0], rgb_currents[pos1], rgb_currents[pos2], current.w);
351
352 // Get gamma LUT
353 float gamma = settings.mGamma.value_or(2.8f);
354 fl::shared_ptr<const Gamma8> gamma8 = Gamma8::getOrCreate(gamma);
355
356 bool is_rgbw = pixelIterator.get_rgbw().active();
357 size_t num_leds = pixelIterator.size();
358
359 // (#2558) UCS7604 is a 4-channel chipset (always RGBW). If the user
360 // configured this channel for 5-channel RGBWW (warm-W + cool-W), the
361 // chipset can't carry the second W byte. Warn loudly — silently dropping
362 // the white channels would be very hard to diagnose. The pixel iterator
363 // continues to emit RGB-only bytes (is_rgbw=false) so the strip still
364 // lights up, just without the W diode.
365 if (pixelIterator.get_rgbww().active() && !is_rgbw) {
366 FL_WARN_ONCE("UCS7604 cannot carry 5-channel RGBWW — this chipset "
367 "always emits 4-channel RGBW. The warm/cool white "
368 "channels in your Rgbww config will be dropped. "
369 "Set ChannelOptions.mWhiteCfg = Rgbw{...} instead to "
370 "silence this warning.");
371 }
372
373 // Encode into the data buffer
374 encodeUCS7604(pixelIterator, num_leds, fl::back_inserter(*data),
375 mode, wire_current, is_rgbw, gamma8.get());
376}
377

Callers 1

showPixelsMethod · 0.85

Calls 8

brightnessFunction · 0.85
encodeUCS7604Function · 0.85
back_inserterFunction · 0.85
value_orMethod · 0.80
get_rgbwMethod · 0.80
get_rgbwwMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected