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

Function FL_TEST_FILE

tests/fl/channels/wave8_spi.cpp:24–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#include "fl/stl/span.h" // for span
23
24FL_TEST_FILE(FL_FILEPATH) {
25
26using namespace fl;
27
28// ============================================================================
29// Helper: Create ChipsetTiming for WS2812 (standard test case)
30// ============================================================================
31ChipsetTiming createWS2812ChipsetTiming() {
32 ChipsetTiming timing;
33 timing.T1 = 800; // bit1 HIGH time: 800nsyhj
34 timing.T2 = 400; // bit1 LOW time: 400ns
35 timing.T3 = 400; // bit0 HIGH time: 400ns
36 return timing;
37}
38
39// Note: convertSpiTimingToChipsetTiming() tests are skipped in stub platform tests
40// because they require ESP32-specific headers. These will be tested in integration
41// tests on real hardware.
42
43// ============================================================================
44// Test: Single-Lane Encoding (No Transposition)
45// ============================================================================
46
47FL_TEST_CASE("wave8EncodeSingleLane_basic") {
48 // Create WS2812 timing and build LUT
49 ChipsetTiming chipsetTiming = createWS2812ChipsetTiming();
50 Wave8BitExpansionLut lut = buildWave8ExpansionLUT(chipsetTiming);
51
52 // Input: Single byte (0xFF = all bits '1')
53 uint8_t input[] = {0xFF};
54 uint8_t output[8]; // 1 byte → 8 bytes (1 Wave8Byte)
55
56 size_t written = wave8EncodeSingleLane(
57 fl::span<const uint8_t>(input, 1),
58 fl::span<uint8_t>(output, 8),
59 lut);
60
61 FL_REQUIRE(written == 8);
62
63 // For 0xFF (all bits '1'), all Wave8Bit symbols should use bit1 waveform
64 // WS2812 bit1: 2/3 HIGH, 1/3 LOW → wave8 with 8 pulses: ~5-6 HIGH pulses
65 // Expected pattern: approximately 0b11111100 to 0b11111110 per Wave8Bit
66 // (exact value depends on rounding in buildWave8ExpansionLUT)
67
68 // Verify all 8 Wave8Bit symbols are non-zero (at least some HIGH pulses)
69 for (int i = 0; i < 8; i++) {
70 FL_REQUIRE(output[i] != 0x00);
71 }
72}
73
74FL_TEST_CASE("wave8EncodeSingleLane_zero_byte") {
75 // Create WS2812 timing and build LUT
76 ChipsetTiming chipsetTiming = createWS2812ChipsetTiming();
77 Wave8BitExpansionLut lut = buildWave8ExpansionLUT(chipsetTiming);
78
79 // Input: Single byte (0x00 = all bits '0')
80 uint8_t input[] = {0x00};
81 uint8_t output[8]; // 1 byte → 8 bytes

Callers

nothing calls this directly

Calls 5

wave8EncodeSingleLaneFunction · 0.85
wave8EncodeDualLaneFunction · 0.85
wave8EncodeQuadLaneFunction · 0.85
wave8CalculateOutputSizeFunction · 0.85

Tested by

no test coverage detected