1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

set the reset packet counter of the prog track to 0 every time the track is turned on

This commit is contained in:
Harald Barth 2022-04-30 23:24:51 +02:00
parent 43bac3f78e
commit 7a2fd90bfc
4 changed files with 9 additions and 0 deletions

View File

@ -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 ) {

View File

@ -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;

View File

@ -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);

View File

@ -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;