From b5491f9b522d711370b03c2d49b46ab3b74be824 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 9 Jan 2025 20:40:07 +0100 Subject: [PATCH] EXRAIL additions XFWD() and XREV() --- EXRAIL.h | 20 ++++++++++++++++++++ EXRAIL2.cpp | 9 +++++++++ EXRAIL2.h | 3 ++- EXRAIL2MacroReset.h | 5 +++++ EXRAILMacros.h | 3 +++ 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/EXRAIL.h b/EXRAIL.h index 575ab05..2fc41d8 100644 --- a/EXRAIL.h +++ b/EXRAIL.h @@ -1,3 +1,23 @@ +/* + * © 2021 Fred Decker + * All rights reserved. + * + * This file is part of CommandStation-EX + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * It is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with CommandStation. If not, see . + */ + #ifndef EXRAIL_H #define EXRAIL_H diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index ac1c453..7e92edf 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -4,6 +4,7 @@ * © 2021-2023 Harald Barth * © 2020-2023 Chris Harlow * © 2022-2023 Colin Murdoch + * © 2025 Morten Nielsen * All rights reserved. * * This file is part of CommandStation-EX @@ -871,6 +872,14 @@ void RMFT2::loop2() { DCC::changeFn(operand,getOperand(1)); break; + case OPCODE_XFWD: + DCC::setThrottle(operand,getOperand(1), true); + break; + + case OPCODE_XREV: + DCC::setThrottle(operand,getOperand(1), false); + break; + case OPCODE_DCCACTIVATE: { // operand is address<<3 | subaddr<<1 | active int16_t addr=operand>>3; diff --git a/EXRAIL2.h b/EXRAIL2.h index ff45a69..5b95f8e 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -3,6 +3,7 @@ * © 2020-2022 Chris Harlow * © 2022-2023 Colin Murdoch * © 2023 Harald Barth + * © 2025 Morten Nielsen * All rights reserved. * * This file is part of CommandStation-EX @@ -45,7 +46,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT, 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_FTOGGLE,OPCODE_XFTOGGLE,OPCODE_XFWD,OPCODE_XREV, 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 82272a9..6b6db29 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -2,6 +2,7 @@ * © 2020-2022 Chris Harlow. All rights reserved. * © 2022-2023 Colin Murdoch * © 2023 Harald Barth + * © 2025 Morten Nielsen * * This file is part of CommandStation-EX * @@ -194,6 +195,8 @@ #undef XFOFF #undef XFON #undef XFTOGGLE +#undef XREV +#undef XFWD #ifndef RMFT2_UNDEF_ONLY #define ACTIVATE(addr,subaddr) @@ -365,5 +368,7 @@ #define XFOFF(cab,func) #define XFON(cab,func) #define XFTOGGLE(cab,func) +#define XFWD(cab,speed) +#define XREV(cab,speed) #endif diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 59accdb..d0f640a 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -3,6 +3,7 @@ * © 2020-2022 Chris Harlow * © 2022-2023 Colin Murdoch * © 2023 Harald Barth + * © 2025 Morten Nielsen * All rights reserved. * * This file is part of CommandStation-EX @@ -665,6 +666,8 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #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), +#define XFWD(cab,speed) OPCODE_XFWD,V(cab),OPCODE_PAD,V(speed), +#define XREV(cab,speed) OPCODE_XREV,V(cab),OPCODE_PAD,V(speed), // Build RouteCode const int StringMacroTracker2=__COUNTER__;