mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 12:51:24 +01:00
clear progTrackSyncMain (join flag) when prog track is removed 2nd fix
This commit is contained in:
parent
84bc098157
commit
cafd53a0e5
@ -72,15 +72,19 @@ void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_C
|
||||
// then unjoin if necessary. This requires that the joined flag is
|
||||
// cleared when the prog track is removed.
|
||||
ackManagerRejoin=TrackManager::isJoined();
|
||||
//DIAG(F("Joined is %d"), ackManagerRejoin);
|
||||
if (ackManagerRejoin) {
|
||||
// Change from JOIN must zero resets packet.
|
||||
TrackManager::setJoin(false);
|
||||
DCCWaveform::progTrack.clearResets();
|
||||
}
|
||||
|
||||
progDriver=TrackManager::getProgDriver();
|
||||
//DIAG(F("Progdriver is %d"), progDriver);
|
||||
if (progDriver==NULL) {
|
||||
TrackManager::setJoin(ackManagerRejoin);
|
||||
if (ackManagerRejoin) {
|
||||
DIAG(F("Joined but no Prog track"));
|
||||
TrackManager::setJoin(false);
|
||||
}
|
||||
callback(-3); // we dont have a prog track!
|
||||
return;
|
||||
}
|
||||
|
@ -356,17 +356,24 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
||||
applyDCSpeed(trackToSet);
|
||||
}
|
||||
|
||||
// Turn off power if we changed the mode of this track
|
||||
if (mode != oldmode)
|
||||
track[trackToSet]->setPower(POWERMODE::OFF);
|
||||
streamTrackState(NULL,trackToSet);
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#ifndef DISABLE_PROG
|
||||
// If no prog track exists, the join flag should not say that
|
||||
// the prog track is joined either, so clear flag here
|
||||
if (getProgDriver() == NULL) progTrackSyncMain=false;
|
||||
if (tempProgTrack == trackToSet && oldmode & TRACK_MODE_MAIN && !(mode & TRACK_MODE_PROG)) {
|
||||
// If we just take away the prog track, the join should not
|
||||
// be active either. So do in effect an unjoin
|
||||
DIAG(F("Unsync"));
|
||||
tempProgTrack = MAX_TRACKS+1;
|
||||
progTrackSyncMain=false;
|
||||
if (joinRelay!=UNUSED_PIN) digitalWrite(joinRelay,LOW);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
// Turn off power if we changed the mode of this track
|
||||
if (mode != oldmode) {
|
||||
track[trackToSet]->setPower(POWERMODE::OFF);
|
||||
}
|
||||
|
||||
streamTrackState(NULL,trackToSet);
|
||||
//DIAG(F("TrackMode=%d"),mode);
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user