From 72ef199315d1c7717331864abb11730890fd3162 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Thu, 4 Apr 2024 09:06:50 +0100 Subject: [PATCH] TOGGLE_TURNOUT --- EXRAIL2.cpp | 4 ++++ EXRAIL2.h | 2 +- EXRAIL2MacroReset.h | 2 ++ EXRAILMacros.h | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 55d922e..ef4387c 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -528,6 +528,10 @@ void RMFT2::loop2() { Turnout::setClosed(operand, true); break; + case OPCODE_TOGGLE_TURNOUT: + Turnout::setClosed(operand, Turnout::isThrown(operand)); + break; + #ifndef IO_NO_HAL case OPCODE_ROTATE: uint8_t activity; diff --git a/EXRAIL2.h b/EXRAIL2.h index c116be9..7075f26 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -33,7 +33,7 @@ // or more OPCODE_PAD instructions with the subsequent parameters. This wastes a byte but makes // searching easier as a parameter can never be confused with an opcode. // -enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, +enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT, OPCODE_FWD,OPCODE_REV,OPCODE_SPEED,OPCODE_INVERT_DIRECTION, OPCODE_RESERVE,OPCODE_FREE, OPCODE_AT,OPCODE_AFTER, diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 7f3c88a..ce242ea 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -169,6 +169,7 @@ #undef STEALTH_GLOBAL #undef STOP #undef THROW +#undef TOGGLE_TURNOUT #undef TT_ADDPOSITION #undef TURNOUT #undef TURNOUTL @@ -331,6 +332,7 @@ #define STEALTH_GLOBAL(code...) #define STOP #define THROW(id) +#define TOGGLE_TURNOUT(id) #define TT_ADDPOSITION(turntable_id,position,value,angle,description...) #define TURNOUT(id,addr,subaddr,description...) #define TURNOUTL(id,addr,description...) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 10b0eb6..7db52dc 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -606,6 +606,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #define STASH(id) OPCODE_STASH,V(id), #define STOP OPCODE_SPEED,V(0), #define THROW(id) OPCODE_THROW,V(id), +#define TOGGLE_TURNOUT(id) OPCODE_TOGGLE_TURNOUT,V(id), #ifndef IO_NO_HAL #define TT_ADDPOSITION(id,position,value,angle,description...) OPCODE_TTADDPOSITION,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(value),OPCODE_PAD,V(angle), #endif