diff --git a/DCCACK.cpp b/DCCACK.cpp index de66355..83ce359 100644 --- a/DCCACK.cpp +++ b/DCCACK.cpp @@ -76,6 +76,7 @@ void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_C callback(-2); // our prog track cant measure current return; } + progDriver->setResetCounterPointer(&(DCCWaveform::progTrack.sentResetsSincePacket)); ackManagerRejoin=TrackManager::isJoined(); if (ackManagerRejoin ) { diff --git a/MotorDriver.cpp b/MotorDriver.cpp index 517e2dd..b26161e 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -98,6 +98,8 @@ void MotorDriver::setPower(POWERMODE mode) { bool on=mode==POWERMODE::ON; if (on) { IODevice::write(powerPin,HIGH); + if (resetsCounterP != NULL) + *resetsCounterP = 0; } else IODevice::write(powerPin,LOW); powerMode=mode; diff --git a/MotorDriver.h b/MotorDriver.h index 981b259..d0dd999 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -73,8 +73,12 @@ class MotorDriver { inline byte getFaultPin() { return faultPin; } + inline void setResetCounterPointer(byte *bp) { // load resetPacketCounter pointer + resetsCounterP = bp; + } void checkPowerOverload(bool useProgLimit, byte trackno); private: + byte *resetsCounterP = NULL; // points to the resetPacketCounter if this is a prog track void getFastPin(const FSH* type,int pin, bool input, FASTPIN & result); void getFastPin(const FSH* type,int pin, FASTPIN & result) { getFastPin(type, pin, 0, result); diff --git a/TrackManager.cpp b/TrackManager.cpp index 5618644..58f10f7 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -124,6 +124,8 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr track[t]->setPower(POWERMODE::OFF); trackMode[t]=TRACK_MODE_OFF; } + } else { + track[trackToSet]->setResetCounterPointer(NULL); // only the prog track has this pointer set } trackMode[trackToSet]=mode; trackDCAddr[trackToSet]=dcAddr;