From 96c4757cc633f807e618f6b66c07ea5c8e815cf8 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Wed, 10 Jul 2024 10:58:22 +0100 Subject: [PATCH] EXTAIL AFTER debounce time --- EXRAIL2.cpp | 8 +++++--- EXRAIL2MacroReset.h | 2 +- EXRAILMacros.h | 2 +- version.h | 5 ++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 676d31c..1a7f888 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -628,14 +628,16 @@ void RMFT2::loop2() { skipIf=blinkState!=at_timeout; break; - case OPCODE_AFTER: // waits for sensor to hit and then remain off for 0.5 seconds. (must come after an AT operation) + case OPCODE_AFTER: // waits for sensor to hit and then remain off for x mS. + // Note, this must come after an AT operation, which is + // automatically inserted by the AFTER macro. if (readSensor(operand)) { - // reset timer to half a second and keep waiting + // reset timer and keep waiting waitAfter=millis(); delayMe(50); return; } - if (millis()-waitAfter < 500 ) return; + if (millis()-waitAfter < getOperand(1) ) return; break; case OPCODE_AFTEROVERLOAD: // waits for the power to be turned back on - either by power routine or button diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 309a27c..8f2845c 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -195,7 +195,7 @@ #ifndef RMFT2_UNDEF_ONLY #define ACTIVATE(addr,subaddr) #define ACTIVATEL(addr) -#define AFTER(sensor_id) +#define AFTER(sensor_id,timer...) #define AFTEROVERLOAD(track_id) #define ALIAS(name,value...) #define AMBER(signal_id) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index ebea75e..edc1088 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -463,7 +463,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #define ACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1 | 1), #define ACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<1 | 1), -#define AFTER(sensor_id) OPCODE_AT,V(sensor_id),OPCODE_AFTER,V(sensor_id), +#define AFTER(sensor_id,timer...) OPCODE_AT,V(sensor_id),OPCODE_AFTER,V(sensor_id),OPCODE_PAD,V(#timer[0]?timer+0:500), #define AFTEROVERLOAD(track_id) OPCODE_AFTEROVERLOAD,V(TRACK_NUMBER_##track_id), #define ALIAS(name,value...) #define AMBER(signal_id) OPCODE_AMBER,V(signal_id), diff --git a/version.h b/version.h index 7fb4fb5..8bd3d5b 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,10 @@ #include "StringFormatter.h" -#define VERSION "5.2.66" +#define VERSION "5.2.67" +// 5.2.67 - EXRAIL AFTER optional debounce time variable (default 500mS) +// - AFTER(42) == AFTER(42,500) sets time sensor must +// - be continuously off. // 5.2.66 - // - EXRAIL SETFREQ drop loco param (breaking since 5.2.28) // 5.2.65 - Speedup Exrail SETFREQ