From 0237c9721ffd4138ef137add3a17b8c658fa36a5 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 30 Nov 2021 13:52:22 +0000 Subject: [PATCH] Chgange IFANALOG to IFGTE/IFLT --- RMFT2.cpp | 11 ++++++++--- RMFT2.h | 2 +- RMFT2MacroReset.h | 6 ++++-- RMFTMacros.h | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/RMFT2.cpp b/RMFT2.cpp index 0b6e0dd..efbbf55 100644 --- a/RMFT2.cpp +++ b/RMFT2.cpp @@ -30,7 +30,7 @@ F10. [DONE] Alias anywhere F11. [DONE]EXRAIL/ENDEXRAIL unnecessary F12. [DONE] Allow guarded code (as effect of ALIAS anywhere) - F13. [DONE] IFANALOG function + F13. [DONE] IFGTE/IFLT function */ /* EXRAILPlus planned TRANSPARENT additions T1. [DONE] RAM based fast lookup for sequences ON* event catchers and signals. @@ -499,7 +499,8 @@ bool RMFT2::skipIfBlock() { kill(F("missing ENDIF"), nest); return false; case OPCODE_IF: - case OPCODE_IFANALOG: + case OPCODE_IFGTE: + case OPCODE_IFLT: case OPCODE_IFNOT: case OPCODE_IFRANDOM: case OPCODE_IFRESERVE: @@ -638,9 +639,13 @@ void RMFT2::loop2() { if (!readSensor(operand)) if (!skipIfBlock()) return; break; - case OPCODE_IFANALOG: // do next operand if sensor>= value + case OPCODE_IFGTE: // do next operand if sensor>= value if (IODevice::readAnalogue(operand)<(int)(GET_OPERAND(1))) if (!skipIfBlock()) return; break; + + case OPCODE_IFLT: // do next operand if sensor< value + if (IODevice::readAnalogue(operand)>=(int)(GET_OPERAND(1))) if (!skipIfBlock()) return; + break; case OPCODE_IFNOT: // do next operand if sensor not set if (readSensor(operand)) if (!skipIfBlock()) return; diff --git a/RMFT2.h b/RMFT2.h index 441a588..cd6ed16 100644 --- a/RMFT2.h +++ b/RMFT2.h @@ -43,7 +43,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE, OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF, OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT, OPCODE_PRINT,OPCODE_DCCACTIVATE, - OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFANALOG, + OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,OPCODE_IFGTE,OPCODE_IFLT, OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL }; diff --git a/RMFT2MacroReset.h b/RMFT2MacroReset.h index 2034e8c..d255844 100644 --- a/RMFT2MacroReset.h +++ b/RMFT2MacroReset.h @@ -52,7 +52,8 @@ #undef FWD #undef GREEN #undef IF -#undef IFANALOG +#undef IFGTE +#undef IFLT #undef IFNOT #undef IFRANDOM #undef IFRESERVE @@ -134,7 +135,8 @@ #define FWD(speed) #define GREEN(signal_id) #define IF(sensor_id) -#define IFANALOG(sensor_id,value) +#define IFGTE(sensor_id,value) +#define IFLT(sensor_id,value) #define IFNOT(sensor_id) #define IFRANDOM(percent) #define IFRESERVE(block) diff --git a/RMFTMacros.h b/RMFTMacros.h index 5082505..25e6208 100644 --- a/RMFTMacros.h +++ b/RMFTMacros.h @@ -152,7 +152,8 @@ void RMFT2::emitTurnoutDescription(Print* stream,int16_t turnoutid) { #define FWD(speed) OPCODE_FWD,V(speed), #define GREEN(signal_id) OPCODE_GREEN,V(signal_id), #define IF(sensor_id) OPCODE_IF,V(sensor_id), -#define IFANALOG(sensor_id,value) OPCODE_IFANALOG,V(sensor_id),OPCODE_PAD,V(value), +#define IFGTE(sensor_id,value) OPCODE_IFGTE,V(sensor_id),OPCODE_PAD,V(value), +#define IFLT(sensor_id,value) OPCODE_IFLT,V(sensor_id),OPCODE_PAD,V(value), #define IFNOT(sensor_id) OPCODE_IFNOT,V(sensor_id), #define IFRANDOM(percent) OPCODE_IFRANDOM,V(percent), #define IFRESERVE(block) OPCODE_IFRESERVE,V(block),