MCPcopy Create free account
hub / github.com/FastLED/FastLED / buildDefaultLUT

Function buildDefaultLUT

src/fl/channels/spi/parallel_device.cpp.hpp:99–128  ·  view source on GitHub ↗

@brief Build default LUT for parallel GPIO mapping @param gpio_pins Vector of GPIO pin numbers @param set_masks Output array of 256 set masks @param clear_masks Output array of 256 clear masks

Source from the content-addressed store, hash-verified

97/// @param set_masks Output array of 256 set masks
98/// @param clear_masks Output array of 256 clear masks
99void buildDefaultLUT(const fl::vector<u8>& gpio_pins,
100 u32* set_masks,
101 u32* clear_masks) {
102 size_t num_pins = gpio_pins.size();
103
104 // For each possible byte value (0-255)
105 for (int byte_val = 0; byte_val < 256; byte_val++) {
106 u32 set_mask = 0;
107 u32 clear_mask = 0;
108
109 // Map byte bits to GPIO pins
110 for (size_t bit_pos = 0; bit_pos < num_pins && bit_pos < 8; bit_pos++) {
111 u32 pin_mask = 1u << gpio_pins[bit_pos];
112
113 if (byte_val & (1 << bit_pos)) {
114 set_mask |= pin_mask; // Set this pin high
115 } else {
116 clear_mask |= pin_mask; // Clear this pin low
117 }
118 }
119
120 // For pins beyond bit 7, always clear them (if num_pins > 8)
121 for (size_t pin_idx = 8; pin_idx < num_pins; pin_idx++) {
122 clear_mask |= (1u << gpio_pins[pin_idx]);
123 }
124
125 set_masks[byte_val] = set_mask;
126 clear_masks[byte_val] = clear_mask;
127 }
128}
129
130} // anonymous namespace
131

Callers 1

beginMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected