diff --git a/RMFT2.cpp b/RMFT2.cpp index 681ec7c..57a6057 100644 --- a/RMFT2.cpp +++ b/RMFT2.cpp @@ -217,6 +217,11 @@ LookList * RMFT2::onCloseLookup=NULL; onCloseLookup->add(operand,progCounter); break; + case OPCODE_AUTOSTART: + // automatically create a task from here at startup. + new RMFT2(progCounter); + break; + default: // Ignore break; } @@ -769,6 +774,7 @@ void RMFT2::loop2() { if (diag) DIAG(F("EXRAIL begin(%d)"),operand); break; + case OPCODE_AUTOSTART: // Handled only during begin process case OPCODE_PAD: // Just a padding for previous opcode needing >1 operad byte. case OPCODE_SIGNAL: // Signal definition ignore at run time case OPCODE_TURNOUT: // Turnout definition ignored at runtime diff --git a/RMFT2.h b/RMFT2.h index 4194fb9..32594c1 100644 --- a/RMFT2.h +++ b/RMFT2.h @@ -30,7 +30,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_FWD,OPCODE_REV,OPCODE_SPEED,OPCODE_INVERT_DIRECTION, OPCODE_RESERVE,OPCODE_FREE, - OPCODE_AT,OPCODE_AFTER, + OPCODE_AT,OPCODE_AFTER,OPCODE_AUTOSTART, OPCODE_LATCH,OPCODE_UNLATCH,OPCODE_SET,OPCODE_RESET, OPCODE_IF,OPCODE_IFNOT,OPCODE_ENDIF,OPCODE_IFRANDOM,OPCODE_IFRESERVE, OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_RANDWAIT, diff --git a/RMFTMacros.h b/RMFTMacros.h index 01bfb46..2ea5732 100644 --- a/RMFTMacros.h +++ b/RMFTMacros.h @@ -60,6 +60,7 @@ #define AFTER(sensor_id) #define AMBER(signal_id) #define AT(sensor_id) +#define AUTOSTART #define CALL(route) #define CLOSE(id) #define DELAY(mindelay) @@ -158,7 +159,8 @@ const int StringMacroTracker1=__COUNTER__; #undef AFTER #undef AMBER #undef AT -#undef AUTOMATION +#undef AUTOMATION +#undef AUTOSTART #undef CALL #undef CLOSE #undef DELAY @@ -240,6 +242,7 @@ const int StringMacroTracker1=__COUNTER__; #define AFTER(sensor_id) OPCODE_AT,V(sensor_id),OPCODE_AFTER,V(sensor_id), #define AMBER(signal_id) OPCODE_AMBER,V(signal_id), #define AT(sensor_id) OPCODE_AT,V(sensor_id), +#define AUTOSTART OPCODE_AUTOSTART,NOP, #define CALL(route) OPCODE_CALL,V(route), #define CLOSE(id) OPCODE_CLOSE,V(id), #define DELAY(ms) OPCODE_DELAY,V(ms/100L),