FastLED 3.9.15
Loading...
Searching...
No Matches
bit_spread_lut.hpp
Go to the documentation of this file.
1
13
14#pragma once
15
17#include "fl/stl/int.h"
18
19namespace fl {
20namespace detail {
21
27constexpr u32 kSpreadNibble[16] = {
28 0x00000000u, 0x01000000u, 0x00010000u, 0x01010000u,
29 0x00000100u, 0x01000100u, 0x00010100u, 0x01010100u,
30 0x00000001u, 0x01000001u, 0x00010001u, 0x01010001u,
31 0x00000101u, 0x01000101u, 0x00010101u, 0x01010101u,
32};
33
35FASTLED_FORCE_INLINE u32 spreadA(u8 v) { return kSpreadNibble[v >> 4]; }
37FASTLED_FORCE_INLINE u32 spreadB(u8 v) { return kSpreadNibble[v & 0x0Fu]; }
38
43void spread_transpose16_symbol(const u8 l[16], u8 out[16]) {
44 const u32 aLo = spreadA(l[0]) | spreadA(l[1]) << 1 | spreadA(l[2]) << 2 | spreadA(l[3]) << 3 |
45 spreadA(l[4]) << 4 | spreadA(l[5]) << 5 | spreadA(l[6]) << 6 | spreadA(l[7]) << 7;
46 const u32 bLo = spreadB(l[0]) | spreadB(l[1]) << 1 | spreadB(l[2]) << 2 | spreadB(l[3]) << 3 |
47 spreadB(l[4]) << 4 | spreadB(l[5]) << 5 | spreadB(l[6]) << 6 | spreadB(l[7]) << 7;
48 const u32 aHi = spreadA(l[8]) | spreadA(l[9]) << 1 | spreadA(l[10]) << 2 | spreadA(l[11]) << 3 |
49 spreadA(l[12]) << 4 | spreadA(l[13]) << 5 | spreadA(l[14]) << 6 | spreadA(l[15]) << 7;
50 const u32 bHi = spreadB(l[8]) | spreadB(l[9]) << 1 | spreadB(l[10]) << 2 | spreadB(l[11]) << 3 |
51 spreadB(l[12]) << 4 | spreadB(l[13]) << 5 | spreadB(l[14]) << 6 | spreadB(l[15]) << 7;
52 out[0] = static_cast<u8>(aLo); out[1] = static_cast<u8>(aHi);
53 out[2] = static_cast<u8>(aLo >> 8); out[3] = static_cast<u8>(aHi >> 8);
54 out[4] = static_cast<u8>(aLo >> 16); out[5] = static_cast<u8>(aHi >> 16);
55 out[6] = static_cast<u8>(aLo >> 24); out[7] = static_cast<u8>(aHi >> 24);
56 out[8] = static_cast<u8>(bLo); out[9] = static_cast<u8>(bHi);
57 out[10] = static_cast<u8>(bLo >> 8); out[11] = static_cast<u8>(bHi >> 8);
58 out[12] = static_cast<u8>(bLo >> 16); out[13] = static_cast<u8>(bHi >> 16);
59 out[14] = static_cast<u8>(bLo >> 24); out[15] = static_cast<u8>(bHi >> 24);
60}
61
65void spread_transpose8_symbol(const u8 l[8], u8 out[8]) {
66 const u32 a = spreadA(l[0]) | spreadA(l[1]) << 1 | spreadA(l[2]) << 2 | spreadA(l[3]) << 3 |
67 spreadA(l[4]) << 4 | spreadA(l[5]) << 5 | spreadA(l[6]) << 6 | spreadA(l[7]) << 7;
68 const u32 b = spreadB(l[0]) | spreadB(l[1]) << 1 | spreadB(l[2]) << 2 | spreadB(l[3]) << 3 |
69 spreadB(l[4]) << 4 | spreadB(l[5]) << 5 | spreadB(l[6]) << 6 | spreadB(l[7]) << 7;
70 out[0] = static_cast<u8>(a); out[1] = static_cast<u8>(a >> 8);
71 out[2] = static_cast<u8>(a >> 16); out[3] = static_cast<u8>(a >> 24);
72 out[4] = static_cast<u8>(b); out[5] = static_cast<u8>(b >> 8);
73 out[6] = static_cast<u8>(b >> 16); out[7] = static_cast<u8>(b >> 24);
74}
75
76} // namespace detail
77} // namespace fl
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void spread_transpose16_symbol(const u8 l[16], u8 out[16])
Transpose one symbol of 16 lanes (16 input bytes) into 16 output bytes: 8 pulses × 2 bytes,...
constexpr u32 kSpreadNibble[16]
kSpreadNibble[n] places the 4 bits of nibble n at bit 0 of 4 separate bytes: byte0 = bit3(n),...
FASTLED_FORCE_INLINE u32 spreadA(u8 v)
Pulses 7,6,5,4 of v (byte j = bit (7-j)). Depends only on the high nibble.
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void spread_transpose8_symbol(const u8 l[8], u8 out[8])
Transpose one symbol of 8 lanes (8 input bytes) into 8 output bytes: 8 pulses × 1 byte (bit L = lane ...
FASTLED_FORCE_INLINE u32 spreadB(u8 v)
Pulses 3,2,1,0 of v (byte j = bit (3-j)). Depends only on the low nibble.
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_traits.h:48
unsigned char u8
Definition stdint.h:131
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_FORCE_INLINE
#define FL_OPTIMIZE_FUNCTION
#define FL_IRAM