FastLED 3.9.15
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 62 of file data.cpp.hpp.

62 {
63 size_t targetSize = dst.size();
64 size_t currentSize = mEncodedData.size();
65
66 // Destination must be at least as large as current data
67 if (targetSize < currentSize) {
68 return; // or throw? For now, silently fail
69 }
70
71 // Create source span from encoded data
72 fl::span<const u8> src(mEncodedData.data(), currentSize);
73
75 // Use custom padding generator (writes directly to dst)
76 mPaddingGenerator(src, dst);
77 } else {
78 // Default behavior: left-pad with zeros, then memcopy data
79 // Padding bytes go out first to non-existent pixels
80 size_t paddingSize = targetSize - currentSize;
81 if (paddingSize > 0) {
82 fl::fill(dst.begin(), dst.begin() + paddingSize, u8(0));
83 }
84 fl::memcopy(dst.data() + paddingSize, src.data(), currentSize);
85 }
86}
fl::vector_psram< u8 > mEncodedData
Encoded transmission bytes (PSRAM)
Definition data.h:148
PaddingGenerator mPaddingGenerator
Optional padding generator for block-size alignment.
Definition data.h:147
iterator begin() FL_NOEXCEPT
Definition span.h:440
const T * data() const FL_NOEXCEPT
Definition span.h:461
constexpr fl::size size() const FL_NOEXCEPT
Definition span.h:458
unsigned char u8
Definition stdint.h:131
void * memcopy(void *dest, const void *src, size_t n) FL_NOEXCEPT
Definition cstring.h:103
void fill(Iterator first, Iterator last, const T &value) FL_NOEXCEPT
Definition algorithm.h:204

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

+ Here is the call graph for this function: