From b2b6886b527898984b736f383b5b6fe6257b1290 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Sat, 6 Jun 2020 11:11:03 +0100 Subject: [PATCH] Reset counter prearation --- DCCWaveform.cpp | 4 ++++ DCCWaveform.h | 1 + 2 files changed, 5 insertions(+) diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index 7068036..cdaa966 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -6,6 +6,8 @@ DCCWaveform DCCWaveform::mainTrack(PREAMBLE_BITS_MAIN, true); DCCWaveform DCCWaveform::progTrack(PREAMBLE_BITS_PROG, false); + + void DCCWaveform::begin() { Hardware::init(); Hardware::setCallback(58, interruptHandler); @@ -170,12 +172,14 @@ void DCCWaveform::interrupt2() { transmitLength = pendingLength; transmitRepeats = pendingRepeats; packetPending = false; + sentResetsSincePacket=0; } else { // Fortunately reset and idle packets are the same length memcpy( transmitPacket, isMainTrack ? idlePacket : resetPacket, sizeof(idlePacket)); transmitLength = sizeof(idlePacket); transmitRepeats = 0; + sentResetsSincePacket++; } } } diff --git a/DCCWaveform.h b/DCCWaveform.h index 5b9234d..b66aff9 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -48,6 +48,7 @@ class DCCWaveform { void schedulePacket(const byte buffer[], byte byteCount, byte repeats); bool schedulePacketWithAck(const byte buffer[], byte byteCount, byte repeats); volatile bool packetPending; + volatile byte sentResetsSincePacket; private: