FastLED 3.10.8
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#include "fl/stl/noexcept.h"
19
20namespace fl {
21namespace detail {
22
28constexpr u32 kSpreadNibble[16] = {
29 0x00000000u, 0x01000000u, 0x00010000u, 0x01010000u,
30 0x00000100u, 0x01000100u, 0x00010100u, 0x01010100u,
31 0x00000001u, 0x01000001u, 0x00010001u, 0x01010001u,
32 0x00000101u, 0x01000101u, 0x00010101u, 0x01010101u,
33};
34
39
44void spread_transpose16_symbol(const u8 l[16], u8 out[16]) FL_NO_EXCEPT {
45 const u32 aLo = spreadA(l[0]) | spreadA(l[1]) << 1 | spreadA(l[2]) << 2 | spreadA(l[3]) << 3 |
46 spreadA(l[4]) << 4 | spreadA(l[5]) << 5 | spreadA(l[6]) << 6 | spreadA(l[7]) << 7;
47 const u32 bLo = spreadB(l[0]) | spreadB(l[1]) << 1 | spreadB(l[2]) << 2 | spreadB(l[3]) << 3 |
48 spreadB(l[4]) << 4 | spreadB(l[5]) << 5 | spreadB(l[6]) << 6 | spreadB(l[7]) << 7;
49 const u32 aHi = spreadA(l[8]) | spreadA(l[9]) << 1 | spreadA(l[10]) << 2 | spreadA(l[11]) << 3 |
50 spreadA(l[12]) << 4 | spreadA(l[13]) << 5 | spreadA(l[14]) << 6 | spreadA(l[15]) << 7;
51 const u32 bHi = spreadB(l[8]) | spreadB(l[9]) << 1 | spreadB(l[10]) << 2 | spreadB(l[11]) << 3 |
52 spreadB(l[12]) << 4 | spreadB(l[13]) << 5 | spreadB(l[14]) << 6 | spreadB(l[15]) << 7;
53 out[0] = static_cast<u8>(aLo); out[1] = static_cast<u8>(aHi);
54 out[2] = static_cast<u8>(aLo >> 8); out[3] = static_cast<u8>(aHi >> 8);
55 out[4] = static_cast<u8>(aLo >> 16); out[5] = static_cast<u8>(aHi >> 16);
56 out[6] = static_cast<u8>(aLo >> 24); out[7] = static_cast<u8>(aHi >> 24);
57 out[8] = static_cast<u8>(bLo); out[9] = static_cast<u8>(bHi);
58 out[10] = static_cast<u8>(bLo >> 8); out[11] = static_cast<u8>(bHi >> 8);
59 out[12] = static_cast<u8>(bLo >> 16); out[13] = static_cast<u8>(bHi >> 16);
60 out[14] = static_cast<u8>(bLo >> 24); out[15] = static_cast<u8>(bHi >> 24);
61}
62
66void spread_transpose8_symbol(const u8 l[8], u8 out[8]) FL_NO_EXCEPT {
67 const u32 a = spreadA(l[0]) | spreadA(l[1]) << 1 | spreadA(l[2]) << 2 | spreadA(l[3]) << 3 |
68 spreadA(l[4]) << 4 | spreadA(l[5]) << 5 | spreadA(l[6]) << 6 | spreadA(l[7]) << 7;
69 const u32 b = spreadB(l[0]) | spreadB(l[1]) << 1 | spreadB(l[2]) << 2 | spreadB(l[3]) << 3 |
70 spreadB(l[4]) << 4 | spreadB(l[5]) << 5 | spreadB(l[6]) << 6 | spreadB(l[7]) << 7;
71 out[0] = static_cast<u8>(a); out[1] = static_cast<u8>(a >> 8);
72 out[2] = static_cast<u8>(a >> 16); out[3] = static_cast<u8>(a >> 24);
73 out[4] = static_cast<u8>(b); out[5] = static_cast<u8>(b >> 8);
74 out[6] = static_cast<u8>(b >> 16); out[7] = static_cast<u8>(b >> 24);
75}
76
77} // namespace detail
78} // namespace fl
FASTLED_FORCE_INLINE u32 spreadB(u8 v) FL_NO_EXCEPT
Pulses 3,2,1,0 of v (byte j = bit (3-j)). Depends only on the low nibble.
FASTLED_FORCE_INLINE FL_IRAM FL_OPTIMIZE_FUNCTION void spread_transpose16_symbol(const u8 l[16], u8 out[16]) FL_NO_EXCEPT
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 FL_IRAM FL_OPTIMIZE_FUNCTION void spread_transpose8_symbol(const u8 l[8], u8 out[8]) FL_NO_EXCEPT
Transpose one symbol of 8 lanes (8 input bytes) into 8 output bytes: 8 pulses × 1 byte (bit L = lane ...
FASTLED_FORCE_INLINE u32 spreadA(u8 v) FL_NO_EXCEPT
Pulses 7,6,5,4 of v (byte j = bit (7-j)). Depends only on the high nibble.
Compile-time linker keep-alive hook for a single fl::Bus.
Definition bus_info.h:57
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
Base definition for an LED controller.
#define FASTLED_FORCE_INLINE
#define FL_OPTIMIZE_FUNCTION
#define FL_IRAM