Skip to content

Commit

Permalink
MERG macris in exrail
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed May 30, 2024
1 parent 0c96d4f commit 0d07aa6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
9 changes: 9 additions & 0 deletions EXRAIL2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,13 @@ void RMFT2::loop2() {
if ((compileFeatures & FEATURE_LCC) && LCCSerial)
StringFormatter::send(LCCSerial,F("<L x%h>"),(uint16_t)operand);
break;

case OPCODE_MERGON: // MERG adapter
case OPCODE_MERGOFF:
if ((compileFeatures & FEATURE_LCC) && LCCSerial)
StringFormatter::send(LCCSerial,F("<L x%c%h>"),
opcode==OPCODE_MERGON?'1':'0',(uint16_t)operand);
break;

case OPCODE_LCCX: // long form LCC
if ((compileFeatures & FEATURE_LCC) && LCCSerial)
Expand Down Expand Up @@ -1088,6 +1095,8 @@ void RMFT2::loop2() {
case OPCODE_PINTURNOUT: // Turnout definition ignored at runtime
case OPCODE_ONCLOSE: // Turnout event catchers ignored here
case OPCODE_ONLCC: // LCC event catchers ignored here
case OPCODE_ONMERGON: // MERG event catchers ignored here
case OPCODE_ONMERGOFF: // MERG event catchers ignored here
case OPCODE_ONTHROW:
case OPCODE_ONACTIVATE: // Activate event catchers ignored here
case OPCODE_ONDEACTIVATE:
Expand Down
2 changes: 2 additions & 0 deletions EXRAIL2.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT,
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_WAITFORTT,
OPCODE_LCC,OPCODE_LCCX,OPCODE_ONLCC,
OPCODE_MERGON, OPCODE_MERGOFF,
OPCODE_ONMERGON, OPCODE_ONMERGOFF,
OPCODE_ONOVERLOAD,
OPCODE_ROUTE_ACTIVE,OPCODE_ROUTE_INACTIVE,OPCODE_ROUTE_HIDDEN,
OPCODE_ROUTE_DISABLED,
Expand Down
8 changes: 8 additions & 0 deletions EXRAIL2MacroReset.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
#undef LCCX
#undef LCN
#undef MOVETT
#undef MERGON
#undef MERGOFF
#undef ONMERGON
#undef ONMERGOFF
#undef MESSAGE
#undef ONACTIVATE
#undef ONACTIVATEL
Expand Down Expand Up @@ -265,6 +269,10 @@
#define LCN(msg)
#define MESSAGE(msg)
#define MOVETT(id,steps,activity)
#define MERGON(eventid)
#define MERGOFF(eventid)
#define ONMERGON(eventid)
#define ONMERGOFF(eventid)
#define ONACTIVATE(addr,subaddr)
#define ONACTIVATEL(linear)
#define ONAMBER(signal_id)
Expand Down
14 changes: 13 additions & 1 deletion EXRAIL2Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16
getOperand(progCounter,3),
getOperand(progCounter,0)
);
}}
}
if (opcode==OPCODE_MERGON) StringFormatter::send(stream,F("<LS x1%h>\n"),getOperand(progCounter,0));
if (opcode==OPCODE_MERGOFF) StringFormatter::send(stream,F("<LS x0%h>\n"),getOperand(progCounter,0));
}

// we stream the hex events we wish to listen to
// and at the same time build the event index looku.
Expand All @@ -98,6 +101,15 @@ void RMFT2::ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16
);
eventIndex++;
}
if (opcode==OPCODE_ONMERGON || opcode==OPCODE_ONMERGOFF) {
onLCCLookup[eventIndex]=progCounter; // TODO skip...
StringFormatter::send(stream,F("<LL %d x%c%h>\n"),
eventIndex,
opcode==OPCODE_ONMERGON?'1':'0',
getOperand(progCounter,0)
);
eventIndex++;
}
}
StringFormatter::send(stream,F("<LR>\n")); // Ready to rumble
opcode=0;
Expand Down
14 changes: 13 additions & 1 deletion EXRAILMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ bool exrailHalSetup() {
#define LCCX(senderid,eventid) | FEATURE_LCC
#undef ONLCC
#define ONLCC(senderid,eventid) | FEATURE_LCC
#undef ONMERGON
#define ONMERGON(eventid) | FEATURE_LCC
#undef ONMERGOFF
#define ONMERGOFF(eventid) | FEATURE_LCC
#undef ROUTE_ACTIVE
#define ROUTE_ACTIVE(id) | FEATURE_ROUTESTATE
#undef ROUTE_INACTIVE
Expand Down Expand Up @@ -429,10 +433,14 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
#include "myAutomation.h"
0,0,0,0 };

// Pass 9 ONLCC counter and lookup array
// Pass 9 ONLCC/ ONMERG counter and lookup array
#include "EXRAIL2MacroReset.h"
#undef ONLCC
#define ONLCC(sender,event) +1
#undef ONMERGON
#define ONMERGON(event) +1
#undef ONMERGOFF
#define ONMERGOFF(event) +1

const int RMFT2::countLCCLookup=0
#include "myAutomation.h"
Expand Down Expand Up @@ -529,6 +537,10 @@ int RMFT2::onLCCLookup[RMFT2::countLCCLookup];
OPCODE_PAD,V((((uint64_t)sender)>>32)&0xFFFF),\
OPCODE_PAD,V((((uint64_t)sender)>>16)&0xFFFF),\
OPCODE_PAD,V((((uint64_t)sender)>>0)&0xFFFF),
#define MERGON(eventid) OPCODE_MERGON,V(eventid),
#define MERGOFF(eventid) OPCODE_MERGOFF,V(eventid),
#define ONMERGON(eventid) OPCODE_ONMERGON,V(eventid),
#define ONMERGOFF(eventid) OPCODE_ONMERGOFF,V(eventid),
#define LCD(id,msg) PRINT(msg)
#define SCREEN(display,id,msg) PRINT(msg)
#define STEALTH(code...) PRINT(dummy)
Expand Down

0 comments on commit 0d07aa6

Please sign in to comment.