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

Function FL_TEST_FILE

tests/fl/channels/wave8.cpp:12–1373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "fl/chipsets/led_timing.h"
11
12FL_TEST_FILE(FL_FILEPATH) {
13
14using namespace fl;
15
16FL_TEST_CASE("buildWave8ExpansionLUT") {
17 // Create timing where bit0 is at 1/4 time, bit1 is at 3/4 time
18 ChipsetTiming timing;
19 timing.T1 = 250; // bit0 goes LOW at 1/4 of period (250/1000)
20 timing.T2 = 500; // bit1 goes LOW at 3/4 of period ((250+500)/1000)
21 timing.T3 = 250; // period = 1000ns total
22
23 // Build the LUT
24 Wave8BitExpansionLut lut = buildWave8ExpansionLUT(timing);
25
26 // Expected waveforms with 8 pulses per bit:
27 // bit0: 1/4 * 8 = 2 HIGH pulses, 6 LOW pulses
28 // bit1: 3/4 * 8 = 6 HIGH pulses, 2 LOW pulses
29
30 // Test nibble 0xA (1010 binary) - used in pattern 0xAA
31 // 0xA = bit3=1, bit2=0, bit1=1, bit0=0 (MSB first)
32 const uint8_t nibble = 0xA;
33
34 // Check bit 3 (MSB, value=1) -> should use bit1 waveform (6 HIGH, 2 LOW)
35 // Expected: 0b11111100 = 0xFC
36 FL_REQUIRE(lut.lut[nibble][0].data == 0xFC);
37
38 // Check bit 2 (value=0) -> should use bit0 waveform (2 HIGH, 6 LOW)
39 // Expected: 0b11000000 = 0xC0
40 FL_REQUIRE(lut.lut[nibble][1].data == 0xC0);
41
42 // Check bit 1 (value=1) -> should use bit1 waveform (6 HIGH, 2 LOW)
43 // Expected: 0b11111100 = 0xFC
44 FL_REQUIRE(lut.lut[nibble][2].data == 0xFC);
45
46 // Check bit 0 (LSB, value=0) -> should use bit0 waveform (2 HIGH, 6 LOW)
47 // Expected: 0b11000000 = 0xC0
48 FL_REQUIRE(lut.lut[nibble][3].data == 0xC0);
49}
50
51FL_TEST_CASE("convertToWave8Bit") {
52 // Build LUT where bit0 = all LOW, bit1 = all HIGH
53 // This creates simple patterns for testing transpose
54 ChipsetTiming timing;
55 timing.T1 = 1; // bit0: ~0 HIGH pulses (rounds to 0)
56 timing.T2 = 999; // bit1: ~8 HIGH pulses (rounds to 8)
57 timing.T3 = 1; // period = 1001ns
58
59 Wave8BitExpansionLut lut = buildWave8ExpansionLUT(timing);
60
61 // Convert to Wave8Bit
62 // lane0: 0xff (all bits are 1) = high nibble 0xF, low nibble 0xF
63 // lane1: 0x00 (all bits are 0) = high nibble 0x0, low nibble 0x0
64 uint8_t lanes[2] = {0xff, 0x00};
65 uint8_t output[2 * sizeof(Wave8Byte)]; // 16 bytes
66
67 wave8Transpose_2(lanes, lut, output);
68
69 // Test transposed output

Callers

nothing calls this directly

Calls 15

wave8Transpose_2Function · 0.85
wave8_expand_byteFunction · 0.85
memsetFunction · 0.85
wave8Transpose_4Function · 0.85
wave8Untranspose_2Function · 0.85
wave8Untranspose_4Function · 0.85
wave8Transpose_8Function · 0.85
wave8Untranspose_8Function · 0.85
wave8Transpose_16Function · 0.85
wave8Untranspose_16Function · 0.85

Tested by

no test coverage detected