diff --git a/RMFT2.cpp b/RMFT2.cpp index 944bcfe..32e0ded 100644 --- a/RMFT2.cpp +++ b/RMFT2.cpp @@ -547,12 +547,18 @@ void RMFT2::loop2() { case OPCODE_START: { - // Create new task and transfer loco..... - // but cheat by swapping prog counters with new task - int newPc=locateRouteStart(operand); + int newPc=locateRouteStart(GET_OPERAND(1)); if (newPc<0) break; - new RMFT2(progCounter+3); // give new task my prog counter - progCounter=newPc; // and I'll carry on from new task position + new RMFT2(newPc); + } + break; + + case OPCODE_SENDLOCO: // cab, route + { + int newPc=locateRouteStart(GET_OPERAND(1)); + if (newPc<0) break; + RMFT2* newtask=new RMFT2(newPc); // create new task + newtask->loco=operand; } break; diff --git a/RMFT2.h b/RMFT2.h index 2dc02d4..90253f3 100644 --- a/RMFT2.h +++ b/RMFT2.h @@ -39,7 +39,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_SERVO,OPCODE_SIGNAL,OPCODE_TURNOUT, OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN, OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,OPCODE_POM, - OPCODE_START,OPCODE_SETLOCO, + OPCODE_START,OPCODE_SETLOCO,OPCODE_SENDLOCO, OPCODE_PAUSE, OPCODE_RESUME, OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT, OPCODE_PRINT, diff --git a/RMFTMacros.h b/RMFTMacros.h index e3af537..652613a 100644 --- a/RMFTMacros.h +++ b/RMFTMacros.h @@ -88,6 +88,7 @@ #define RETURN #define REV(speed) #define START(route) +#define SENDLOCO(cab,route) #define SERVO(id,position,profile) #define SETLOCO(loco) #define SET(sensor_id) @@ -168,6 +169,7 @@ const int StringMacroTracker1=__COUNTER__; #undef START #undef SEQUENCE #undef SERVO +#undef SENDLOCO #undef SETLOCO #undef SET #undef SPEED @@ -226,6 +228,7 @@ const int StringMacroTracker1=__COUNTER__; #define RESUME OPCODE_RESUME,NOP, #define RETURN OPCODE_RETURN,NOP, #define REV(speed) OPCODE_REV,V(speed), +#define SENDLOCO(cab,route) OPCODE_START,V(cab),OPCODE_PAD,V(route), #define START(route) OPCODE_START,V(route), #define SERVO(id,position,profile) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::ProfileType::profile), #define SETLOCO(loco) OPCODE_SETLOCO,V(loco), diff --git a/myAutomation.example.h b/myAutomation.example.h index 7353821..9ba9e20 100644 --- a/myAutomation.example.h +++ b/myAutomation.example.h @@ -26,10 +26,8 @@ EXRAIL // myAutomation must start with the EXRAIL instruction // This is the default starting route, AKA SEQUENCE(0) - SETLOCO(3) // set current loco id... - START(1) // send current loco off along route 1 - SETLOCO(10) // set current loco id... - START(2) // send current loco off along route 2 + SENDLOCO(3,1) // send loco 3 off along route 1 + SENDLOCO(10,2) // send loco 10 off along route 2 DONE // This just ends the startup thread, leaving 2 others running. /* SEQUENCE(1) is a simple shuttle between 2 sensors