FastLED 3.9.15
Loading...
Searching...
No Matches

◆ writeUCS7604()

void fl::anonymous_namespace{channel.cpp.hpp}::writeUCS7604 ( fl::vector_psram< u8 > * data,
PixelIterator & pixelIterator,
ClocklessEncoder encoder,
const ChannelOptions & settings,
EOrder rgbOrder )

Encode UCS7604 pixel data into the channel data buffer.

Parameters
dataOutput byte vector (cleared by caller)
pixelIteratorPixel iterator with color order and RGBW conversion
encoderClocklessEncoder value identifying the UCS7604 mode
settingsChannel settings (for gamma override)
rgbOrderRGB ordering for current control reordering

Definition at line 320 of file channel.cpp.hpp.

322 {
323 // Map encoder enum to UCS7604Mode
324 UCS7604Mode mode;
325 switch (encoder) {
328 break;
331 break;
334 break;
335 default:
336 // Should never happen — caller already checked
338 break;
339 }
340
341 // Get current control from global 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);
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}
static fl::shared_ptr< const Gamma8 > getOrCreate(float gamma) FL_NOEXCEPT
Definition ease.cpp.hpp:459
int size() FL_NOEXCEPT
Rgbw get_rgbw() const FL_NOEXCEPT
Rgbww get_rgbww() const FL_NOEXCEPT
T * get() const FL_NOEXCEPT
Definition shared_ptr.h:334
#define FL_WARN_ONCE(X)
Definition log.h:278
CurrentControl brightness()
Get current global UCS7604 brightness value.
unsigned char u8
Definition stdint.h:131
@ CLOCKLESS_ENCODER_UCS7604_8BIT
UCS7604 8-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT
UCS7604 16-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT_1600
UCS7604 16-bit 1600KHz.
back_insert_iterator< Container > back_inserter(Container &c) FL_NOEXCEPT
Helper function to create a back_insert_iterator.
Definition iterator.h:139
UCS7604Mode
UCS7604 protocol configuration modes.
Definition ucs7604.h:28
@ UCS7604_MODE_8BIT_800KHZ
Definition ucs7604.h:29
@ UCS7604_MODE_16BIT_1600KHZ
Definition ucs7604.h:31
@ UCS7604_MODE_16BIT_800KHZ
Definition ucs7604.h:30
constexpr u32 gamma(float g) FL_NOEXCEPT
Definition gamma_lut.h:36
void encodeUCS7604(PixelIterator &pixel_iter, size_t num_leds, OutputIterator out, UCS7604Mode mode, const UCS7604CurrentControl &current, bool is_rgbw, const Gamma8 *gamma=nullptr)
Encode complete UCS7604 frame (preamble + padding + pixel data)
Definition ucs7604.h:209
fl::optional< float > mGamma
Definition options.h:51
FASTLED_FORCE_INLINE bool active() const FL_NOEXCEPT
Definition rgbw.h:182
FASTLED_FORCE_INLINE bool active() const FL_NOEXCEPT
Definition rgbww.h:79
u8 g
Green channel current (0x0-0xF)
Definition ucs7604.h:37
u8 b
Blue channel current (0x0-0xF)
Definition ucs7604.h:38
u8 w
White channel current (0x0-0xF)
Definition ucs7604.h:39
u8 r
Red channel current (0x0-0xF)
Definition ucs7604.h:36
UCS7604 current control structure with 4-bit fields for each channel.
Definition ucs7604.h:35

References fl::Rgbw::active(), fl::Rgbww::active(), fl::UCS7604CurrentControl::b, fl::back_inserter(), fl::ucs7604::brightness(), fl::CLOCKLESS_ENCODER_UCS7604_16BIT, fl::CLOCKLESS_ENCODER_UCS7604_16BIT_1600, fl::CLOCKLESS_ENCODER_UCS7604_8BIT, fl::encodeUCS7604(), FL_WARN_ONCE, fl::UCS7604CurrentControl::g, fl::gamma(), fl::shared_ptr< T >::get(), fl::PixelIterator::get_rgbw(), fl::PixelIterator::get_rgbww(), fl::Gamma8::getOrCreate(), fl::ChannelOptions::mGamma, fl::UCS7604CurrentControl::r, fl::PixelIterator::size(), fl::UCS7604_MODE_16BIT_1600KHZ, fl::UCS7604_MODE_16BIT_800KHZ, fl::UCS7604_MODE_8BIT_800KHZ, fl::UCS7604CurrentControl::w, and writeUCS7604().

Referenced by writeUCS7604().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: