diff --git a/DCC.cpp b/DCC.cpp index e3dd921..79c5b19 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -239,6 +239,9 @@ void DCC::updateGroupflags(byte & flags, int16_t functionNumber) { } void DCC::setAccessory(int address, byte number, bool activate) { + #ifdef DIAG_IO + DIAG(F("DCC::setAccessory(%d,%d,%d)"), address, number, activate); + #endif // use masks to detect wrong values and do nothing if(address != (address & 511)) return; diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index e4b4d73..91039f7 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -27,6 +27,7 @@ #include "freeMemory.h" #include "GITHUB_SHA.h" #include "version.h" +#include "defines.h" #include "EEStore.h" #include "DIAG.h" @@ -364,8 +365,12 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream) || ((subaddress & 0x03) != subaddress) // invalid subaddress (limit 2 bits ) || ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1 ) break; - // TODO: Trigger configurable range of addresses on local VPins. + // Honour the configuration option (config.h) which allows the command to be reversed +#ifdef DCC_ACCESSORY_RCN_213 + DCC::setAccessory(address, subaddress,p[activep]==0); +#else DCC::setAccessory(address, subaddress,p[activep]==1); +#endif } return; diff --git a/config.example.h b/config.example.h index 6c5c69a..9b1855f 100644 --- a/config.example.h +++ b/config.example.h @@ -134,11 +134,17 @@ The configuration file for DCC-EX Command Station // // According to norm RCN-213 a DCC packet with a 1 is closed/straight // and one with a 0 is thrown/diverging. In DCC++ Classic, and in previous -// versions of DCC++EX, a throw command was implemented in the packet as +// versions of DCC++EX, a turnout throw command was implemented in the packet as // '1' and a close command as '0'. The #define below makes the states // match with the norm. But we don't want to cause havoc on existent layouts, // so we define this only for new installations. If you don't want this, // don't add it to your config.h. -#define DCC_TURNOUTS_RCN_213 +//#define DCC_TURNOUTS_RCN_213 + +// The following #define likewise inverts the behaviour of the command +// for triggering DCC Accessory Decoders, so that generates a +// DCC packet with D=1 (close turnout) and generates D=0 +// (throw turnout). +//#define DCC_ACCESSORY_RCN_213 /////////////////////////////////////////////////////////////////////////////////////