mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
Fix <1 JOIN>
Fixed <1 JOIN> issue in TrackManager
This commit is contained in:
parent
2a46b96083
commit
25bbfa4c68
|
@ -589,8 +589,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
prog=false;
|
prog=false;
|
||||||
}
|
}
|
||||||
singletrack=true;
|
singletrack=true;
|
||||||
if (main) TrackManager::setTrackPower(false, POWERMODE::ON, t);
|
if (main) TrackManager::setTrackPower(false, false, POWERMODE::ON, t);
|
||||||
if (prog) TrackManager::setTrackPower(true, POWERMODE::ON, t);
|
if (prog) TrackManager::setTrackPower(true, false, POWERMODE::ON, t);
|
||||||
//CommandDistributor::broadcastPower();
|
//CommandDistributor::broadcastPower();
|
||||||
//TrackManager::streamTrackState(stream, t);
|
//TrackManager::streamTrackState(stream, t);
|
||||||
TrackManager::streamTrackState(NULL,t);
|
TrackManager::streamTrackState(NULL,t);
|
||||||
|
@ -603,8 +603,11 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
|
|
||||||
if (!singletrack) {
|
if (!singletrack) {
|
||||||
TrackManager::setJoin(join);
|
TrackManager::setJoin(join);
|
||||||
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
if (join) TrackManager::setJoinPower(POWERMODE::ON);
|
||||||
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
else {
|
||||||
|
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
||||||
|
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
||||||
|
}
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -646,10 +649,10 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
}
|
}
|
||||||
singletrack=true;
|
singletrack=true;
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
if (main) TrackManager::setTrackPower(false, POWERMODE::OFF, t);
|
if (main) TrackManager::setTrackPower(false, false, POWERMODE::OFF, t);
|
||||||
if (prog) {
|
if (prog) {
|
||||||
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
||||||
TrackManager::setTrackPower(true, POWERMODE::OFF, t);
|
TrackManager::setTrackPower(true, false, POWERMODE::OFF, t);
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
}
|
}
|
||||||
StringFormatter::send(stream, F("Track %d OFF\n"), t);
|
StringFormatter::send(stream, F("Track %d OFF\n"), t);
|
||||||
|
|
|
@ -786,10 +786,10 @@ void RMFT2::loop2() {
|
||||||
//byte thistrack=getOperand(1);
|
//byte thistrack=getOperand(1);
|
||||||
switch (operand) {
|
switch (operand) {
|
||||||
case TRACK_POWER_0:
|
case TRACK_POWER_0:
|
||||||
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), POWERMODE::OFF, getOperand(1));
|
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), false, POWERMODE::OFF, getOperand(1));
|
||||||
break;
|
break;
|
||||||
case TRACK_POWER_1:
|
case TRACK_POWER_1:
|
||||||
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), POWERMODE::ON, getOperand(1));
|
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), false, POWERMODE::ON, getOperand(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,17 +417,17 @@ std::vector<MotorDriver *>TrackManager::getMainDrivers() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TrackManager::setPower2(bool setProg,POWERMODE mode) {
|
void TrackManager::setPower2(bool setProg,bool setJoin, POWERMODE mode) {
|
||||||
if (!setProg) mainPowerGuess=mode;
|
if (!setProg) mainPowerGuess=mode;
|
||||||
FOR_EACH_TRACK(t) {
|
FOR_EACH_TRACK(t) {
|
||||||
|
|
||||||
TrackManager::setTrackPower(setProg, mode, t);
|
TrackManager::setTrackPower(setProg, setJoin, mode, t);
|
||||||
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackManager::setTrackPower(bool setProg, POWERMODE mode, byte thistrack) {
|
void TrackManager::setTrackPower(bool setProg, bool setJoin, POWERMODE mode, byte thistrack) {
|
||||||
|
|
||||||
//DIAG(F("SetTrackPower Processing Track %d"), thistrack);
|
//DIAG(F("SetTrackPower Processing Track %d"), thistrack);
|
||||||
MotorDriver * driver=track[thistrack];
|
MotorDriver * driver=track[thistrack];
|
||||||
|
@ -445,21 +445,23 @@ void TrackManager::setTrackPower(bool setProg, POWERMODE mode, byte thistrack) {
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_DC:
|
case TRACK_MODE_DC:
|
||||||
case TRACK_MODE_DCX:
|
case TRACK_MODE_DCX:
|
||||||
if (setProg) break;
|
DIAG(F("Processing track - %d setProg %d"), thistrack, setProg);
|
||||||
|
if (setProg || setJoin) {DIAG(F("Nowt to do")); break;}
|
||||||
driver->setBrake(true); // DC starts with brake on
|
driver->setBrake(true); // DC starts with brake on
|
||||||
applyDCSpeed(thistrack); // speed match DCC throttles
|
applyDCSpeed(thistrack); // speed match DCC throttles
|
||||||
driver->setPower(mode);
|
driver->setPower(mode);
|
||||||
|
DIAG(F("Doing it anyway"));
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_PROG:
|
case TRACK_MODE_PROG:
|
||||||
if (!setProg) break;
|
if (!setProg && !setJoin) break;
|
||||||
driver->setBrake(true);
|
driver->setBrake(true);
|
||||||
driver->setBrake(false);
|
driver->setBrake(false);
|
||||||
driver->setPower(mode);
|
driver->setPower(mode);
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_EXT:
|
case TRACK_MODE_EXT:
|
||||||
driver->setBrake(true);
|
driver->setBrake(true);
|
||||||
driver->setBrake(false);
|
driver->setBrake(false);
|
||||||
driver->setPower(mode);
|
driver->setPower(mode);
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_NONE:
|
case TRACK_MODE_NONE:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -65,11 +65,12 @@ class TrackManager {
|
||||||
static std::vector<MotorDriver *>getMainDrivers();
|
static std::vector<MotorDriver *>getMainDrivers();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void setPower2(bool progTrack,POWERMODE mode);
|
static void setPower2(bool progTrack,bool joinTrack,POWERMODE mode);
|
||||||
static void setPower(POWERMODE mode) {setMainPower(mode); setProgPower(mode);}
|
static void setPower(POWERMODE mode) {setMainPower(mode); setProgPower(mode);}
|
||||||
static void setMainPower(POWERMODE mode) {setPower2(false,mode);}
|
static void setMainPower(POWERMODE mode) {setPower2(false,false,mode);}
|
||||||
static void setProgPower(POWERMODE mode) {setPower2(true,mode);}
|
static void setProgPower(POWERMODE mode) {setPower2(true,false,mode);}
|
||||||
static void setTrackPower(bool setProg, POWERMODE mode, byte thistrack);
|
static void setJoinPower(POWERMODE mode) {setPower2(false,true,mode);}
|
||||||
|
static void setTrackPower(bool setProg, bool setJoin, POWERMODE mode, byte thistrack);
|
||||||
|
|
||||||
|
|
||||||
static const int16_t MAX_TRACKS=8;
|
static const int16_t MAX_TRACKS=8;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user