diff --git a/DCCACK.cpp b/DCCACK.cpp index 83ce359..de66355 100644 --- a/DCCACK.cpp +++ b/DCCACK.cpp @@ -76,7 +76,6 @@ 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 42fef16..0d6423b 100644 --- a/MotorDriver.cpp +++ b/MotorDriver.cpp @@ -23,6 +23,7 @@ */ #include #include "MotorDriver.h" +#include "DCCWaveform.h" #include "DCCTimer.h" #include "DIAG.h" @@ -122,8 +123,8 @@ void MotorDriver::setPower(POWERMODE mode) { bool on=mode==POWERMODE::ON; if (on) { IODevice::write(powerPin,HIGH); - if (resetsCounterP != NULL) - *resetsCounterP = 0; + if (isProgTrack) + DCCWaveform::progTrack.clearResets(); } else IODevice::write(powerPin,LOW); powerMode=mode; diff --git a/MotorDriver.h b/MotorDriver.h index d673044..7e71687 100644 --- a/MotorDriver.h +++ b/MotorDriver.h @@ -136,12 +136,12 @@ class MotorDriver { inline byte getFaultPin() { return faultPin; } - inline void setResetCounterPointer(volatile byte *bp) { // load resetPacketCounter pointer - resetsCounterP = bp; + inline void makeProgTrack(bool on) { // let this output know it's a prog track. + isProgTrack = on; } void checkPowerOverload(bool useProgLimit, byte trackno); private: - volatile byte *resetsCounterP = NULL; // points to the resetPacketCounter if this is a prog track + bool isProgTrack = false; // tells us 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 064dfc8..0aac3f7 100644 --- a/TrackManager.cpp +++ b/TrackManager.cpp @@ -140,14 +140,16 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr } if (mode==TRACK_MODE_PROG) { - // only allow 1 track to be prog - FOR_EACH_TRACK(t) - if (trackMode[t]==TRACK_MODE_PROG && t != trackToSet) { - track[t]->setPower(POWERMODE::OFF); - trackMode[t]=TRACK_MODE_OFF; - } + // only allow 1 track to be prog + FOR_EACH_TRACK(t) + if (trackMode[t]==TRACK_MODE_PROG && t != trackToSet) { + track[t]->setPower(POWERMODE::OFF); + trackMode[t]=TRACK_MODE_OFF; + track[t]->makeProgTrack(false); // revoke prog track special handling + } + track[trackToSet]->makeProgTrack(true); // set for prog track special handling } else { - track[trackToSet]->setResetCounterPointer(NULL); // only the prog track has this pointer set + track[trackToSet]->makeProgTrack(false); // only the prog track knows it's type } trackMode[trackToSet]=mode; trackDCAddr[trackToSet]=dcAddr;