FastLED 3.9.15
Loading...
Searching...
No Matches
lpd8806.h
Go to the documentation of this file.
1#pragma once
2
16
17#include "fl/stl/stdint.h"
18#include "fl/stl/array.h"
21#include "fl/stl/noexcept.h"
22
23namespace fl {
24
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
A fixed-size array implementation similar to std::array.
Definition array.h:27
Constants for SPI chipset encoders.
Shared utilities for SPI chipset encoders.
void encodeLPD8806(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in LPD8806 format.
Definition lpd8806.h:33
u8 lpd8806Encode(u8 value) FL_NOEXCEPT
Apply LPD8806 encoding to a single color byte.
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT