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

Function dumpRawEdgeTiming

examples/AutoResearch/AutoResearchTest.cpp:28–116  ·  view source on GitHub ↗

@brief Dump raw edge timing data to console for debugging @param rx_channel RX device to read edge data from @param timing Chipset timing configuration for pattern analysis @param range Edge range to print (offset, count)

Source from the content-addressed store, hash-verified

26/// @param timing Chipset timing configuration for pattern analysis
27/// @param range Edge range to print (offset, count)
28void dumpRawEdgeTiming(fl::shared_ptr<fl::RxChannel> rx_channel,
29 const fl::ChipsetTimingConfig& timing,
30 fl::EdgeRange range) {
31 if (!rx_channel) {
32 FL_WARN("[RAW EDGE TIMING] ERROR: RX channel is null");
33 return;
34 }
35
36 // Allocate edge buffer sized to requested count (max 256 to avoid stack overflow)
37 fl::FixedVector<fl::EdgeTime, 256> edges;
38 size_t buffer_size = range.count < 256 ? range.count : 256;
39 edges.resize(buffer_size); // Default initializes to EdgeTime()
40
41 // Get edges starting at offset
42 size_t edge_count = rx_channel->getRawEdgeTimes(edges, range.offset);
43
44 if (edge_count == 0) {
45 FL_WARN("[RAW EDGE TIMING] WARNING: No edge data captured at offset " << range.offset);
46 return;
47 }
48
49 // Calculate actual range printed (start from offset)
50 size_t start_idx = range.offset;
51 size_t end_idx = range.offset + edge_count;
52
53 FL_WARN("[RAW EDGES " << start_idx << ".." << (end_idx - 1) << "]");
54
55 // Display edges (edges buffer contains data starting from offset)
56 for (size_t i = 0; i < edge_count; i++) {
57 const char* level = edges[i].high ? "H" : "L";
58 size_t absolute_index = start_idx + i;
59 FL_WARN(" [" << absolute_index << "] " << level << " " << edges[i].ns);
60 }
61
62 // Pattern analysis (only if showing edges from start)
63 if (range.offset == 0 && edge_count >= 16) {
64 // Calculate expected timings from config (3-phase to 4-phase conversion)
65 uint32_t expected_bit0_high = timing.t1_ns;
66 uint32_t expected_bit0_low = timing.t2_ns + timing.t3_ns;
67 uint32_t expected_bit1_high = timing.t1_ns + timing.t2_ns;
68 uint32_t expected_bit1_low = timing.t3_ns;
69
70 const uint32_t tolerance = 150;
71
72 bool has_short_high = false, has_long_high = false;
73 bool has_short_low = false, has_long_low = false;
74
75 for (size_t i = 0; i < edge_count; i++) {
76 uint32_t ns = edges[i].ns;
77 if (edges[i].high) {
78 if (ns >= expected_bit0_high - tolerance && ns <= expected_bit0_high + tolerance)
79 has_short_high = true;
80 if (ns >= expected_bit1_high - tolerance && ns <= expected_bit1_high + tolerance)
81 has_long_high = true;
82 } else {
83 if (ns >= expected_bit1_low - tolerance && ns <= expected_bit1_low + tolerance)
84 has_short_low = true;
85 if (ns >= expected_bit0_low - tolerance && ns <= expected_bit0_low + tolerance)

Callers 2

captureFunction · 0.85
runMultiTestFunction · 0.85

Calls 4

resizeMethod · 0.45
getRawEdgeTimesMethod · 0.45
strMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected