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

◆ encodeLPD8806()

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

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

Definition at line 33 of file lpd8806.h.

33 {
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}
A fixed-size array implementation similar to std::array.
Definition array.h:27
u8 lpd8806Encode(u8 value) FL_NOEXCEPT
Apply LPD8806 encoding to a single color byte.

References FL_NOEXCEPT, and lpd8806Encode().

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

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