diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index c9c6716..b39adff 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -815,6 +815,10 @@ void RMFT2::loop2() { case OPCODE_FOFF: if (loco) DCC::setFn(loco,operand,false); break; + + case OPCODE_FTOGGLE: + if (loco) DCC::changeFn(loco,operand); + break; case OPCODE_DRIVE: { @@ -830,6 +834,10 @@ void RMFT2::loop2() { case OPCODE_XFOFF: DCC::setFn(operand,getOperand(1),false); break; + + case OPCODE_XFTOGGLE: + DCC::changeFn(operand,getOperand(1)); + break; case OPCODE_DCCACTIVATE: { // operand is address<<3 | subaddr<<1 | active diff --git a/EXRAIL2.h b/EXRAIL2.h index f4cf320..707bfae 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -44,6 +44,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_ENDIF,OPCODE_ELSE, OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_DELAYMS,OPCODE_RANDWAIT, OPCODE_FON,OPCODE_FOFF,OPCODE_XFON,OPCODE_XFOFF, + OPCODE_FTOGGLE,OPCODE_XFTOGGLE, OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,OPCODE_DRIVE, OPCODE_SERVO,OPCODE_SIGNAL,OPCODE_TURNOUT,OPCODE_WAITFOR, OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN, diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 340bc64..187c4ca 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -66,6 +66,7 @@ #undef FOLLOW #undef FON #undef FORGET +#undef FTOGGLE #undef FREE #undef FWD #undef GREEN @@ -181,6 +182,7 @@ #undef WITHROTTLE #undef XFOFF #undef XFON +#undef XFTOGGLE #ifndef RMFT2_UNDEF_ONLY #define ACTIVATE(addr,subaddr) @@ -226,6 +228,7 @@ #define FON(func) #define FORGET #define FREE(blockid) +#define FTOGGLE(func) #define FWD(speed) #define GREEN(signal_id) #define HAL(haltype,params...) @@ -340,4 +343,6 @@ #define WITHROTTLE(msg) #define XFOFF(cab,func) #define XFON(cab,func) +#define XFTOGGLE(cab,func) + #endif diff --git a/EXRAIL2Parser.cpp b/EXRAIL2Parser.cpp index 7969750..2cbdd10 100644 --- a/EXRAIL2Parser.cpp +++ b/EXRAIL2Parser.cpp @@ -36,7 +36,7 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]) { (void)stream; // avoid compiler warning if we don't access this parameter - bool reject=false; + switch(opcode) { case 'D': @@ -47,8 +47,7 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16 break; case '/': // New EXRAIL command - reject=!parseSlash(stream,paramCount,p); - opcode=0; + if (parseSlash(stream,paramCount,p)) opcode=0; break; case 'A': // @@ -106,9 +105,11 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16 } if (paramCount==1) { // LCC event arrived from adapter int16_t eventid=p[0]; - reject=eventid<0 || eventid>=countLCCLookup; - if (!reject) startNonRecursiveTask(F("LCC"),eventid,onLCCLookup[eventid]); - opcode=0; + bool reject = eventid<0 || eventid>=countLCCLookup; + if (!reject) { + startNonRecursiveTask(F("LCC"),eventid,onLCCLookup[eventid]); + opcode=0; + } } break; diff --git a/EXRAILMacros.h b/EXRAILMacros.h index c5ebbba..0f4b3a8 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -490,6 +490,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #define FON(func) OPCODE_FON,V(func), #define FORGET OPCODE_FORGET,0,0, #define FREE(blockid) OPCODE_FREE,V(blockid), +#define FTOGGLE(func) OPCODE_FTOGGLE,V(func), #define FWD(speed) OPCODE_FWD,V(speed), #define GREEN(signal_id) OPCODE_GREEN,V(signal_id), #define HAL(haltype,params...) @@ -618,6 +619,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #endif #define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func), #define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func), +#define XFTOGGLE(cab,func) OPCODE_XFTOGGLE,V(cab),OPCODE_PAD,V(func), // Build RouteCode const int StringMacroTracker2=__COUNTER__;