mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-25 00:56:13 +01:00
Compare commits
No commits in common. "17c004aecf558baa980bf9bb620cd7e456cf7969" and "aacb980dc873cc52742d5840aebb215ef0b573ce" have entirely different histories.
17c004aecf
...
aacb980dc8
|
@ -556,7 +556,6 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
bool prog=false;
|
bool prog=false;
|
||||||
bool join=false;
|
bool join=false;
|
||||||
bool singletrack=false;
|
bool singletrack=false;
|
||||||
byte t=0;
|
|
||||||
if (params > 1) break;
|
if (params > 1) break;
|
||||||
if (params==0) { // All
|
if (params==0) { // All
|
||||||
main=true;
|
main=true;
|
||||||
|
@ -577,8 +576,8 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
||||||
t = (p[0] - 'A');
|
byte t = (p[0] - 'A');
|
||||||
//DIAG(F("Processing track - %d "), t);
|
DIAG(F("Processing track - %d "), t);
|
||||||
if (TrackManager::isProg(t)) {
|
if (TrackManager::isProg(t)) {
|
||||||
main = false;
|
main = false;
|
||||||
prog = true;
|
prog = true;
|
||||||
|
@ -589,7 +588,10 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
prog=false;
|
prog=false;
|
||||||
}
|
}
|
||||||
singletrack=true;
|
singletrack=true;
|
||||||
|
DIAG(F("Calling SetPower %d - %d - %d"), POWERMODE::ON, false, t);
|
||||||
|
if (main) TrackManager::setTrackPower(POWERMODE::ON, t);
|
||||||
|
//if (main) TrackManager::SetMainTrackPower(POWERMODE::ON, t);
|
||||||
|
//if (prog) TrackManager::SetProgTrackPower(POWERMODE::ON, t);
|
||||||
}
|
}
|
||||||
else break; // will reply <X>
|
else break; // will reply <X>
|
||||||
}
|
}
|
||||||
|
@ -598,12 +600,6 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
||||||
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (main) TrackManager::setTrackPower(false, POWERMODE::ON, t);
|
|
||||||
if (prog) {
|
|
||||||
TrackManager::setTrackPower(true, POWERMODE::ON, t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -613,7 +609,6 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
bool main=false;
|
bool main=false;
|
||||||
bool prog=false;
|
bool prog=false;
|
||||||
bool singletrack=false;
|
bool singletrack=false;
|
||||||
byte t=0;
|
|
||||||
if (params > 1) break;
|
if (params > 1) break;
|
||||||
if (params==0) { // All
|
if (params==0) { // All
|
||||||
main=true;
|
main=true;
|
||||||
|
@ -627,10 +622,10 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
||||||
prog=true;
|
prog=true;
|
||||||
}
|
}
|
||||||
#endif <=
|
#endif
|
||||||
else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
||||||
t = (p[0] - 'A');
|
byte t = (p[0] - 'A');
|
||||||
//DIAG(F("Processing track - %d "), t);
|
DIAG(F("Processing track - %d "), t);
|
||||||
if (TrackManager::isProg(t)) {
|
if (TrackManager::isProg(t)) {
|
||||||
main = false;
|
main = false;
|
||||||
prog = true;
|
prog = true;
|
||||||
|
@ -641,28 +636,24 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
prog=false;
|
prog=false;
|
||||||
}
|
}
|
||||||
singletrack=true;
|
singletrack=true;
|
||||||
|
DIAG(F("Calling SetPower %d - %d - %d"), POWERMODE::OFF, false, t);
|
||||||
|
if (main) TrackManager::setTrackPower(POWERMODE::OFF, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
else break; // will reply <X>
|
else break; // will reply <X>
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
if (!singletrack) {
|
if (!singletrack) {
|
||||||
if (main) TrackManager::setMainPower(POWERMODE::OFF);
|
if (main) TrackManager::setMainPower(POWERMODE::OFF);
|
||||||
if (prog) {
|
|
||||||
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
|
||||||
TrackManager::setProgPower(POWERMODE::OFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (main) TrackManager::setTrackPower(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::setProgPower(POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '!': // ESTOP ALL <!>
|
case '!': // ESTOP ALL <!>
|
||||||
DCC::setThrottle(0,1,1); // this broadcasts speed 1(estop) and sets all reminders to speed 1.
|
DCC::setThrottle(0,1,1); // this broadcasts speed 1(estop) and sets all reminders to speed 1.
|
||||||
|
|
|
@ -783,13 +783,13 @@ void RMFT2::loop2() {
|
||||||
|
|
||||||
case OPCODE_SET_POWER:
|
case OPCODE_SET_POWER:
|
||||||
// operand is TRACK_POWER , trackid
|
// operand is TRACK_POWER , trackid
|
||||||
//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(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(POWERMODE::ON, getOperand(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -412,7 +412,7 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
|
||||||
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...) OPCODE_SERVOTURNOUT,V(id),OPCODE_PAD,V(pin),OPCODE_PAD,V(activeAngle),OPCODE_PAD,V(inactiveAngle),OPCODE_PAD,V(PCA9685::ProfileType::profile),
|
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...) OPCODE_SERVOTURNOUT,V(id),OPCODE_PAD,V(pin),OPCODE_PAD,V(activeAngle),OPCODE_PAD,V(inactiveAngle),OPCODE_PAD,V(PCA9685::ProfileType::profile),
|
||||||
#define SET(pin) OPCODE_SET,V(pin),
|
#define SET(pin) OPCODE_SET,V(pin),
|
||||||
#define SET_TRACK(track,mode) OPCODE_SET_TRACK,V(TRACK_MODE_##mode <<8 | TRACK_NUMBER_##track),
|
#define SET_TRACK(track,mode) OPCODE_SET_TRACK,V(TRACK_MODE_##mode <<8 | TRACK_NUMBER_##track),
|
||||||
#define SET_POWER(track,onoff) OPCODE_SET_POWER,V(TRACK_POWER_##onoff),OPCODE_PAD, V(TRACK_NUMBER_##track),
|
#define SET_POWER(track,onoff) OPCODE_SET_POWER,V(TRACK_POWER_##onoff, TRACK_NUMBER_##track),
|
||||||
#define SETLOCO(loco) OPCODE_SETLOCO,V(loco),
|
#define SETLOCO(loco) OPCODE_SETLOCO,V(loco),
|
||||||
#define SIGNAL(redpin,amberpin,greenpin)
|
#define SIGNAL(redpin,amberpin,greenpin)
|
||||||
#define SIGNALH(redpin,amberpin,greenpin)
|
#define SIGNALH(redpin,amberpin,greenpin)
|
||||||
|
|
|
@ -364,16 +364,16 @@ void TrackManager::streamTrackState(Print* stream, byte t) {
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case TRACK_MODE_NONE:
|
case TRACK_MODE_NONE:
|
||||||
if (pstate) {format=F("<= %c NONE ON>\n");} else {format=F("<= %c NONE OFF>\n");}
|
if (pstate) {format=F("<= %c NONE %ON>\n");} else {format=F("<= %c NONE %OFF>\n");}
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_EXT:
|
case TRACK_MODE_EXT:
|
||||||
if (pstate) {format=F("<= %c EXT ON>\n");} else {format=F("<= %c EXT OFF>\n");}
|
if (pstate) {format=F("<= %c EXT ON>\n");} else {format=F("<= %c EXT OFF>\n");}
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_DC:
|
case TRACK_MODE_DC:
|
||||||
if (pstate) {format=F("<= %c DC %d ON>\n");} else {format=F("<= %c DC %d OFF>\n");}
|
if (pstate) {format=F("<= %c DC ON %d>\n");} else {format=F("<= %c DC OFF %d>\n");}
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_DCX:
|
case TRACK_MODE_DCX:
|
||||||
if (pstate) {format=F("<= %c DCX %d ON>\n");} else {format=F("<= %c DCX %d OFF>\n");}
|
if (pstate) {format=F("<= %c DCX ON %d>\n");} else {format=F("<= %c DCX OFF %d>\n");}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break; // unknown, dont care
|
break; // unknown, dont care
|
||||||
|
@ -416,51 +416,9 @@ std::vector<MotorDriver *>TrackManager::getMainDrivers() {
|
||||||
void TrackManager::setPower2(bool setProg,POWERMODE mode) {
|
void TrackManager::setPower2(bool setProg,POWERMODE mode) {
|
||||||
if (!setProg) mainPowerGuess=mode;
|
if (!setProg) mainPowerGuess=mode;
|
||||||
FOR_EACH_TRACK(t) {
|
FOR_EACH_TRACK(t) {
|
||||||
TrackManager::setTrackPower(setProg, mode, t);
|
MotorDriver * driver=track[t];
|
||||||
// MotorDriver * driver=track[t];
|
if (!driver) continue;
|
||||||
// if (!driver) continue;
|
switch (track[t]->getMode()) {
|
||||||
// switch (track[t]->getMode()) {
|
|
||||||
// case TRACK_MODE_MAIN:
|
|
||||||
// if (setProg) break;
|
|
||||||
// // toggle brake before turning power on - resets overcurrent error
|
|
||||||
// // on the Pololu board if brake is wired to ^D2.
|
|
||||||
// // XXX see if we can make this conditional
|
|
||||||
// driver->setBrake(true);
|
|
||||||
// driver->setBrake(false); // DCC runs with brake off
|
|
||||||
// driver->setPower(mode);
|
|
||||||
// break;
|
|
||||||
// case TRACK_MODE_DC:
|
|
||||||
// case TRACK_MODE_DCX:
|
|
||||||
// if (setProg) break;
|
|
||||||
// driver->setBrake(true); // DC starts with brake on
|
|
||||||
// applyDCSpeed(t); // speed match DCC throttles
|
|
||||||
// driver->setPower(mode);
|
|
||||||
// break;
|
|
||||||
// case TRACK_MODE_PROG:
|
|
||||||
// if (!setProg) break;
|
|
||||||
// driver->setBrake(true);
|
|
||||||
// driver->setBrake(false);
|
|
||||||
// driver->setPower(mode);
|
|
||||||
// break;
|
|
||||||
// case TRACK_MODE_EXT:
|
|
||||||
// driver->setBrake(true);
|
|
||||||
// driver->setBrake(false);
|
|
||||||
// driver->setPower(mode);
|
|
||||||
// break;
|
|
||||||
// case TRACK_MODE_NONE:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackManager::setTrackPower(bool setProg, POWERMODE mode, byte thistrack) {
|
|
||||||
|
|
||||||
DIAG(F("SetTrackPower Processing Track %d"), thistrack);
|
|
||||||
MotorDriver * driver=track[thistrack];
|
|
||||||
if (!driver) return;
|
|
||||||
|
|
||||||
switch (track[thistrack]->getMode()) {
|
|
||||||
case TRACK_MODE_MAIN:
|
case TRACK_MODE_MAIN:
|
||||||
if (setProg) break;
|
if (setProg) break;
|
||||||
// toggle brake before turning power on - resets overcurrent error
|
// toggle brake before turning power on - resets overcurrent error
|
||||||
|
@ -474,7 +432,7 @@ void TrackManager::setTrackPower(bool setProg, POWERMODE mode, byte thistrack) {
|
||||||
case TRACK_MODE_DCX:
|
case TRACK_MODE_DCX:
|
||||||
if (setProg) break;
|
if (setProg) break;
|
||||||
driver->setBrake(true); // DC starts with brake on
|
driver->setBrake(true); // DC starts with brake on
|
||||||
applyDCSpeed(thistrack); // speed match DCC throttles
|
applyDCSpeed(t); // speed match DCC throttles
|
||||||
driver->setPower(mode);
|
driver->setPower(mode);
|
||||||
break;
|
break;
|
||||||
case TRACK_MODE_PROG:
|
case TRACK_MODE_PROG:
|
||||||
|
@ -491,9 +449,17 @@ void TrackManager::setTrackPower(bool setProg, POWERMODE mode, byte thistrack) {
|
||||||
case TRACK_MODE_NONE:
|
case TRACK_MODE_NONE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mode == POWERMODE::ON) {DIAG(F("Power Track %d ON"), thistrack);}
|
|
||||||
else {DIAG(F("Power Track %d OFF"), thistrack);}
|
}
|
||||||
//driver->setPower(mode);
|
}
|
||||||
|
|
||||||
|
void TrackManager::setTrackPower(POWERMODE mode, byte thistrack) {
|
||||||
|
|
||||||
|
DIAG(F("SetPower Processing Track %d"), thistrack);
|
||||||
|
MotorDriver * driver=track[thistrack];
|
||||||
|
if (!driver) return;
|
||||||
|
|
||||||
|
driver->setPower(mode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ class TrackManager {
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
static std::vector<MotorDriver *>getMainDrivers();
|
static std::vector<MotorDriver *>getMainDrivers();
|
||||||
#endif
|
#endif
|
||||||
static void setTrackPower(bool setProg, POWERMODE mode, byte thistrack);
|
static void setTrackPower(POWERMODE mode, byte thistrack);
|
||||||
static void setPower2(bool progTrack,POWERMODE mode);
|
static void setPower2(bool progTrack,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,mode);}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user