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

◆ transpose16()

bool fl::SPITransposer::transpose16 ( const fl::optional< LaneData > lanes[16],
fl::span< u8 > output,
const char ** error = nullptr )
static

Transpose 16 lanes of data into interleaved hex-SPI format.

Parameters
lanesArray of 16 lane data (use fl::nullopt for unused lanes)
outputOutput buffer to write interleaved data (size must be divisible by 16)
errorOptional pointer to receive error message (set to nullptr if unused)
Returns
true on success, false if output buffer size is invalid
Note
Output buffer size determines max lane size: max_size = output.size() / 16
Shorter lanes are padded at the beginning with repeating padding_frame pattern
Empty lanes (nullopt) are filled with zeros or first lane's padding
Examples
/home/runner/work/FastLED/FastLED/src/fl/math/transposition.h.

Definition at line 241 of file transposition.cpp.hpp.

243 {
244 // Validate output buffer size (must be divisible by 16)
245 if (output.size() % 16 != 0) {
246 if (error) {
247 *error = "Output buffer size must be divisible by 16";
248 }
249 return false;
250 }
251
252 // Calculate max lane size from output buffer
253 const size_t max_size = output.size() / 16;
254
255 // Handle empty case
256 if (max_size == 0) {
257 if (error) {
258 *error = nullptr; // No error, just empty
259 }
260 return true;
261 }
262
263 // Determine default padding byte from first available lane
264 u8 default_padding = 0x00;
265 for (size_t i = 0; i < 16; i++) {
266 if (lanes[i].has_value() && !lanes[i]->padding_frame.empty()) {
267 default_padding = lanes[i]->padding_frame[0];
268 break;
269 }
270 }
271
272 // Gather all bytes from each lane into temporary buffers
273 fl::vector<u8> lane_buffers[16];
274 const u8* lane_ptrs[16];
275
276 for (size_t lane = 0; lane < 16; lane++) {
277 lane_buffers[lane].resize(max_size);
278 lane_ptrs[lane] = lane_buffers[lane].data();
279
280 for (size_t byte_idx = 0; byte_idx < max_size; byte_idx++) {
281 lane_buffers[lane][byte_idx] = lanes[lane].has_value() ?
282 getLaneByte(*lanes[lane], byte_idx, max_size) : default_padding;
283 }
284 }
285
286 // Perform transposition using ISR-safe primitive
287 transpose_16lane_inline(lane_ptrs, output.data(), max_size);
288
289 if (error) {
290 *error = nullptr; // Success, no error
291 }
292 return true;
293}
bool has_value() const FL_NO_EXCEPT
Definition optional.h:42
static u8 getLaneByte(const LaneData &lane, size_t byte_idx, size_t max_size) FL_NO_EXCEPT
Get byte from lane at given index, handling padding automatically.
const T * data() const FL_NO_EXCEPT
Definition span.h:486
constexpr fl::size size() const FL_NO_EXCEPT
Definition span.h:483
void resize(fl::size n) FL_NO_EXCEPT
Definition vector.h:593
T * data() FL_NO_EXCEPT
Definition vector.h:619
unsigned char u8
Definition stdint.h:131
void transpose_16lane_inline(const u8 *const lanes[16], u8 *output, size_t num_bytes) FL_NO_EXCEPT
Low-level bit-interleaving primitive for 16 lanes (ISR-safe)

References fl::vector< T >::data(), fl::FL_NO_EXCEPT, getLaneByte(), fl::vector< T >::resize(), and fl::transpose_16lane_inline().

+ Here is the call graph for this function: