FastLED 3.10.6
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,
bool managed )

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 552 of file channel.cpp.hpp.

554 {
555 // Map encoder enum to UCS7604Mode
556 UCS7604Mode mode;
557 switch (encoder) {
560 break;
563 break;
566 break;
567 default:
568 // Should never happen — caller already checked
570 break;
571 }
572
573 // Get current control from global UCS7604 brightness
575
576 // Reorder current control values to match wire order (same logic as UCS7604ControllerT)
577 u8 rgb_currents[3] = {current.r, current.g, current.b};
578 u8 pos0 = (static_cast<int>(rgbOrder) >> 6) & 0x3;
579 u8 pos1 = (static_cast<int>(rgbOrder) >> 3) & 0x3;
580 u8 pos2 = (static_cast<int>(rgbOrder) >> 0) & 0x3;
581 UCS7604CurrentControl wire_current(
582 rgb_currents[pos0], rgb_currents[pos1], rgb_currents[pos2], current.w);
583
584 // Get gamma LUT.
585 //
586 // Only the unbound path uses it. With a profile bound the pixel source
587 // has already produced the device drive and quantized it once, to 16
588 // bits, so widening it again through a curve is the second shaping stage
589 // B1 and section 6 forbid after the device solve -- and the 2.8 here is
590 // `value_or`'s default rather than anything the caller asked for, since
591 // `setColorProfile` clears `mGamma`. #4326.
592 // The iterator's own state, not the options'. `hasColorProfile()` says a
593 // profile is configured; it does not say the managed iterator was built.
594 // A rejected binding leaves the legacy controller in place, and taking
595 // the no-gamma path over its 8-bit pixels would drop a stage that path
596 // still needs.
597 const bool wide_source = managed;
598 float gamma = settings.mGamma.value_or(2.8f);
600
601 bool is_rgbw = pixelIterator.get_rgbw().active();
602 size_t num_leds = pixelIterator.size();
603
604 // (#2558) UCS7604 is a 4-channel chipset (always RGBW). If the user
605 // configured this channel for 5-channel RGBWW (warm-W + cool-W), the
606 // chipset can't carry the second W byte. Warn loudly — silently dropping
607 // the white channels would be very hard to diagnose. The pixel iterator
608 // continues to emit RGB-only bytes (is_rgbw=false) so the strip still
609 // lights up, just without the W diode.
610 if (pixelIterator.get_rgbww().active() && !is_rgbw) {
611 FL_WARN_ONCE("UCS7604 cannot carry 5-channel RGBWW — this chipset "
612 "always emits 4-channel RGBW. The warm/cool white "
613 "channels in your Rgbww config will be dropped. "
614 "Set ChannelOptions.mWhiteCfg = Rgbw{...} instead to "
615 "silence this warning.");
616 }
617
618 // Encode into the data buffer
619 encodeUCS7604(pixelIterator, num_leds, fl::back_inserter(*data),
620 mode, wire_current, is_rgbw, gamma8.get(), wide_source);
621}
static fl::shared_ptr< const Gamma8 > getOrCreate(float gamma) FL_NO_EXCEPT
Definition ease.cpp.hpp:459
Rgbw get_rgbw() const FL_NO_EXCEPT
int size() FL_NO_EXCEPT
Rgbww get_rgbww() const FL_NO_EXCEPT
T * get() const FL_NO_EXCEPT
Definition shared_ptr.h:334
#define FL_WARN_ONCE(...)
Definition log.h:442
CurrentControl brightness()
Get current global UCS7604 brightness value.
back_insert_iterator< Container > back_inserter(Container &c) FL_NO_EXCEPT
Helper function to create a back_insert_iterator.
Definition iterator.h:139
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.
constexpr u32 gamma(float g) FL_NO_EXCEPT
Definition gamma_lut.h:36
UCS7604Mode
UCS7604 protocol configuration modes.
Definition ucs7604.h:30
@ UCS7604_MODE_8BIT_800KHZ
Definition ucs7604.h:31
@ UCS7604_MODE_16BIT_1600KHZ
Definition ucs7604.h:33
@ UCS7604_MODE_16BIT_800KHZ
Definition ucs7604.h:32
void encodeUCS7604(PixelIterator &pixel_iter, size_t num_leds, OutputIterator out, UCS7604Mode mode, const UCS7604CurrentControl &current, bool is_rgbw, const Gamma8 *gamma=nullptr, bool wide_source=false) FL_NO_EXCEPT
Encode complete UCS7604 frame (preamble + padding + pixel data)
Definition ucs7604.h:273
fl::optional< float > mGamma
Definition options.h:94
FASTLED_FORCE_INLINE bool active() const FL_NO_EXCEPT
Definition rgbw.h:232
FASTLED_FORCE_INLINE bool active() const FL_NO_EXCEPT
Definition rgbww.h:79
u8 g
Green channel current (0x0-0xF)
Definition ucs7604.h:39
u8 b
Blue channel current (0x0-0xF)
Definition ucs7604.h:40
u8 w
White channel current (0x0-0xF)
Definition ucs7604.h:41
u8 r
Red channel current (0x0-0xF)
Definition ucs7604.h:38
UCS7604 current control structure with 4-bit fields for each channel.
Definition ucs7604.h:37

References 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::FL_NO_EXCEPT, FL_WARN_ONCE, fl::UCS7604CurrentControl::g, fl::gamma(), fl::shared_ptr< T >::get(), fl::Gamma8::getOrCreate(), fl::UCS7604CurrentControl::r, 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: