FastLED 3.10.8
Loading...
Searching...
No Matches

◆ writeWithPadding()

void fl::ChannelData::writeWithPadding ( fl::span< u8 > dst)

Write encoded data with padding to destination buffer.

This method separates the concern of data preparation from memory format. It writes the encoded data with padding applied to a caller-provided span, allowing the caller to control the destination memory type (DRAM, DMA, etc.)

Parameters
dstDestination buffer to write to (size determines target padding size)

The destination buffer size must be >= current data size. If a padding generator is configured, it will be used to extend the data to fill the entire destination buffer.

Definition at line 70 of file data.cpp.hpp.

70 {
71 size_t targetSize = dst.size();
72 size_t currentSize = mEncodedData.size();
73
74 // Destination must be at least as large as current data
75 if (targetSize < currentSize) {
76 return; // or throw? For now, silently fail
77 }
78
79 // Create source span from encoded data
80 fl::span<const u8> src(mEncodedData.data(), currentSize);
81
83 // Use custom padding generator (writes directly to dst)
84 mPaddingGenerator(src, dst);
85 } else {
86 // Default behavior: left-pad with zeros, then memcopy data
87 // Padding bytes go out first to non-existent pixels
88 size_t paddingSize = targetSize - currentSize;
89 if (paddingSize > 0) {
90 fl::fill(dst.begin(), dst.begin() + paddingSize, u8(0));
91 }
92 fl::memcopy(dst.data() + paddingSize, src.data(), currentSize);
93 }
94}
fl::vector_psram< u8 > mEncodedData
Encoded transmission bytes (PSRAM)
Definition data.h:192
PaddingGenerator mPaddingGenerator
Optional padding generator for block-size alignment.
Definition data.h:191
const T * data() const FL_NO_EXCEPT
Definition span.h:486
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
iterator begin() FL_NO_EXCEPT
Definition span.h:465
void fill(Iterator first, Iterator last, const T &value) FL_NO_EXCEPT
Definition algorithm.h:207
unsigned char u8
Definition stdint.h:131
void * memcopy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
Definition cstring.h:163

References fl::span< T, Extent >::data(), fl::adl_barrier::fill(), fl::FL_NO_EXCEPT, fl::memcopy(), mEncodedData, and mPaddingGenerator.

+ Here is the call graph for this function: