From 269e1b36ea793344dca9793abebe480b44efbf06 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 21 Mar 2022 16:29:35 +0000 Subject: [PATCH] Automatic ALIAS(name) and _ in keywords --- DCCEXParser.cpp | 2 +- EXRAIL2MacroReset.h | 2 +- EXRAILMacros.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index f84c123..11a2796 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -145,7 +145,7 @@ int16_t DCCEXParser::splitValues(int16_t result[MAX_COMMAND_PARAMS], const byte runningValue = 16 * runningValue + (hot - 'A' + 10); break; } - if (hot >= 'A' && hot <= 'Z') + if (hot=='_' || (hot >= 'A' && hot <= 'Z')) { // Since JMRI got modified to send keywords in some rare cases, we need this // Super Kluge to turn keywords into a hash value that can be recognised later diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 4456679..7c6bcc9 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -121,7 +121,7 @@ #define ACTIVATE(addr,subaddr) #define ACTIVATEL(addr) #define AFTER(sensor_id) -#define ALIAS(name,value) +#define ALIAS(name,value...) #define AMBER(signal_id) #define AT(sensor_id) #define ATGTE(sensor_id,value) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 1f143f0..e3b0217 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -52,7 +52,7 @@ // Pass 1 Implements aliases #include "EXRAIL2MacroReset.h" #undef ALIAS -#define ALIAS(name,value) const int name=value; +#define ALIAS(name,value...) const int name= 1##value##0 ==10 ? -__COUNTER__ : value##0/10; #include "myAutomation.h" // Pass 2 convert descriptions to withrottle format emitter function @@ -170,7 +170,7 @@ const FLASH int16_t RMFT2::SignalDefinitions[] = { #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 ALIAS(name,value) +#define ALIAS(name,value...) #define AMBER(signal_id) OPCODE_AMBER,V(signal_id), #define AT(sensor_id) OPCODE_AT,V(sensor_id), #define ATGTE(sensor_id,value) OPCODE_ATGTE,V(sensor_id),OPCODE_PAD,V(value),