FastLED 3.9.15
Loading...
Searching...
No Matches
p9813.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 encodeP9813(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT {
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}
61
62} // 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
u8 p9813FlagByte(u8 r, u8 g, u8 b) FL_NOEXCEPT
Generate P9813 flag byte from RGB components.
void encodeP9813(InputIterator first, InputIterator last, OutputIterator out) FL_NOEXCEPT
Encode pixel data in P9813 format.
Definition p9813.h:33
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT