MCPcopy Create free account
hub / github.com/FastLED/FastLED / FL_TEST_FILE

Function FL_TEST_FILE

tests/fl/channels/data.cpp:19–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17#include "fl/stl/move.h"
18
19FL_TEST_FILE(FL_FILEPATH) {
20
21using namespace fl;
22
23namespace {
24
25/// @brief Helper to build a UCS7604-style preamble (15 bytes)
26void buildUCS7604Preamble(fl::vector_psram<uint8_t>& buffer) {
27 buffer.push_back(0xFF); // Sync pattern
28 buffer.push_back(0xFF);
29 buffer.push_back(0xFF);
30 buffer.push_back(0xFF);
31 buffer.push_back(0xFF);
32 buffer.push_back(0xFF);
33 buffer.push_back(0x00); // Header
34 buffer.push_back(0x02);
35 buffer.push_back(0x03); // Mode: 8-bit @ 800kHz
36 buffer.push_back(0x0F); // R current
37 buffer.push_back(0x0F); // G current
38 buffer.push_back(0x0F); // B current
39 buffer.push_back(0x0F); // W current
40 buffer.push_back(0x00); // Reserved
41 buffer.push_back(0x00);
42}
43
44/// @brief UCS7604-style padding generator
45///
46/// Writes source data to destination with padding inserted after the 15-byte preamble.
47/// Layout: [PREAMBLE (15 bytes)][PADDING (zeros)][LED DATA]
48void ucs7604PaddingGenerator(fl::span<const uint8_t> src, fl::span<uint8_t> dst) {
49 constexpr size_t PREAMBLE_LEN = 15;
50
51 size_t srcSize = src.size();
52 size_t dstSize = dst.size();
53
54 if (dstSize < srcSize) {
55 return; // Invalid: destination too small
56 }
57
58 size_t paddingSize = dstSize - srcSize;
59
60 // Copy preamble (first 15 bytes)
61 size_t preambleBytes = (srcSize < PREAMBLE_LEN) ? srcSize : PREAMBLE_LEN;
62 fl::memcopy(dst.data(), src.data(), preambleBytes);
63
64 // Insert padding zeros after preamble
65 if (paddingSize > 0 && srcSize >= PREAMBLE_LEN) {
66 fl::fill(dst.begin() + PREAMBLE_LEN, dst.begin() + PREAMBLE_LEN + paddingSize, uint8_t(0));
67 }
68
69 // Copy LED data after padding
70 if (srcSize > PREAMBLE_LEN) {
71 size_t ledDataSize = srcSize - PREAMBLE_LEN;
72 fl::memcopy(dst.data() + PREAMBLE_LEN + paddingSize, src.data() + PREAMBLE_LEN, ledDataSize);
73 }
74}
75
76} // anonymous namespace

Callers

nothing calls this directly

Calls 14

ChipsetTimingConfigClass · 0.85
createFunction · 0.85
memcopyFunction · 0.85
fillFunction · 0.85
getDataMethod · 0.80
writeWithPaddingMethod · 0.80
setPaddingGeneratorMethod · 0.80
buildUCS7604PreambleFunction · 0.70
clearMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected