mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-23 12:51:24 +01:00
ESP32 Trackmanager reset cab number to 0 when track is not DC
This commit is contained in:
parent
1a307eea3d
commit
38a9585a41
@ -38,8 +38,8 @@
|
|||||||
if (track[t]->getMode()==findmode) \
|
if (track[t]->getMode()==findmode) \
|
||||||
track[t]->function;
|
track[t]->function;
|
||||||
|
|
||||||
MotorDriver * TrackManager::track[MAX_TRACKS];
|
MotorDriver * TrackManager::track[MAX_TRACKS] = { NULL };
|
||||||
int16_t TrackManager::trackDCAddr[MAX_TRACKS];
|
int16_t TrackManager::trackDCAddr[MAX_TRACKS] = { 0 };
|
||||||
|
|
||||||
int8_t TrackManager::lastTrack=-1;
|
int8_t TrackManager::lastTrack=-1;
|
||||||
bool TrackManager::progTrackSyncMain=false;
|
bool TrackManager::progTrackSyncMain=false;
|
||||||
@ -251,7 +251,6 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
|||||||
} else {
|
} else {
|
||||||
track[trackToSet]->makeProgTrack(false); // only the prog track knows it's type
|
track[trackToSet]->makeProgTrack(false); // only the prog track knows it's type
|
||||||
}
|
}
|
||||||
track[trackToSet]->setMode(mode);
|
|
||||||
|
|
||||||
// When a track is switched, we must clear any side effects of its previous
|
// When a track is switched, we must clear any side effects of its previous
|
||||||
// state, otherwise trains run away or just dont move.
|
// state, otherwise trains run away or just dont move.
|
||||||
@ -259,8 +258,13 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
|||||||
// This can be done BEFORE the PWM-Timer evaluation (methinks)
|
// This can be done BEFORE the PWM-Timer evaluation (methinks)
|
||||||
if (mode & TRACK_MODE_DC) {
|
if (mode & TRACK_MODE_DC) {
|
||||||
if (trackDCAddr[trackToSet] != dcAddr) {
|
if (trackDCAddr[trackToSet] != dcAddr) {
|
||||||
// if we change dcAddr, detach first old signal
|
// new or changed DC Addr, run the new setup
|
||||||
track[trackToSet]->detachDCSignal();
|
if (trackDCAddr[trackToSet] != 0) {
|
||||||
|
// if we change dcAddr and not only
|
||||||
|
// change from another mode,
|
||||||
|
// first detach old DC signal
|
||||||
|
track[trackToSet]->detachDCSignal();
|
||||||
|
}
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
int trackfound = -1;
|
int trackfound = -1;
|
||||||
FOR_EACH_TRACK(t) {
|
FOR_EACH_TRACK(t) {
|
||||||
@ -285,7 +289,9 @@ bool TrackManager::setTrackMode(byte trackToSet, TRACK_MODE mode, int16_t dcAddr
|
|||||||
// DCC tracks need to have set the PWM to zero or they will not work.
|
// DCC tracks need to have set the PWM to zero or they will not work.
|
||||||
track[trackToSet]->detachDCSignal();
|
track[trackToSet]->detachDCSignal();
|
||||||
track[trackToSet]->setBrake(false);
|
track[trackToSet]->setBrake(false);
|
||||||
|
trackDCAddr[trackToSet]=0; // clear that an addr is set for DC as this is not a DC track
|
||||||
}
|
}
|
||||||
|
track[trackToSet]->setMode(mode);
|
||||||
|
|
||||||
// BOOST:
|
// BOOST:
|
||||||
// Leave it as is
|
// Leave it as is
|
||||||
|
Loading…
Reference in New Issue
Block a user