FastLED 3.10.10
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 595 of file channel.cpp.hpp.

597 {
598 // Map encoder enum to UCS7604Mode
599 UCS7604Mode mode;
600 switch (encoder) {
603 break;
606 break;
609 break;
610 default:
611 // Should never happen — caller already checked
613 break;
614 }
615
616 // Get current control from global UCS7604 brightness
618
619 // Reorder current control values to match wire order (same logic as UCS7604ControllerT)
620 u8 rgb_currents[3] = {current.r, current.g, current.b};
621 u8 pos0 = (static_cast<int>(rgbOrder) >> 6) & 0x3;
622 u8 pos1 = (static_cast<int>(rgbOrder) >> 3) & 0x3;
623 u8 pos2 = (static_cast<int>(rgbOrder) >> 0) & 0x3;
624 UCS7604CurrentControl wire_current(
625 rgb_currents[pos0], rgb_currents[pos1], rgb_currents[pos2], current.w);
626
627 // Get gamma LUT.
628 //
629 // Only the unbound path uses it. With a profile bound the pixel source
630 // has already produced the device drive and quantized it once, to 16
631 // bits, so widening it again through a curve is the second shaping stage
632 // B1 and section 6 forbid after the device solve -- and the 2.8 here is
633 // `value_or`'s default rather than anything the caller asked for, since
634 // `setColorProfile` clears `mGamma`. #4326.
635 // The iterator's own state, not the options'. `hasColorProfile()` says a
636 // profile is configured; it does not say the managed iterator was built.
637 // A rejected binding leaves the legacy controller in place, and taking
638 // the no-gamma path over its 8-bit pixels would drop a stage that path
639 // still needs.
640 const bool wide_source = managed;
641 float gamma = settings.mGamma.value_or(2.8f);
643
644 bool is_rgbw = pixelIterator.get_rgbw().active();
645 size_t num_leds = pixelIterator.size();
646
647 // (#2558) UCS7604 is a 4-channel chipset (always RGBW). If the user
648 // configured this channel for 5-channel RGBWW (warm-W + cool-W), the
649 // chipset can't carry the second W byte. Warn loudly — silently dropping
650 // the white channels would be very hard to diagnose. The pixel iterator
651 // continues to emit RGB-only bytes (is_rgbw=false) so the strip still
652 // lights up, just without the W diode.
653 if (pixelIterator.get_rgbww().active() && !is_rgbw) {
654 FL_WARN_ONCE("UCS7604 cannot carry 5-channel RGBWW — this chipset "
655 "always emits 4-channel RGBW. The warm/cool white "
656 "channels in your Rgbww config will be dropped. "
657 "Set ChannelOptions.mWhiteCfg = Rgbw{...} instead to "
658 "silence this warning.");
659 }
660
661 // Encode into the data buffer
662 encodeUCS7604(pixelIterator, num_leds, fl::back_inserter(*data),
663 mode, wire_current, is_rgbw, gamma8.get(), wide_source);
664}
static fl::shared_ptr< const Gamma8 > getOrCreate(float gamma) FL_NO_EXCEPT
Definition ease.cpp.hpp:460
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:342
#define FL_WARN_ONCE(...)
Definition log.h:439
CurrentControl brightness() FL_NO_EXCEPT
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:132
@ 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:101
FASTLED_FORCE_INLINE bool active() const FL_NO_EXCEPT
Definition rgbw.h:258
FASTLED_FORCE_INLINE bool active() const FL_NO_EXCEPT
Definition rgbww.h:100
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: