FastLED 3.9.15
Loading...
Searching...
No Matches

◆ transpose_4strips()

FASTLED_FORCE_INLINE void fl::transpose_4strips ( const u8 *const input[4],
u8 * output,
u16 num_leds,
u8 bytes_per_led )

Transpose 4 LED strips into parallel bit format.

This function transposes 4 LED strips from standard byte-sequential format to bit-parallel format suitable for 4-way PIO output.

Input: 4 strips, each with num_leds * bytes_per_led bytes Output: num_leds * bytes_per_led * 8 bytes

Parameters
inputArray of 4 pointers to LED strip data
outputPointer to output buffer
num_ledsNumber of LEDs per strip (all strips padded to this length)
bytes_per_ledNumber of bytes per LED (3 for RGB, 4 for RGBW, etc.)
Note
All strips must be pre-padded to the same length
Output buffer must be pre-allocated by caller
Upper 4 bits of each output byte are zero
Examples
/home/runner/work/FastLED/FastLED/src/fl/math/transposition.h.

Definition at line 722 of file transposition.h.

727 {
728 // Process each LED
729 for (u16 led = 0; led < num_leds; led++) {
730 // Process each byte in the LED
731 for (u8 byte_idx = 0; byte_idx < bytes_per_led; byte_idx++) {
732 // Collect one byte from each strip for this byte position
733 u8 strip_bytes[4];
734 for (int strip = 0; strip < 4; strip++) {
735 strip_bytes[strip] = input[strip][led * bytes_per_led + byte_idx];
736 }
737
738 // Transpose: extract each bit position from all 4 strips
739 for (int bit = 7; bit >= 0; bit--) {
740 u8 output_byte = 0;
741 // Pack bits from all 4 strips into lower 4 bits
742 for (int strip = 0; strip < 4; strip++) {
743 output_byte |= ((strip_bytes[strip] >> bit) & 1) << strip;
744 }
745 *output++ = output_byte;
746 }
747 }
748 }
749}
unsigned char u8
Definition stdint.h:131
unsigned char u8
Definition stdint.h:131

References FASTLED_FORCE_INLINE, and FL_NOEXCEPT.

Referenced by transpose_strips().

+ Here is the caller graph for this function: