mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-24 16:46:13 +01:00
Compare commits
No commits in common. "ea4f90d5fcd76b59f2a3a4fb0daa5a6f7ceeb815" and "370dae0ab8854b903906b2f7647b65022968b40f" have entirely different histories.
ea4f90d5fc
...
370dae0ab8
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,5 +13,3 @@ myFilter.cpp
|
||||||
my*.h
|
my*.h
|
||||||
!my*.example.h
|
!my*.example.h
|
||||||
compile_commands.json
|
compile_commands.json
|
||||||
newcode.txt.old
|
|
||||||
UserAddin.txt
|
|
||||||
|
|
|
@ -269,6 +269,6 @@ void CommandDistributor::broadcastRaw(clientType type, char * msg) {
|
||||||
broadcastReply(type, F("%s"),msg);
|
broadcastReply(type, F("%s"),msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr) {
|
void CommandDistributor::broadcastTrackState(const FSH* format,byte trackLetter,int16_t dcAddr) {
|
||||||
broadcastReply(COMMAND_TYPE, format,trackLetter, dcAddr);
|
broadcastReply(COMMAND_TYPE, format,trackLetter,dcAddr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public :
|
||||||
static int16_t retClockTime();
|
static int16_t retClockTime();
|
||||||
static void broadcastPower();
|
static void broadcastPower();
|
||||||
static void broadcastRaw(clientType type,char * msg);
|
static void broadcastRaw(clientType type,char * msg);
|
||||||
static void broadcastTrackState(const FSH* format,byte trackLetter, int16_t dcAddr);
|
static void broadcastTrackState(const FSH* format,byte trackLetter,int16_t dcAddr);
|
||||||
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
||||||
static void forget(byte clientId);
|
static void forget(byte clientId);
|
||||||
|
|
||||||
|
|
173
DCCEXParser.cpp
173
DCCEXParser.cpp
|
@ -157,7 +157,6 @@ const int16_t HASH_KEYWORD_VPIN=-415;
|
||||||
const int16_t HASH_KEYWORD_A='A';
|
const int16_t HASH_KEYWORD_A='A';
|
||||||
const int16_t HASH_KEYWORD_C='C';
|
const int16_t HASH_KEYWORD_C='C';
|
||||||
const int16_t HASH_KEYWORD_G='G';
|
const int16_t HASH_KEYWORD_G='G';
|
||||||
const int16_t HASH_KEYWORD_H='H';
|
|
||||||
const int16_t HASH_KEYWORD_I='I';
|
const int16_t HASH_KEYWORD_I='I';
|
||||||
const int16_t HASH_KEYWORD_O='O';
|
const int16_t HASH_KEYWORD_O='O';
|
||||||
const int16_t HASH_KEYWORD_P='P';
|
const int16_t HASH_KEYWORD_P='P';
|
||||||
|
@ -553,131 +552,69 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
|
|
||||||
case '1': // POWERON <1 [MAIN|PROG|JOIN]>
|
case '1': // POWERON <1 [MAIN|PROG|JOIN]>
|
||||||
{
|
{
|
||||||
bool main=false;
|
bool main=false;
|
||||||
bool prog=false;
|
bool prog=false;
|
||||||
bool join=false;
|
bool join=false;
|
||||||
bool singletrack=false;
|
if (params > 1) break;
|
||||||
//byte t=0;
|
if (params==0) { // All
|
||||||
if (params > 1) break;
|
main=true;
|
||||||
if (params==0) { // All
|
prog=true;
|
||||||
main=true;
|
}
|
||||||
prog=true;
|
if (params==1) {
|
||||||
}
|
if (p[0]==HASH_KEYWORD_MAIN) { // <1 MAIN>
|
||||||
if (params==1) {
|
main=true;
|
||||||
if (p[0]==HASH_KEYWORD_MAIN) { // <1 MAIN>
|
}
|
||||||
main=true;
|
|
||||||
}
|
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
else if (p[0] == HASH_KEYWORD_JOIN) { // <1 JOIN>
|
else if (p[0] == HASH_KEYWORD_JOIN) { // <1 JOIN>
|
||||||
main=true;
|
main=true;
|
||||||
prog=true;
|
prog=true;
|
||||||
join=true;
|
join=true;
|
||||||
}
|
}
|
||||||
else if (p[0]==HASH_KEYWORD_PROG) { // <1 PROG>
|
else if (p[0]==HASH_KEYWORD_PROG) { // <1 PROG>
|
||||||
prog=true;
|
prog=true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
else break; // will reply <X>
|
||||||
else if (p[0] >= HASH_KEYWORD_A && p[0] <= HASH_KEYWORD_H) { // <1 A-H>
|
}
|
||||||
byte t = (p[0] - 'A');
|
TrackManager::setJoin(join);
|
||||||
//DIAG(F("Processing track - %d "), t);
|
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
||||||
if (TrackManager::isProg(t)) {
|
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
||||||
main = false;
|
|
||||||
prog = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
main=true;
|
|
||||||
prog=false;
|
|
||||||
}
|
|
||||||
singletrack=true;
|
|
||||||
if (main) TrackManager::setTrackPower(false, false, POWERMODE::ON, t);
|
|
||||||
if (prog) TrackManager::setTrackPower(true, false, POWERMODE::ON, t);
|
|
||||||
|
|
||||||
StringFormatter::send(stream, F("<1 %c>\n"), t+'A');
|
|
||||||
//CommandDistributor::broadcastPower();
|
|
||||||
//TrackManager::streamTrackState(NULL,t);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else break; // will reply <X>
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!singletrack) {
|
|
||||||
TrackManager::setJoin(join);
|
|
||||||
if (join) TrackManager::setJoinPower(POWERMODE::ON);
|
|
||||||
else {
|
|
||||||
if (main) TrackManager::setMainPower(POWERMODE::ON);
|
|
||||||
if (prog) TrackManager::setProgPower(POWERMODE::ON);
|
|
||||||
}
|
|
||||||
CommandDistributor::broadcastPower();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
CommandDistributor::broadcastPower();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case '0': // POWEROFF <0 [MAIN | PROG] >
|
case '0': // POWEROFF <0 [MAIN | PROG] >
|
||||||
{
|
{
|
||||||
bool main=false;
|
bool main=false;
|
||||||
bool prog=false;
|
bool prog=false;
|
||||||
bool singletrack=false;
|
if (params > 1) break;
|
||||||
//byte t=0;
|
if (params==0) { // All
|
||||||
if (params > 1) break;
|
main=true;
|
||||||
if (params==0) { // All
|
prog=true;
|
||||||
main=true;
|
}
|
||||||
prog=true;
|
if (params==1) {
|
||||||
}
|
if (p[0]==HASH_KEYWORD_MAIN) { // <0 MAIN>
|
||||||
if (params==1) {
|
main=true;
|
||||||
if (p[0]==HASH_KEYWORD_MAIN) { // <0 MAIN>
|
}
|
||||||
main=true;
|
#ifndef DISABLE_PROG
|
||||||
}
|
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
||||||
#ifndef DISABLE_PROG
|
prog=true;
|
||||||
else if (p[0]==HASH_KEYWORD_PROG) { // <0 PROG>
|
}
|
||||||
prog=true;
|
#endif
|
||||||
}
|
else break; // will reply <X>
|
||||||
#endif
|
}
|
||||||
//else if (p[0] >= 'A' && p[0] <= 'H') { // <1 A-H>
|
|
||||||
else if (p[0] >= HASH_KEYWORD_A && p[0] <= HASH_KEYWORD_H) { // <1 A-H>
|
TrackManager::setJoin(false);
|
||||||
byte t = (p[0] - 'A');
|
if (main) TrackManager::setMainPower(POWERMODE::OFF);
|
||||||
//DIAG(F("Processing track - %d "), t);
|
if (prog) {
|
||||||
if (TrackManager::isProg(t)) {
|
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
||||||
main = false;
|
TrackManager::setProgPower(POWERMODE::OFF);
|
||||||
prog = true;
|
}
|
||||||
}
|
|
||||||
else
|
CommandDistributor::broadcastPower();
|
||||||
{
|
return;
|
||||||
main=true;
|
|
||||||
prog=false;
|
|
||||||
}
|
|
||||||
singletrack=true;
|
|
||||||
TrackManager::setJoin(false);
|
|
||||||
if (main) TrackManager::setTrackPower(false, false, POWERMODE::OFF, t);
|
|
||||||
if (prog) {
|
|
||||||
TrackManager::progTrackBoosted=false; // Prog track boost mode will not outlive prog track off
|
|
||||||
TrackManager::setTrackPower(true, false, POWERMODE::OFF, t);
|
|
||||||
}
|
|
||||||
StringFormatter::send(stream, F("<0 %c>\n"), t+'A');
|
|
||||||
//CommandDistributor::broadcastPower();
|
|
||||||
//TrackManager::streamTrackState(NULL, t);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else break; // will reply <X>
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!singletrack) {
|
|
||||||
TrackManager::setJoin(false);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
CommandDistributor::broadcastPower();
|
|
||||||
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.
|
||||||
|
|
14
EXRAIL2.cpp
14
EXRAIL2.cpp
|
@ -781,20 +781,6 @@ void RMFT2::loop2() {
|
||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPCODE_SET_POWER:
|
|
||||||
// operand is TRACK_POWER , trackid
|
|
||||||
//byte thistrack=getOperand(1);
|
|
||||||
switch (operand) {
|
|
||||||
case TRACK_POWER_0:
|
|
||||||
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), false, POWERMODE::OFF, getOperand(1));
|
|
||||||
break;
|
|
||||||
case TRACK_POWER_1:
|
|
||||||
TrackManager::setTrackPower(TrackManager::isProg(getOperand(1)), false, POWERMODE::ON, getOperand(1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OPCODE_SET_TRACK:
|
case OPCODE_SET_TRACK:
|
||||||
// operand is trackmode<<8 | track id
|
// operand is trackmode<<8 | track id
|
||||||
// If DC/DCX use my loco for DC address
|
// If DC/DCX use my loco for DC address
|
||||||
|
|
|
@ -59,7 +59,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_ROSTER,OPCODE_KILLALL,
|
OPCODE_ROSTER,OPCODE_KILLALL,
|
||||||
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,
|
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,
|
||||||
OPCODE_ENDTASK,OPCODE_ENDEXRAIL,
|
OPCODE_ENDTASK,OPCODE_ENDEXRAIL,
|
||||||
OPCODE_SET_TRACK,OPCODE_SET_POWER,
|
OPCODE_SET_TRACK,
|
||||||
OPCODE_ONRED,OPCODE_ONAMBER,OPCODE_ONGREEN,
|
OPCODE_ONRED,OPCODE_ONAMBER,OPCODE_ONGREEN,
|
||||||
OPCODE_ONCHANGE,
|
OPCODE_ONCHANGE,
|
||||||
OPCODE_ONCLOCKTIME,
|
OPCODE_ONCLOCKTIME,
|
||||||
|
|
|
@ -138,7 +138,6 @@
|
||||||
#undef SERVO_SIGNAL
|
#undef SERVO_SIGNAL
|
||||||
#undef SET
|
#undef SET
|
||||||
#undef SET_TRACK
|
#undef SET_TRACK
|
||||||
#undef SET_POWER
|
|
||||||
#undef SETLOCO
|
#undef SETLOCO
|
||||||
#undef SIGNAL
|
#undef SIGNAL
|
||||||
#undef SIGNALH
|
#undef SIGNALH
|
||||||
|
@ -276,7 +275,6 @@
|
||||||
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...)
|
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...)
|
||||||
#define SET(pin)
|
#define SET(pin)
|
||||||
#define SET_TRACK(track,mode)
|
#define SET_TRACK(track,mode)
|
||||||
#define SET_POWER(track,onoff)
|
|
||||||
#define SETLOCO(loco)
|
#define SETLOCO(loco)
|
||||||
#define SIGNAL(redpin,amberpin,greenpin)
|
#define SIGNAL(redpin,amberpin,greenpin)
|
||||||
#define SIGNALH(redpin,amberpin,greenpin)
|
#define SIGNALH(redpin,amberpin,greenpin)
|
||||||
|
|
|
@ -63,11 +63,6 @@
|
||||||
// (10#mins)%100)
|
// (10#mins)%100)
|
||||||
#define STRIP_ZERO(value) 10##value%100
|
#define STRIP_ZERO(value) 10##value%100
|
||||||
|
|
||||||
// These constants help EXRAIL macros convert Track Power e.g. SET_POWER(A ON|OFF).
|
|
||||||
//const byte TRACK_POWER_0=0, TRACK_POWER_OFF=0;
|
|
||||||
//const byte TRACK_POWER_1=1, TRACK_POWER_ON=1;
|
|
||||||
|
|
||||||
|
|
||||||
// Pass 1 Implements aliases
|
// Pass 1 Implements aliases
|
||||||
#include "EXRAIL2MacroReset.h"
|
#include "EXRAIL2MacroReset.h"
|
||||||
#undef ALIAS
|
#undef ALIAS
|
||||||
|
@ -412,7 +407,6 @@ 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 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)
|
||||||
|
|
144
TrackManager.cpp
144
TrackManager.cpp
|
@ -26,8 +26,7 @@
|
||||||
#include "MotorDriver.h"
|
#include "MotorDriver.h"
|
||||||
#include "DCCTimer.h"
|
#include "DCCTimer.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
#include "CommandDistributor.h"
|
#include"CommandDistributor.h"
|
||||||
#include "DCCEXParser.h"
|
|
||||||
// Virtualised Motor shield multi-track hardware Interface
|
// Virtualised Motor shield multi-track hardware Interface
|
||||||
#define FOR_EACH_TRACK(t) for (byte t=0;t<=lastTrack;t++)
|
#define FOR_EACH_TRACK(t) for (byte t=0;t<=lastTrack;t++)
|
||||||
|
|
||||||
|
@ -332,7 +331,6 @@ bool TrackManager::parseJ(Print *stream, int16_t params, int16_t p[])
|
||||||
FOR_EACH_TRACK(t)
|
FOR_EACH_TRACK(t)
|
||||||
streamTrackState(stream,t);
|
streamTrackState(stream,t);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p[0]-=HASH_KEYWORD_A; // convert A... to 0....
|
p[0]-=HASH_KEYWORD_A; // convert A... to 0....
|
||||||
|
@ -367,36 +365,32 @@ void TrackManager::streamTrackState(Print* stream, byte t) {
|
||||||
// null stream means send to commandDistributor for broadcast
|
// null stream means send to commandDistributor for broadcast
|
||||||
if (track[t]==NULL) return;
|
if (track[t]==NULL) return;
|
||||||
auto format=F("");
|
auto format=F("");
|
||||||
bool pstate = TrackManager::isPowerOn(t);
|
|
||||||
|
|
||||||
switch(track[t]->getMode()) {
|
switch(track[t]->getMode()) {
|
||||||
case TRACK_MODE_MAIN:
|
case TRACK_MODE_MAIN:
|
||||||
if (pstate) {format=F("<= %c MAIN ON>\n");} else {format = F("<= %c MAIN OFF>\n");}
|
format=F("<= %c MAIN>\n");
|
||||||
break;
|
break;
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
case TRACK_MODE_PROG:
|
case TRACK_MODE_PROG:
|
||||||
if (pstate) {format=F("<= %c PROG ON>\n");} else {format=F("<= %c PROG OFF>\n");}
|
format=F("<= %c PROG>\n");
|
||||||
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");}
|
format=F("<= %c NONE>\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");}
|
format=F("<= %c EXT>\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");}
|
format=F("<= %c DC %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");}
|
format=F("<= %c DCX %d>\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break; // unknown, dont care
|
break; // unknown, dont care
|
||||||
}
|
}
|
||||||
|
if (stream) StringFormatter::send(stream,format,'A'+t,trackDCAddr[t]);
|
||||||
if (stream) StringFormatter::send(stream,format,'A'+t, trackDCAddr[t]);
|
else CommandDistributor::broadcastTrackState(format,'A'+t,trackDCAddr[t]);
|
||||||
else CommandDistributor::broadcastTrackState(format,'A'+t, trackDCAddr[t]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte TrackManager::nextCycleTrack=MAX_TRACKS;
|
byte TrackManager::nextCycleTrack=MAX_TRACKS;
|
||||||
|
@ -430,70 +424,49 @@ std::vector<MotorDriver *>TrackManager::getMainDrivers() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void TrackManager::setPower2(bool setProg,bool setJoin, 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) {
|
||||||
|
MotorDriver * driver=track[t];
|
||||||
TrackManager::setTrackPower(setProg, setJoin, mode, t);
|
if (!driver) continue;
|
||||||
|
switch (track[t]->getMode()) {
|
||||||
}
|
case TRACK_MODE_MAIN:
|
||||||
return;
|
if (setProg) break;
|
||||||
}
|
// toggle brake before turning power on - resets overcurrent error
|
||||||
|
// on the Pololu board if brake is wired to ^D2.
|
||||||
void TrackManager::setTrackPower(bool setProg, bool setJoin, POWERMODE mode, byte thistrack) {
|
// XXX see if we can make this conditional
|
||||||
|
driver->setBrake(true);
|
||||||
//DIAG(F("SetTrackPower Processing Track %d"), thistrack);
|
driver->setBrake(false); // DCC runs with brake off
|
||||||
MotorDriver * driver=track[thistrack];
|
driver->setPower(mode);
|
||||||
if (!driver) return;
|
break;
|
||||||
|
case TRACK_MODE_DC:
|
||||||
switch (track[thistrack]->getMode()) {
|
case TRACK_MODE_DCX:
|
||||||
case TRACK_MODE_MAIN:
|
if (setProg) break;
|
||||||
if (setProg) break;
|
driver->setBrake(true); // DC starts with brake on
|
||||||
// toggle brake before turning power on - resets overcurrent error
|
applyDCSpeed(t); // speed match DCC throttles
|
||||||
// on the Pololu board if brake is wired to ^D2.
|
driver->setPower(mode);
|
||||||
// XXX see if we can make this conditional
|
break;
|
||||||
driver->setBrake(true);
|
case TRACK_MODE_PROG:
|
||||||
driver->setBrake(false); // DCC runs with brake off
|
if (!setProg) break;
|
||||||
driver->setPower(mode);
|
driver->setBrake(true);
|
||||||
break;
|
driver->setBrake(false);
|
||||||
case TRACK_MODE_DC:
|
driver->setPower(mode);
|
||||||
case TRACK_MODE_DCX:
|
break;
|
||||||
//DIAG(F("Processing track - %d setProg %d"), thistrack, setProg);
|
case TRACK_MODE_EXT:
|
||||||
if (setProg || setJoin) break;
|
driver->setBrake(true);
|
||||||
driver->setBrake(true); // DC starts with brake on
|
driver->setBrake(false);
|
||||||
applyDCSpeed(thistrack); // speed match DCC throttles
|
driver->setPower(mode);
|
||||||
driver->setPower(mode);
|
break;
|
||||||
break;
|
case TRACK_MODE_NONE:
|
||||||
case TRACK_MODE_PROG:
|
break;
|
||||||
if (!setProg && !setJoin) 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::reportPowerChange(Print* stream, byte thistrack) {
|
|
||||||
// This function is for backward JMRI compatibility only
|
|
||||||
// It reports the first track only, as main, regardless of track settings.
|
|
||||||
// <c MeterName value C/V unit min max res warn>
|
|
||||||
int maxCurrent=track[0]->raw2mA(track[0]->getRawCurrentTripValue());
|
|
||||||
StringFormatter::send(stream, F("<c CurrentMAIN %d C Milli 0 %d 1 %d>\n"),
|
|
||||||
track[0]->raw2mA(track[0]->getCurrentRaw(false)), maxCurrent, maxCurrent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
POWERMODE TrackManager::getProgPower() {
|
POWERMODE TrackManager::getProgPower() {
|
||||||
FOR_EACH_TRACK(t)
|
FOR_EACH_TRACK(t)
|
||||||
if (track[t]->getMode()==TRACK_MODE_PROG)
|
if (track[t]->getMode()==TRACK_MODE_PROG)
|
||||||
return track[t]->getPower();
|
return track[t]->getPower();
|
||||||
return POWERMODE::OFF;
|
return POWERMODE::OFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,32 +538,3 @@ bool TrackManager::isPowerOn(byte t) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackManager::isProg(byte t) {
|
|
||||||
if (track[t]->getMode()==TRACK_MODE_PROG)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte TrackManager::returnMode(byte t) {
|
|
||||||
return (track[t]->getMode());
|
|
||||||
}
|
|
||||||
|
|
||||||
int16_t TrackManager::returnDCAddr(byte t) {
|
|
||||||
return (trackDCAddr[t]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* TrackManager::getModeName(byte Mode) {
|
|
||||||
|
|
||||||
//DIAG(F("PowerMode %d"), Mode);
|
|
||||||
|
|
||||||
switch (Mode)
|
|
||||||
{
|
|
||||||
case 1: return "NONE";
|
|
||||||
case 2: return "MAIN";
|
|
||||||
case 4: return "PROG";
|
|
||||||
case 8: return "DC";
|
|
||||||
case 16: return "DCX";
|
|
||||||
case 32: return "EXT";
|
|
||||||
default: return "----";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -39,10 +39,6 @@ const byte TRACK_NUMBER_5=5, TRACK_NUMBER_F=5;
|
||||||
const byte TRACK_NUMBER_6=6, TRACK_NUMBER_G=6;
|
const byte TRACK_NUMBER_6=6, TRACK_NUMBER_G=6;
|
||||||
const byte TRACK_NUMBER_7=7, TRACK_NUMBER_H=7;
|
const byte TRACK_NUMBER_7=7, TRACK_NUMBER_H=7;
|
||||||
|
|
||||||
// These constants help EXRAIL macros convert Track Power e.g. SET_POWER(A ON|OFF).
|
|
||||||
const byte TRACK_POWER_0=0, TRACK_POWER_OFF=0;
|
|
||||||
const byte TRACK_POWER_1=1, TRACK_POWER_ON=1;
|
|
||||||
|
|
||||||
class TrackManager {
|
class TrackManager {
|
||||||
public:
|
public:
|
||||||
static void Setup(const FSH * shieldName,
|
static void Setup(const FSH * shieldName,
|
||||||
|
@ -64,14 +60,10 @@ class TrackManager {
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
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,false,mode);}
|
static void setMainPower(POWERMODE mode) {setPower2(false,mode);}
|
||||||
static void setProgPower(POWERMODE mode) {setPower2(true,false,mode);}
|
static void setProgPower(POWERMODE mode) {setPower2(true,mode);}
|
||||||
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;
|
||||||
static bool setTrackMode(byte track, TRACK_MODE mode, int16_t DCaddr=0);
|
static bool setTrackMode(byte track, TRACK_MODE mode, int16_t DCaddr=0);
|
||||||
|
@ -85,14 +77,9 @@ class TrackManager {
|
||||||
static void sampleCurrent();
|
static void sampleCurrent();
|
||||||
static void reportGauges(Print* stream);
|
static void reportGauges(Print* stream);
|
||||||
static void reportCurrent(Print* stream);
|
static void reportCurrent(Print* stream);
|
||||||
static void reportPowerChange(Print* stream, byte thistrack);
|
|
||||||
static void reportObsoleteCurrent(Print* stream);
|
static void reportObsoleteCurrent(Print* stream);
|
||||||
static void streamTrackState(Print* stream, byte t);
|
static void streamTrackState(Print* stream, byte t);
|
||||||
static bool isPowerOn(byte t);
|
static bool isPowerOn(byte t);
|
||||||
static bool isProg(byte t);
|
|
||||||
static byte returnMode(byte t);
|
|
||||||
static int16_t returnDCAddr(byte t);
|
|
||||||
static const char* getModeName(byte Mode);
|
|
||||||
|
|
||||||
static int16_t joinRelay;
|
static int16_t joinRelay;
|
||||||
static bool progTrackSyncMain; // true when prog track is a siding switched to main
|
static bool progTrackSyncMain; // true when prog track is a siding switched to main
|
||||||
|
|
|
@ -3,12 +3,7 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.1.12"
|
#define VERSION "5.1.11"
|
||||||
// 5.1.12 - Added Power commands <0 A> & <1 A> etc. and update to <=>
|
|
||||||
// Added EXRAIL SET_POWER(track, ON/OFF)
|
|
||||||
// Fixed a problem whereby <1 MAIN> also powered on PROG track
|
|
||||||
// Added functions to TrackManager.cpp to allow UserAddin code for power display on OLED/LCD
|
|
||||||
// Added - returnMode(byte t), returnDCAddr(byte t) & getModeName(byte Mode)
|
|
||||||
// 5.1.11 - STM32F4xx revised I2C clock setup, no correctly sets clock and has fully variable frequency selection
|
// 5.1.11 - STM32F4xx revised I2C clock setup, no correctly sets clock and has fully variable frequency selection
|
||||||
// 5.1.10 - STM32F4xx DCCEXanalogWrite to handle PWM generation for TrackManager DC/DCX
|
// 5.1.10 - STM32F4xx DCCEXanalogWrite to handle PWM generation for TrackManager DC/DCX
|
||||||
// - STM32F4xx DCC 58uS timer now using non-PWM output timers where possible
|
// - STM32F4xx DCC 58uS timer now using non-PWM output timers where possible
|
||||||
|
|
Loading…
Reference in New Issue
Block a user