From 212708d88f15ed027c08510392d9768f0d6e45cf Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 28 Sep 2024 21:35:28 +0200 Subject: [PATCH] Caculare from preamble start instead --- DCCWaveform.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 1217769..d61de9d 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -163,9 +163,12 @@ void DCCWaveform::interrupt2() { if (remainingPreambles==1) promotePendingPacket(); else if (isMainTrack && railcomActive) { // cutout has ended so its now possible to poll the railcom detectors - if (remainingPreambles==5) railcomSampleWindow=true; + // requiredPreambles is one higher that preamble length so + // if preamble length is 16 then this evaluates to 5 + if (remainingPreambles==(requiredPreambles-12)) railcomSampleWindow=true; // cutout can be ended when read - else if (remainingPreambles==14) DCCTimer::ackRailcomTimer(); + // see above for requiredPreambles + else if (remainingPreambles==(requiredPreambles-3)) DCCTimer::ackRailcomTimer(); } // Update free memory diagnostic as we don't have anything else to do this time. // Allow for checkAck and its called functions using 22 bytes more.