FastLED 3.9.15
Loading...
Searching...
No Matches
lpd6803.h
Go to the documentation of this file.
1#pragma once
2
18
19#include "fl/stl/stdint.h"
20#include "fl/stl/array.h"
23#include "fl/stl/noexcept.h"
24
25namespace fl {
26
34template <typename InputIterator, typename OutputIterator>
35void encodeLPD6803(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT {
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}
66
67} // 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.
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)
void encodeLPD6803(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in LPD6803 format.
Definition lpd6803.h:35
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT