diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 41e749c..b2ac320 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -174,9 +174,6 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { onCloseLookup=LookListLoader(OPCODE_ONCLOSE); onActivateLookup=LookListLoader(OPCODE_ONACTIVATE); onDeactivateLookup=LookListLoader(OPCODE_ONDEACTIVATE); - onRedLookup=LookListLoader(OPCODE_ONRED); - onAmberLookup=LookListLoader(OPCODE_ONAMBER); - onGreenLookup=LookListLoader(OPCODE_ONGREEN); onChangeLookup=LookListLoader(OPCODE_ONCHANGE); onClockLookup=LookListLoader(OPCODE_ONTIME); onOverloadLookup=LookListLoader(OPCODE_ONOVERLOAD); @@ -184,12 +181,18 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) { // Second pass startup, define any turnouts or servos, set signals red // add sequences onRoutines to the lookups - for (int sigslot=0;;sigslot++) { - VPIN sigid=GETHIGHFLASHW(RMFT2::SignalDefinitions,sigslot*8); - if (sigid==0) break; // end of signal list - doSignal(sigid & SIGNAL_ID_MASK, SIGNAL_RED); + if (compileFeatures & FEATURE_SIGNAL) { + onRedLookup=LookListLoader(OPCODE_ONRED); + onAmberLookup=LookListLoader(OPCODE_ONAMBER); + onGreenLookup=LookListLoader(OPCODE_ONGREEN); + for (int sigslot=0;;sigslot++) { + VPIN sigid=GETHIGHFLASHW(RMFT2::SignalDefinitions,sigslot*8); + if (sigid==0) break; // end of signal list + doSignal(sigid & SIGNAL_ID_MASK, SIGNAL_RED); + } } + int progCounter; for (progCounter=0;; SKIPOP){ byte opcode=GET_OPCODE; @@ -305,6 +308,8 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16 break; case 'L': + if (compileFeatures & FEATURE_LCC) { + // This entire code block is compiled out if LLC macros not used if (paramCount==0) { // LCC adapter introducing self LCCSerial=stream; // now we know where to send events we raise @@ -352,6 +357,7 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16 if (!reject) startNonRecursiveTask(F("LCC"),eventid,onLCCLookup[eventid]); opcode=0; } + } break; default: // other commands pass through @@ -387,17 +393,19 @@ bool RMFT2::parseSlash(Print * stream, byte & paramCount, int16_t p[]) { if (flag & LATCH_FLAG) StringFormatter::send(stream,F(" LATCHED")); } } - // do the signals - // flags[n] represents the state of the nth signal in the table - for (int sigslot=0;;sigslot++) { - VPIN sigid=GETHIGHFLASHW(RMFT2::SignalDefinitions,sigslot*8); - if (sigid==0) break; // end of signal list - byte flag=flags[sigslot] & SIGNAL_MASK; // obtain signal flags for this id - StringFormatter::send(stream,F("\n%S[%d]"), - (flag == SIGNAL_RED)? F("RED") : (flag==SIGNAL_GREEN) ? F("GREEN") : F("AMBER"), - sigid & SIGNAL_ID_MASK); - } - + + if (compileFeatures & FEATURE_SIGNAL) { + // do the signals + // flags[n] represents the state of the nth signal in the table + for (int sigslot=0;;sigslot++) { + VPIN sigid=GETHIGHFLASHW(RMFT2::SignalDefinitions,sigslot*8); + if (sigid==0) break; // end of signal list + byte flag=flags[sigslot] & SIGNAL_MASK; // obtain signal flags for this id + StringFormatter::send(stream,F("\n%S[%d]"), + (flag == SIGNAL_RED)? F("RED") : (flag==SIGNAL_GREEN) ? F("GREEN") : F("AMBER"), + sigid & SIGNAL_ID_MASK); + } + } StringFormatter::send(stream,F(" *>\n")); return true; } @@ -1018,11 +1026,12 @@ void RMFT2::loop2() { break; case OPCODE_LCC: // short form LCC - if (LCCSerial) StringFormatter::send(LCCSerial,F(""),(uint16_t)operand); + if ((compileFeatures & FEATURE_LCC) && LCCSerial) + StringFormatter::send(LCCSerial,F(""),(uint16_t)operand); break; case OPCODE_LCCX: // long form LCC - if (LCCSerial) + if ((compileFeatures & FEATURE_LCC) && LCCSerial) StringFormatter::send(LCCSerial,F("\n"), getOperand(progCounter,1), getOperand(progCounter,2), @@ -1122,6 +1131,7 @@ int16_t RMFT2::getSignalSlot(int16_t id) { } /* static */ void RMFT2::doSignal(int16_t id,char rag) { + if (!(compileFeatures & FEATURE_SIGNAL)) return; // dont compile code below if (diag) DIAG(F(" doSignal %d %x"),id,rag); // Schedule any event handler for this signal change. @@ -1189,6 +1199,7 @@ int16_t RMFT2::getSignalSlot(int16_t id) { } /* static */ bool RMFT2::isSignal(int16_t id,char rag) { + if (!(compileFeatures & FEATURE_LCC)) return false; int16_t sigslot=getSignalSlot(id); if (sigslot<0) return false; return (flags[sigslot] & SIGNAL_MASK) == rag; diff --git a/EXRAIL2.h b/EXRAIL2.h index bc1839f..951826c 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -91,7 +91,10 @@ enum thrunger: byte { thrunge_lcd, // Must be last!! }; - + // Flag bits for compile time feature + static const byte FEATURE_SIGNAL= 0x80; + static const byte FEATURE_LCC = 0x40; + // Flag bits for status of hardware and TPL static const byte SECTION_FLAG = 0x80; @@ -198,6 +201,7 @@ private: static const int countLCCLookup; static int onLCCLookup[]; + static const byte compileFeatures; // Local variables - exist for each instance/task RMFT2 *next; // loop chain diff --git a/EXRAILMacros.h b/EXRAILMacros.h index ced0725..0e28560 100644 --- a/EXRAILMacros.h +++ b/EXRAILMacros.h @@ -75,6 +75,30 @@ void exrailHalSetup() { #include "myAutomation.h" } +// Pass 1c detect compile time featurtes +#include "EXRAIL2MacroReset.h" +#undef SIGNAL +#define SIGNAL(redpin,amberpin,greenpin) | FEATURE_SIGNAL +#undef SIGNALH +#define SIGNALH(redpin,amberpin,greenpin) | FEATURE_SIGNAL +#undef SERVO_SIGNAL +#define SERVO_SIGNAL(vpin,redval,amberval,greenval) | FEATURE_SIGNAL +#undef DCC_SIGNAL +#define DCC_SIGNAL(id,addr,subaddr) | FEATURE_SIGNAL +#undef VIRTUAL_SIGNAL +#define VIRTUAL_SIGNAL(id) | FEATURE_SIGNAL + +#undef LCC +#define LCC(eventid) | FEATURE_LCC +#undef LCCX +#define LCCX(senderid,eventid) | FEATURE_LCC +#undef ONLCC +#define ONLCC(senderid,eventid) | FEATURE_LCC + +const byte RMFT2::compileFeatures = 0 + #include "myAutomation.h" +; + // Pass 2 create throttle route list #include "EXRAIL2MacroReset.h" #undef ROUTE