diff --git a/DCCEXParser.cpp b/DCCEXParser.cpp index ed1f684..a412531 100644 --- a/DCCEXParser.cpp +++ b/DCCEXParser.cpp @@ -368,7 +368,7 @@ void DCCEXParser::parse(Print *stream, byte *com, RingStream * ringStream) || ((p[activep] & 0x01) != p[activep]) // invalid activate 0|1 ) break; // Honour the configuration option (config.h) which allows the command to be reversed -#ifdef DCC_ACCESSORY_RCN_213 +#ifdef DCC_ACCESSORY_COMMAND_REVERSE DCC::setAccessory(address, subaddress,p[activep]==0); #else DCC::setAccessory(address, subaddress,p[activep]==1); diff --git a/IO_DCCAccessory.cpp b/IO_DCCAccessory.cpp index e40198b..6e739cd 100644 --- a/IO_DCCAccessory.cpp +++ b/IO_DCCAccessory.cpp @@ -47,11 +47,15 @@ void DCCAccessoryDecoder::_begin() { // Device-specific write function. State 1=closed, 0=thrown. Adjust for RCN-213 compliance void DCCAccessoryDecoder::_write(VPIN id, int state) { int packedAddress = _packedAddress + id - _firstVpin; - #ifdef DIAG_IO - DIAG(F("DCC Write Linear Address:%d State:%d"), packedAddress, state); - #endif -#if !defined(DCC_ACCESSORY_RCN_213) +#if defined(HAL_ACCESSORY_COMMAND_REVERSE) state = !state; +#ifdef DIAG_IO + DIAG(F("DCC Write Linear Address:%d State:%d (inverted)"), packedAddress, state); +#endif +#else +#ifdef DIAG_IO + DIAG(F("DCC Write Linear Address:%d State:%d"), packedAddress, state); +#endif #endif DCC::setAccessory(ADDRESS(packedAddress), SUBADDRESS(packedAddress), state); } diff --git a/config.example.h b/config.example.h index 5f26ca7..c948c53 100644 --- a/config.example.h +++ b/config.example.h @@ -141,10 +141,20 @@ The configuration file for DCC-EX Command Station // don't add it to your config.h. //#define DCC_TURNOUTS_RCN_213 -// The following #define likewise inverts the behaviour of the command -// for triggering DCC Accessory Decoders, so that generates a +// By default, the driver which defines a DCC accessory decoder +// does send out the same state change on the DCC packet as it +// receives. This means a VPIN state=1 sends D=1 (close turnout +// or signal green) in the DCC packet. This can be reversed if +// necessary. +//#define HAL_ACCESSORY_COMMAND_REVERSE + +// If you have issues with that the direction of the accessory commands is +// reversed (for example when converting from another CS to DCC-EX) then +// you can use this to revese the sense of all accessory commmands sent +// over DCC++. This #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 +//#define DCC_ACCESSORY_COMMAND_REVERSE /////////////////////////////////////////////////////////////////////////////////////