diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 56aeeb2..6f0420c 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -1066,7 +1066,7 @@ int16_t RMFT2::getSignalSlot(int16_t id) { if (diag) DIAG(F(" doSignal %d %x"),id,rag); // Schedule any event handler for this signal change. - // Thjis will work even without a signal definition. + // This will work even without a signal definition. if (rag==SIGNAL_RED) onRedLookup->handleEvent(F("RED"),id); else if (rag==SIGNAL_GREEN) onGreenLookup->handleEvent(F("GREEN"),id); else onAmberLookup->handleEvent(F("AMBER"),id); @@ -1103,6 +1103,16 @@ int16_t RMFT2::getSignalSlot(int16_t id) { return; } + if (sigtype== DCCX_SIGNAL_FLAG) { + // redpin,amberpin,greenpin are the 3 aspects + byte value=redpin; + if (rag==SIGNAL_AMBER) value=amberpin; + if (rag==SIGNAL_GREEN) value=greenpin; + DCC::setExtendedAccessory(sigid & SIGNAL_ID_MASK,value); + return; + } + + // LED or similar 3 pin signal, (all pins zero would be a virtual signal) // If amberpin is zero, synthesise amber from red+green const byte SIMAMBER=0x00; diff --git a/EXRAIL2.h b/EXRAIL2.h index e8235c6..eec2a06 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -158,6 +158,7 @@ class LookList { static const int16_t SERVO_SIGNAL_FLAG=0x4000; static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000; static const int16_t DCC_SIGNAL_FLAG=0x1000; + static const int16_t DCCX_SIGNAL_FLAG=0x3000; static const int16_t SIGNAL_ID_MASK=0x0FFF; // Throttle Info Access functions built by exrail macros static const byte rosterNameCount; diff --git a/EXRAIL2MacroReset.h b/EXRAIL2MacroReset.h index 633f4d5..723bef2 100644 --- a/EXRAIL2MacroReset.h +++ b/EXRAIL2MacroReset.h @@ -45,6 +45,7 @@ #undef CLOSE #undef CONFIGURE_SERVO #undef DCC_SIGNAL +#undef DCCX_SIGNAL #undef DCC_TURNTABLE #undef DEACTIVATE #undef DEACTIVATEL @@ -200,6 +201,7 @@ #define CLOSE(id) #define CONFIGURE_SERVO(vpin,pos1,pos2,profile) #define DCC_SIGNAL(id,add,subaddr) +#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) #define DCC_TURNTABLE(id,home,description) #define DEACTIVATE(addr,subaddr) #define DEACTIVATEL(addr) diff --git a/EXRAILMacros.h b/EXRAILMacros.h index 8d870ef..698451e 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -172,6 +172,8 @@ bool exrailHalSetup() { #define SERVO_SIGNAL(vpin,redval,amberval,greenval) | FEATURE_SIGNAL #undef DCC_SIGNAL #define DCC_SIGNAL(id,addr,subaddr) | FEATURE_SIGNAL +#undef DCCX_SIGNAL +#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) | FEATURE_SIGNAL #undef VIRTUAL_SIGNAL #define VIRTUAL_SIGNAL(id) | FEATURE_SIGNAL @@ -401,6 +403,8 @@ const FSH * RMFT2::getRosterFunctions(int16_t id) { #define SERVO_SIGNAL(vpin,redval,amberval,greenval) vpin | RMFT2::SERVO_SIGNAL_FLAG,redval,amberval,greenval, #undef DCC_SIGNAL #define DCC_SIGNAL(id,addr,subaddr) id | RMFT2::DCC_SIGNAL_FLAG,addr,subaddr,0, +#undef DCCX_SIGNAL +#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) id | RMFT2::DCCX_SIGNAL_FLAG,redAspect,amberAspect,greenAspect, #undef VIRTUAL_SIGNAL #define VIRTUAL_SIGNAL(id) id,0,0,0, @@ -457,6 +461,7 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup]; #define DELAYMINS(mindelay) OPCODE_DELAYMINS,V(mindelay), #define DELAYRANDOM(mindelay,maxdelay) DELAY(mindelay) OPCODE_RANDWAIT,V((maxdelay-mindelay)/100L), #define DCC_SIGNAL(id,add,subaddr) +#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) #define DONE OPCODE_ENDTASK,0,0, #define DRIVE(analogpin) OPCODE_DRIVE,V(analogpin), #define ELSE OPCODE_ELSE,0,0,