diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index f021594..2324ea8 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -656,7 +656,13 @@ void RMFT2::loop2() { DCCWaveform::setJoin(false); CommandDistributor::broadcastPower(); break; - + + case OPCODE_SET_TRACK: + // operand is track id and +128= Use my loco for DC + TrackManager::setTrackMode(operand & 0x0F, + operand>=128 ? loco : TrackManager::TRACK_MODE_MAIN); + break; + case OPCODE_RESUME: pausingTask=NULL; driveLoco(speedo); diff --git a/EXRAIL2.h b/EXRAIL2.h index b44ada6..29b9816 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -48,7 +48,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT, OPCODE_PRINT,OPCODE_DCCACTIVATE, OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFGTE,OPCODE_IFLT, - OPCODE_ROSTER, + OPCODE_ROSTER,OPCODE_SET_TRACK, OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL }; diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 852eb70..962322a 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -98,6 +98,8 @@ #undef SERVO2 #undef SERVO_TURNOUT #undef SET +#undef SET_TRACK_DC +#undef SET_TRACK_DCC #undef SETLOCO #undef SIGNAL #undef SPEED @@ -187,6 +189,8 @@ #define SERVO2(id,position,duration) #define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...) #define SET(pin) +#define SET_TRACK_DC(trackid) +#define SET_TRACK_DCC(trackid) #define SETLOCO(loco) #define SIGNAL(redpin,amberpin,greenpin) #define SPEED(speed) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 7efb445..7e70e83 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -236,6 +236,8 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = { #define SERVO2(id,position,ms) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::Instant),OPCODE_PAD,V(ms/100L), #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_TRACK_DC(track) OPCODE_SET_TRACK,V(128+track), +#define SET_TRACK_DCC(track) OPCODE_SET_TRACK,V(track), #define SETLOCO(loco) OPCODE_SETLOCO,V(loco), #define SIGNAL(redpin,amberpin,greenpin) #define SPEED(speed) OPCODE_SPEED,V(speed),