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 191 of file bitswap.h.

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

References FASTLED_FORCE_INLINE, x, and y.