1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

clear progTrackSyncMain (join flag) when prog track is removed

This commit is contained in:
Harald Barth 2024-12-21 15:42:15 +01:00
parent 4f16091670
commit 8329fd83ce
2 changed files with 10 additions and 0 deletions

View File

@ -67,6 +67,10 @@ CALLBACK_STATE DCCACK::callbackState=READY;
ACK_CALLBACK DCCACK::ackManagerCallback;
void DCCACK::Setup(int cv, byte byteValueOrBitnum, ackOp const program[], ACK_CALLBACK callback) {
// On ESP32 the joined track is hidden from sight (it has type MAIN)
// and because of that we need first check if track was joined and
// then unjoin if necessary. This requires that the joined flag is
// cleared when the prog track is removed.
ackManagerRejoin=TrackManager::isJoined();
if (ackManagerRejoin) {
// Change from JOIN must zero resets packet.

View File

@ -361,6 +361,12 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
track[trackToSet]->setPower(POWERMODE::OFF);
streamTrackState(NULL,trackToSet);
#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;
#endif
//DIAG(F("TrackMode=%d"),mode);
return true;
}