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

◆ encodeLPD6803()

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

Encode pixel data in LPD6803 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
LPD6803 uses RGB wire order: pixel[0]=Red, pixel[1]=Green, pixel[2]=Blue

Definition at line 35 of file lpd6803.h.

35 {
36 // Start boundary: 4 bytes of 0x00
37 *out++ = 0x00;
38 *out++ = 0x00;
39 *out++ = 0x00;
40 *out++ = 0x00;
41
42 // LED data: 16-bit format (1bbbbbgggggrrrrr, count as we go)
43 size_t num_leds = 0;
44 while (first != last) {
45 const fl::array<u8, BYTES_PER_PIXEL_RGB>& pixel = *first;
46
47 // RGB order: 0=R, 1=G, 2=B
48 u16 command = lpd6803EncodeRGB(pixel[0], pixel[1], pixel[2]);
49
50 *out++ = static_cast<u8>(command >> 8); // MSB
51 *out++ = static_cast<u8>(command & 0xFF); // LSB
52
53 ++first;
54 ++num_leds;
55 }
56
57 // End boundary: (num_leds / 32) DWords of 0xFF000000
58 size_t end_dwords = (num_leds / 32);
59 for (size_t i = 0; i < end_dwords; i++) {
60 *out++ = 0xFF;
61 *out++ = 0x00;
62 *out++ = 0x00;
63 *out++ = 0x00;
64 }
65}
A fixed-size array implementation similar to std::array.
Definition array.h:27
unsigned char u8
Definition stdint.h:131
u16 lpd6803EncodeRGB(u8 r, u8 g, u8 b) FL_NOEXCEPT
Convert RGB to LPD6803 16-bit format (1bbbbbgggggrrrrr)

References FL_NOEXCEPT, and lpd6803EncodeRGB().

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

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