diff options
author | Daniel Garcia <danielgarcia@gmail.com> | 2016-05-22 15:38:55 +0300 |
---|---|---|
committer | Daniel Garcia <danielgarcia@gmail.com> | 2016-05-22 15:38:55 +0300 |
commit | 20e5042e9f868c0c56ce08571e0cc3344af9e8f4 (patch) | |
tree | 2408a62671190f3243e5ab04e1b51043ed9150f8 | |
parent | a448d5c3dbbb2183e9782d5b8ad130c35072f900 (diff) |
Tweak 4-way parallel output to work on pins 12-15 on esp8266 - keep blocked out for now, needs some more testing.
-rw-r--r-- | bitswap.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bitswap.cpp b/bitswap.cpp new file mode 100644 index 00000000..67530c72 --- /dev/null +++ b/bitswap.cpp @@ -0,0 +1,28 @@ +#define FASTLED_INTERNAL +#include "FastLED.h" + +/// Simplified form of bits rotating function. Based on code found here - http://www.hackersdelight.org/hdcodetxt/transpose8.c.txt - rotating +/// data into LSB for a faster write (the code using this data can happily walk the array backwards) +void transpose8x1_noinline(unsigned char *A, unsigned char *B) { + uint32_t x, y, t; + + // Load the array and pack it into x and y. + y = *(unsigned int*)(A); + x = *(unsigned int*)(A+4); + + // pre-transform x + t = (x ^ (x >> 7)) & 0x00AA00AA; x = x ^ t ^ (t << 7); + t = (x ^ (x >>14)) & 0x0000CCCC; x = x ^ t ^ (t <<14); + + // pre-transform y + t = (y ^ (y >> 7)) & 0x00AA00AA; y = y ^ t ^ (t << 7); + t = (y ^ (y >>14)) & 0x0000CCCC; y = y ^ t ^ (t <<14); + + // final transform + t = (x & 0xF0F0F0F0) | ((y >> 4) & 0x0F0F0F0F); + y = ((x << 4) & 0xF0F0F0F0) | (y & 0x0F0F0F0F); + x = t; + + *((uint32_t*)B) = y; + *((uint32_t*)(B+4)) = x; +} |