FastLED 3.9.15
Loading...
Searching...
No Matches

◆ encodeP9813()

template<typename InputIterator, typename OutputIterator>
void fl::encodeP9813 ( InputIterator first,
InputIterator last,
OutputIterator out )

Encode pixel data in P9813 format.

Template Parameters
InputIteratorIterator yielding fl::array<u8, 3> (3 bytes in wire order)
OutputIteratorOutput iterator accepting uint8_t
Parameters
firstIterator to first pixel
lastIterator past last pixel
outOutput iterator for encoded bytes
Note
P9813 uses BGR wire order: pixel[0]=Blue, pixel[1]=Green, pixel[2]=Red

Definition at line 33 of file p9813.h.

33 {
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}
A fixed-size array implementation similar to std::array.
Definition array.h:27
unsigned char u8
Definition stdint.h:131
u8 p9813FlagByte(u8 r, u8 g, u8 b) FL_NOEXCEPT
Generate P9813 flag byte from RGB components.

References FL_NOEXCEPT, and p9813FlagByte().

Referenced by fl::PixelIterator::writeP9813().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: