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

◆ transpose8x1()

FASTLED_FORCE_INLINE void transpose8x1 ( unsigned char * A,
unsigned char * B )

Simplified form of bits rotating function.

This rotates data into LSB for a faster write (the code using this data can happily walk the array backwards).
Based on code found here: https://web.archive.org/web/20190108225554/http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt

Definition at line 193 of file bitswap.h.

193 {
194 uint32_t x, y, t;
195
196 // Load the array and pack it into x and y.
197 y = *(unsigned int*)(A);
198 x = *(unsigned int*)(A+4);
199
200 // pre-transform x
201 t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7);
202 t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14);
203
204 // pre-transform y
205 t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7);
206 t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14);
207
208 // final transform
209 t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F);
210 y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F);
211 x = t;
212
213 *((uint32_t*)B) = y;
214 *((uint32_t*)(B+4)) = x;
215}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:82
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:83

References FASTLED_FORCE_INLINE, x, and y.