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

Function encodeLPD8806

src/fl/chipsets/encoders/lpd8806.h:33–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31/// @note LPD8806 uses GRB wire order: pixel[0]=Green, pixel[1]=Red, pixel[2]=Blue
32template <typename InputIterator, typename OutputIterator>
33void encodeLPD8806(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT {
34 // LED data: GRB with MSB set (count as we go)
35 size_t num_leds = 0;
36 while (first != last) {
37 const fl::array<u8, BYTES_PER_PIXEL_RGB>& pixel = *first;
38
39 // LPD8806 requires MSB set on each byte, and uses 7-bit color depth
40 // GRB order: 0=G, 1=R, 2=B
41 *out++ = lpd8806Encode(pixel[0]); // Index 0 (GRB order: Green)
42 *out++ = lpd8806Encode(pixel[1]); // Index 1 (GRB order: Red)
43 *out++ = lpd8806Encode(pixel[2]); // Index 2 (GRB order: Blue)
44
45 ++first;
46 ++num_leds;
47 }
48
49 // Latch: ((num_leds * 3 + 63) / 64) bytes of 0x00
50 size_t latch_bytes = (num_leds * 3 + 63) / 64;
51 for (size_t i = 0; i < latch_bytes; i++) {
52 *out++ = 0x00;
53 }
54}
55
56} // namespace fl

Callers 2

writeLPD8806Method · 0.85
lpd8806.hppFile · 0.85

Calls 1

lpd8806EncodeFunction · 0.85

Tested by

no test coverage detected