MCPcopy Create free account
hub / github.com/FastLED/FastLED / transpose2

Method transpose2

src/fl/math/transposition.cpp.hpp:43–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43FL_DISABLE_WARNING_POP
44
45// ============================================================================
46// SPI Multi-Lane Transposer Implementation
47// ============================================================================
48
49// ----------------------------------------------------------------------------
50// 2-Way Transpose (Dual-SPI)
51// ----------------------------------------------------------------------------
52
53bool SPITransposer::transpose2(const fl::optional<LaneData>& lane0,
54 const fl::optional<LaneData>& lane1,
55 fl::span<u8> output,
56 const char** error) {
57 // Validate output buffer size (must be divisible by 2)
58 if (output.size() % 2 != 0) {
59 if (error) {
60 *error = "Output buffer size must be divisible by 2";
61 }
62 return false;
63 }
64
65 // Calculate max lane size from output buffer
66 const size_t max_size = output.size() / 2;
67
68 // Handle empty case
69 if (max_size == 0) {
70 if (error) {
71 *error = nullptr; // No error, just empty
72 }
73 return true;
74 }
75
76 // Create array of lane references for easier iteration
77 const fl::optional<LaneData>* lanes[2] = {&lane0, &lane1};
78
79 // Determine default padding byte from first available lane
80 u8 default_padding = 0x00;
81 for (size_t i = 0; i < 2; i++) {
82 if (lanes[i]->has_value() && !(*lanes[i])->padding_frame.empty()) {
83 default_padding = (*lanes[i])->padding_frame[0];
84 break;
85 }
86 }
87
88 // Gather all bytes from each lane into temporary buffers
89 fl::vector<u8> lane0_buffer(max_size);
90 fl::vector<u8> lane1_buffer(max_size);
91
92 for (size_t byte_idx = 0; byte_idx < max_size; byte_idx++) {
93 lane0_buffer[byte_idx] = lanes[0]->has_value() ?
94 getLaneByte(**lanes[0], byte_idx, max_size) : default_padding;
95 lane1_buffer[byte_idx] = lanes[1]->has_value() ?
96 getLaneByte(**lanes[1], byte_idx, max_size) : default_padding;
97 }
98
99 // Perform transposition using ISR-safe primitive
100 transpose_2lane_inline(lane0_buffer.data(), lane1_buffer.data(), output.data(), max_size);

Callers

nothing calls this directly

Calls 5

transpose_2lane_inlineFunction · 0.85
sizeMethod · 0.45
has_valueMethod · 0.45
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected