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

◆ transpose8()

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

Transpose 8 lanes of data into interleaved octal-SPI format.

Parameters
lanesArray of 8 lane data (use fl::nullopt for unused lanes)
outputOutput buffer to write interleaved data (size must be divisible by 8)
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() / 8
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 181 of file transposition.cpp.hpp.

183 {
184 // Validate output buffer size (must be divisible by 8)
185 if (output.size() % 8 != 0) {
186 if (error) {
187 *error = "Output buffer size must be divisible by 8";
188 }
189 return false;
190 }
191
192 // Calculate max lane size from output buffer
193 const size_t max_size = output.size() / 8;
194
195 // Handle empty case
196 if (max_size == 0) {
197 if (error) {
198 *error = nullptr; // No error, just empty
199 }
200 return true;
201 }
202
203 // Determine default padding byte from first available lane
204 u8 default_padding = 0x00;
205 for (size_t i = 0; i < 8; i++) {
206 if (lanes[i].has_value() && !lanes[i]->padding_frame.empty()) {
207 default_padding = lanes[i]->padding_frame[0];
208 break;
209 }
210 }
211
212 // Gather all bytes from each lane into temporary buffers
213 fl::vector<u8> lane_buffers[8];
214 const u8* lane_ptrs[8];
215
216 for (size_t lane = 0; lane < 8; lane++) {
217 lane_buffers[lane].resize(max_size);
218 lane_ptrs[lane] = lane_buffers[lane].data();
219
220 for (size_t byte_idx = 0; byte_idx < max_size; byte_idx++) {
221 lane_buffers[lane][byte_idx] = lanes[lane].has_value() ?
222 getLaneByte(*lanes[lane], byte_idx, max_size) : default_padding;
223 }
224 }
225
226 // Perform transposition using ISR-safe primitive
227 transpose_8lane_inline(lane_ptrs, output.data(), max_size);
228
229 if (error) {
230 *error = nullptr; // Success, no error
231 }
232 return true;
233}
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_8lane_inline(const u8 *const lanes[8], u8 *output, size_t num_bytes) FL_NO_EXCEPT
Low-level bit-interleaving primitive for 8 lanes (ISR-safe)

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

Referenced by fl::spi::MultiLaneDevice::flush().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: