Dump raw edge timing data to console for debugging.
30 {
31 if (!rx_channel) {
32 FL_WARN(
"[RAW EDGE TIMING] ERROR: RX channel is null");
33 return;
34 }
35
36
38 size_t buffer_size = range.
count < 256 ? range.
count : 256;
40
41
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
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
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
63 if (range.
offset == 0 && edge_count >= 16) {
64
69
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++) {
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)
86 has_long_low = true;
87 }
88 }
89
91 ss << "\n[RAW EDGE TIMING] Pattern Analysis:\n";
92 ss << " Short HIGH (~" << expected_bit0_high << "ns, Bit 0): " << (has_short_high ? "FOUND ✓" : "MISSING ✗") << "\n";
93 ss << " Long HIGH (~" << expected_bit1_high << "ns, Bit 1): " << (has_long_high ? "FOUND ✓" : "MISSING ✗") << "\n";
94 ss << " Short LOW (~" << expected_bit1_low << "ns, Bit 1): " << (has_short_low ? "FOUND ✓" : "MISSING ✗") << "\n";
95 ss << " Long LOW (~" << expected_bit0_low << "ns, Bit 0): " << (has_long_low ? "FOUND ✓" : "MISSING ✗");
97
98 if (has_short_high && has_long_high && has_short_low && has_long_low) {
99 FL_WARN(
"\n[RAW EDGE TIMING] ✓ Encoder appears to be working correctly (varied timing patterns)");
100 } else if (!has_short_high && !has_long_high) {
102 ss << "[RAW EDGE TIMING] ✗ ENCODER BROKEN: No valid HIGH pulses detected!\n";
103 ss << "[RAW EDGE TIMING] Possible causes:\n";
104 ss << "[RAW EDGE TIMING] 1. Encoder not reading pixel buffer data\n";
105 ss << "[RAW EDGE TIMING] 2. Bytes encoder state machine stuck\n";
106 ss << "[RAW EDGE TIMING] 3. Data pointer not passed correctly to encoder";
108 } else if (!has_short_low && !has_long_low) {
109
110 FL_WARN(
"[RAW EDGE TIMING] ✗ ENCODER BROKEN: No valid LOW pulses detected!");
111 } else {
112 FL_WARN(
"[RAW EDGE TIMING] ⚠ Partial pattern match - encoder may have issues");
113 }
114 }
116}
void resize(fl::size n) FL_NOEXCEPT
size_t getRawEdgeTimes(fl::span< EdgeTime > out, size_t offset=0) FL_NOEXCEPT
string str() const FL_NOEXCEPT
u32 t1_ns
T0H: High time for bit 0 (nanoseconds)
u32 t2_ns
T1H-T0H: Additional high time for bit 1 (nanoseconds)
u32 t3_ns
T0L: Low tail duration (nanoseconds)
size_t offset
Starting edge index.
size_t count
Number of edges to extract.