Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions EXRAIL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ char RMFT2::getRouteType(int16_t id) {
}


RMFT2::RMFT2(int progCtr, int16_t _loco) {
RMFT2::RMFT2(int progCtr, int16_t _loco, bool _invert) {
progCounter=progCtr;

// get an unused task id from the flags table
Expand All @@ -404,7 +404,7 @@ RMFT2::RMFT2(int progCtr, int16_t _loco) {
}
delayTime=0;
loco=_loco;
invert=false;
invert=_invert;
blinkState=not_blink_task;
stackDepth=0;
onEventStartPosition=-1; // Not handling an ONxxx
Expand Down Expand Up @@ -1000,6 +1000,23 @@ void RMFT2::loop2() {
new RMFT2(newPc);
}
break;

case OPCODE_START_SHARED:
{
int newPc=routeLookup->find(operand);
if (newPc<0) break;
new RMFT2(newPc,loco, invert); // create new task and share loco
}
break;

case OPCODE_START_SEND:
{
int newPc=routeLookup->find(operand);
if (newPc<0) break;
new RMFT2(newPc,loco, invert); // create new task and send loco exclusive
loco = 0;
}
break;

case OPCODE_SENDLOCO: // cab, route
{
Expand Down
4 changes: 2 additions & 2 deletions EXRAIL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT,
OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,
#endif
OPCODE_POM,
OPCODE_START,OPCODE_SETLOCO,OPCODE_SETFREQ,OPCODE_SENDLOCO,OPCODE_FORGET,
OPCODE_START,OPCODE_START_SHARED,OPCODE_START_SEND,OPCODE_SETLOCO,OPCODE_SETFREQ,OPCODE_SENDLOCO,OPCODE_FORGET,
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,OPCODE_POWERON,
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
OPCODE_PRINT,OPCODE_DCCACTIVATE,OPCODE_ASPECT,
Expand Down Expand Up @@ -187,7 +187,7 @@ class LookList {
public:
static void begin();
static void loop();
RMFT2(int progCounter, int16_t cab=0);
RMFT2(int progCounter, int16_t cab=0, bool invert=false);
~RMFT2();
static void readLocoCallback(int16_t cv);
static void createNewTask(int route, uint16_t cab);
Expand Down
16 changes: 15 additions & 1 deletion EXRAIL2MacroReset.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@
#undef SIGNAL
#undef SIGNALH
#undef SPEED
#undef START
#undef START
#undef START_SHARED
#undef START_SEND
#undef STASH
#undef STEALTH
#undef STEALTH_GLOBAL
Expand Down Expand Up @@ -1297,6 +1299,18 @@
* @param sequence_id
*/
#define START(sequence_id)
/**
* @def START_SHARED(sequence_id)
* @brief Starts a new task at the given route/animation/sequence an share current loco with it
* @param sequence_id
*/
#define START_SHARED(sequence_id)
/**
* @def START_SEND(sequence_id)
* @brief Starts a new task at the given route/animation/sequence an send current loco to it. Remove loco from current task.
* @param sequence_id
*/
#define START_SEND(sequence_id)
/**
* @def STASH(stash_id)
* @brief saves cuttent tasks loco id in the stash array
Expand Down
4 changes: 4 additions & 0 deletions EXRAILAsserts.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ constexpr bool unsafePin(const int16_t value, const int16_t pos=0 ) {
#define FOLLOW(id) static_assert(seqCount(id)>0,"Sequence not found");
#undef START
#define START(id) static_assert(seqCount(id)>0,"Sequence not found");
#undef START_SHARED
#define START_SHARED(id) static_assert(seqCount(id)>0,"Sequence not found");
#undef START_SEND
#define START_SEND(id) static_assert(seqCount(id)>0,"Sequence not found");
#undef SENDLOCO
#define SENDLOCO(cab,id) static_assert(seqCount(id)>0,"Sequence not found");
#undef ROUTE_ACTIVE
Expand Down
2 changes: 2 additions & 0 deletions EXRAILMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup];
#define SIGNALH(redpin,amberpin,greenpin)
#define SPEED(speed) OPCODE_SPEED,V(speed),
#define START(route) OPCODE_START,V(route),
#define START_SHARED(route) OPCODE_START_SHARED,V(route),
#define START_SEND(route) OPCODE_START_SEND,V(route),
#define STASH(id) OPCODE_STASH,V(id),
#define STOP OPCODE_SPEED,V(0),
#define THROW(id) OPCODE_THROW,V(id),
Expand Down