FastLED 3.10.8
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 575 of file channel.cpp.hpp.

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