FastLED 3.9.15
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 180 of file transposition.cpp.hpp.

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

References fl::vector< T >::data(), fl::Optional< T >::empty(), getLaneByte(), fl::Optional< T >::has_value(), 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: