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

Function encodeP9813

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

Source from the content-addressed store, hash-verified

31/// @note P9813 uses BGR wire order: pixel[0]=Blue, pixel[1]=Green, pixel[2]=Red
32template <typename InputIterator, typename OutputIterator>
33void encodeP9813(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT {
34 // Start boundary: 4 bytes of 0x00
35 *out++ = 0x00;
36 *out++ = 0x00;
37 *out++ = 0x00;
38 *out++ = 0x00;
39
40 // LED data: flag + BGR
41 while (first != last) {
42 const fl::array<u8, BYTES_PER_PIXEL_RGB>& pixel = *first;
43
44 // P9813 flag byte: 0xC0 | checksum (BGR order: 0=B, 1=G, 2=R)
45 u8 flag = p9813FlagByte(pixel[2], pixel[1], pixel[0]); // r, g, b
46
47 *out++ = flag;
48 *out++ = pixel[0]; // Index 0 (BGR order: Blue)
49 *out++ = pixel[1]; // Index 1 (BGR order: Green)
50 *out++ = pixel[2]; // Index 2 (BGR order: Red)
51
52 ++first;
53 }
54
55 // End boundary: 4 bytes of 0x00
56 *out++ = 0x00;
57 *out++ = 0x00;
58 *out++ = 0x00;
59 *out++ = 0x00;
60}
61
62} // namespace fl

Callers 2

writeP9813Method · 0.85
p9813.hppFile · 0.85

Calls 1

p9813FlagByteFunction · 0.85

Tested by

no test coverage detected