mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 13:21:01 +01:00
PRINT command
This commit is contained in:
parent
b06db69b53
commit
a93f88d3b7
17
RMFT2.cpp
17
RMFT2.cpp
@ -570,7 +570,11 @@ void RMFT2::loop2() {
|
|||||||
case OPCODE_SERVO: // OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(profile),
|
case OPCODE_SERVO: // OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(profile),
|
||||||
IODevice::writeAnalogue(operand,GET_OPERAND(1),GET_OPERAND(2));
|
IODevice::writeAnalogue(operand,GET_OPERAND(1),GET_OPERAND(2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPCODE_PRINT:
|
||||||
|
printMessage(operand);
|
||||||
|
break;
|
||||||
|
|
||||||
case OPCODE_ROUTE:
|
case OPCODE_ROUTE:
|
||||||
case OPCODE_AUTOMATION:
|
case OPCODE_AUTOMATION:
|
||||||
case OPCODE_SEQUENCE:
|
case OPCODE_SEQUENCE:
|
||||||
@ -632,8 +636,8 @@ void RMFT2::kill(const FSH * reason, int operand) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void RMFT2::turnoutEvent(VPIN id, bool thrown) {
|
void RMFT2::turnoutEvent(VPIN id, bool state) {
|
||||||
byte huntFor=thrown? OPCODE_ONTHROW : OPCODE_ONCLOSE;
|
byte huntFor=state ? OPCODE_ONCLOSE : OPCODE_ONTHROW ;
|
||||||
// caution hides class progCounter;
|
// caution hides class progCounter;
|
||||||
for (int progCounter=0;; SKIPOP){
|
for (int progCounter=0;; SKIPOP){
|
||||||
byte opcode=GET_OPCODE;
|
byte opcode=GET_OPCODE;
|
||||||
@ -643,4 +647,9 @@ void RMFT2::kill(const FSH * reason, int operand) {
|
|||||||
new RMFT2(progCounter); // new task starts at this instruction
|
new RMFT2(progCounter); // new task starts at this instruction
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RMFT2::printMessage2(const FSH * msg) {
|
||||||
|
DIAG(F("EXRAIL(%d) %S"),loco,msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
5
RMFT2.h
5
RMFT2.h
@ -41,7 +41,8 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
|||||||
OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,OPCODE_POM,
|
OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,OPCODE_POM,
|
||||||
OPCODE_START,OPCODE_SETLOCO,
|
OPCODE_START,OPCODE_SETLOCO,
|
||||||
OPCODE_PAUSE, OPCODE_RESUME,
|
OPCODE_PAUSE, OPCODE_RESUME,
|
||||||
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
||||||
|
OPCODE_PRINT,
|
||||||
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +90,8 @@ private:
|
|||||||
bool doManual();
|
bool doManual();
|
||||||
void loop2();
|
void loop2();
|
||||||
void kill(const FSH * reason=NULL,int operand=0);
|
void kill(const FSH * reason=NULL,int operand=0);
|
||||||
|
void printMessage(uint16_t id); // Built by RMFTMacros.h
|
||||||
|
void printMessage2(const FSH * msg);
|
||||||
|
|
||||||
static bool diag;
|
static bool diag;
|
||||||
static const FLASH byte RouteCode[];
|
static const FLASH byte RouteCode[];
|
||||||
|
262
RMFTMacros.h
262
RMFTMacros.h
@ -33,12 +33,148 @@
|
|||||||
// but since the C preprocessor is such a wimp, we have to pass over the myAutomation.h 2 times with
|
// but since the C preprocessor is such a wimp, we have to pass over the myAutomation.h 2 times with
|
||||||
// different macros.
|
// different macros.
|
||||||
|
|
||||||
|
// PRINT(msg) is implemented in a separate pass to create a getMessageText(id) function
|
||||||
#define V(val) ((int16_t)(val))&0x00FF,((int16_t)(val)>>8)&0x00FF
|
#define V(val) ((int16_t)(val))&0x00FF,((int16_t)(val)>>8)&0x00FF
|
||||||
#define NOP 0,0
|
#define NOP 0,0
|
||||||
|
|
||||||
// CAUTION: The macros below are triple passed over myAutomation.h
|
// CAUTION: The macros below are triple passed over myAutomation.h
|
||||||
// Adding a macro here must have equivalent macros or no-ops in pass 2 and 3
|
|
||||||
|
// Pass 1 Macros convert descriptions to a flash string constant in withrottle format.
|
||||||
|
// Most macros are simply ignored in this pass.
|
||||||
|
#define ROUTE(id, description) "]\\[R" #id "}|{" description "}|{2"
|
||||||
|
#define AUTOMATION(id, description) "]\\[A" #id "}|{" description "}|{4"
|
||||||
|
#define EXRAIL const FLASH char RMFT2::RouteDescription[]=
|
||||||
|
#define ENDEXRAIL "";
|
||||||
|
|
||||||
|
#define ALIAS(name,value)
|
||||||
|
#define AFTER(sensor_id)
|
||||||
|
#define AMBER(signal_id)
|
||||||
|
#define AT(sensor_id)
|
||||||
|
#define CALL(route)
|
||||||
|
#define CLOSE(id)
|
||||||
|
#define DELAY(mindelay)
|
||||||
|
#define DELAYMINS(mindelay)
|
||||||
|
#define DELAYRANDOM(mindelay,maxdelay)
|
||||||
|
#define DONE
|
||||||
|
#define ENDIF
|
||||||
|
#define ENDTASK
|
||||||
|
#define ESTOP
|
||||||
|
#define FOFF(func)
|
||||||
|
#define FOLLOW(route)
|
||||||
|
#define FON(func)
|
||||||
|
#define FREE(blockid)
|
||||||
|
#define FWD(speed)
|
||||||
|
#define GREEN(signal_id)
|
||||||
|
#define IF(sensor_id)
|
||||||
|
#define IFNOT(sensor_id)
|
||||||
|
#define IFRANDOM(percent)
|
||||||
|
#define IFRESERVE(block)
|
||||||
|
#define INVERT_DIRECTION
|
||||||
|
#define JOIN
|
||||||
|
#define LATCH(sensor_id)
|
||||||
|
#define ONCLOSE(turnout_id)
|
||||||
|
#define ONTHROW(turnout_id)
|
||||||
|
#define PAUSE
|
||||||
|
#define PRINT(msg)
|
||||||
|
#define POM(cv,value)
|
||||||
|
#define READ_LOCO
|
||||||
|
#define RED(signal_id)
|
||||||
|
#define RESERVE(blockid)
|
||||||
|
#define RESET(sensor_id)
|
||||||
|
#define RESUME
|
||||||
|
#define RETURN
|
||||||
|
#define REV(speed)
|
||||||
|
#define START(route)
|
||||||
|
#define SERVO(id,position,profile)
|
||||||
|
#define SETLOCO(loco)
|
||||||
|
#define SET(sensor_id)
|
||||||
|
#define SEQUENCE(id)
|
||||||
|
#define SPEED(speed)
|
||||||
|
#define STOP
|
||||||
|
#undef SIGNAL
|
||||||
|
#define SIGNAL(redpin,amberpin,greenpin)
|
||||||
|
#define SERVO_TURNOUT(pin,activeAngle,inactiveAngle)
|
||||||
|
#define PIN_TURNOUT(pin)
|
||||||
|
#define THROW(id)
|
||||||
|
#define TURNOUT(id,addr,subaddr)
|
||||||
|
#define UNJOIN
|
||||||
|
#define UNLATCH(sensor_id)
|
||||||
|
|
||||||
|
#include "myAutomation.h"
|
||||||
|
|
||||||
|
// setup for pass 2... Create getMessageText function
|
||||||
|
#undef ROUTE
|
||||||
|
#undef AUTOMATION
|
||||||
|
#define ROUTE(id, description)
|
||||||
|
#define AUTOMATION(id, description)
|
||||||
|
|
||||||
|
#undef EXRAIL
|
||||||
|
#undef PRINT
|
||||||
|
#undef ENDEXRAIL
|
||||||
|
const int PrintMacroTracker1=__COUNTER__;
|
||||||
|
#define EXRAIL void RMFT2::printMessage(uint16_t id) { switch(id) {
|
||||||
|
#define ENDEXRAIL default: DIAG(F("printMessage error %d %d"),id,PrintMacroTracker1); return ; }}
|
||||||
|
#define PRINT(msg) case (__COUNTER__ - PrintMacroTracker1) : printMessage2(F(msg));break;
|
||||||
|
#include "myAutomation.h"
|
||||||
|
|
||||||
|
#undef ALIAS
|
||||||
|
#undef AFTER
|
||||||
|
#undef AMBER
|
||||||
|
#undef AT
|
||||||
|
#undef AUTOMATION
|
||||||
|
#undef CALL
|
||||||
|
#undef CLOSE
|
||||||
|
#undef DELAY
|
||||||
|
#undef DELAYMINS
|
||||||
|
#undef DELAYRANDOM
|
||||||
|
#undef DONE
|
||||||
|
#undef ENDIF
|
||||||
|
#undef ENDEXRAIL
|
||||||
|
#undef ENDTASK
|
||||||
|
#undef ESTOP
|
||||||
|
#undef EXRAIL
|
||||||
|
#undef FOFF
|
||||||
|
#undef FOLLOW
|
||||||
|
#undef FON
|
||||||
|
#undef FREE
|
||||||
|
#undef FWD
|
||||||
|
#undef GREEN
|
||||||
|
#undef IF
|
||||||
|
#undef IFNOT
|
||||||
|
#undef IFRANDOM
|
||||||
|
#undef IFRESERVE
|
||||||
|
#undef INVERT_DIRECTION
|
||||||
|
#undef JOIN
|
||||||
|
#undef LATCH
|
||||||
|
#undef ONCLOSE
|
||||||
|
#undef ONTHROW
|
||||||
|
#undef PAUSE
|
||||||
|
#undef POM
|
||||||
|
#undef PRINT
|
||||||
|
#undef READ_LOCO
|
||||||
|
#undef RED
|
||||||
|
#undef RESERVE
|
||||||
|
#undef RESET
|
||||||
|
#undef RESUME
|
||||||
|
#undef RETURN
|
||||||
|
#undef REV
|
||||||
|
#undef ROUTE
|
||||||
|
#undef START
|
||||||
|
#undef SEQUENCE
|
||||||
|
#undef SERVO
|
||||||
|
#undef SETLOCO
|
||||||
|
#undef SET
|
||||||
|
#undef SPEED
|
||||||
|
#undef STOP
|
||||||
|
#undef SIGNAL
|
||||||
|
#undef SERVO_TURNOUT
|
||||||
|
#undef PIN_TURNOUT
|
||||||
|
#undef THROW
|
||||||
|
#undef TURNOUT
|
||||||
|
#undef UNJOIN
|
||||||
|
#undef UNLATCH
|
||||||
|
|
||||||
|
// Define macros or route code creation
|
||||||
#define ALIAS(name,value) const int name=value;
|
#define ALIAS(name,value) const int name=value;
|
||||||
#define EXRAIL const FLASH byte RMFT2::RouteCode[] = {
|
#define EXRAIL const FLASH byte RMFT2::RouteCode[] = {
|
||||||
#define AUTOMATION(id, description) OPCODE_AUTOMATION, V(id),
|
#define AUTOMATION(id, description) OPCODE_AUTOMATION, V(id),
|
||||||
@ -88,136 +224,20 @@
|
|||||||
#define SET(sensor_id) OPCODE_SET,V(sensor_id),
|
#define SET(sensor_id) OPCODE_SET,V(sensor_id),
|
||||||
#define SPEED(speed) OPCODE_SPEED,V(speed),
|
#define SPEED(speed) OPCODE_SPEED,V(speed),
|
||||||
#define STOP OPCODE_SPEED,V(0),
|
#define STOP OPCODE_SPEED,V(0),
|
||||||
#undef SIGNAL
|
|
||||||
#define SIGNAL(redpin,amberpin,greenpin) OPCODE_SIGNAL,V(redpin),OPCODE_PAD,V(amberpin),OPCODE_PAD,V(greenpin),
|
#define SIGNAL(redpin,amberpin,greenpin) OPCODE_SIGNAL,V(redpin),OPCODE_PAD,V(amberpin),OPCODE_PAD,V(greenpin),
|
||||||
#define SERVO_TURNOUT(pin,activeAngle,inactiveAngle) OPCODE_SERVOTURNOUT,V(pin),OPCODE_PAD,V(actibeAngle),OPCODE
|
#define SERVO_TURNOUT(pin,activeAngle,inactiveAngle) OPCODE_SERVOTURNOUT,V(pin),OPCODE_PAD,V(actibeAngle),OPCODE
|
||||||
#define PIN_TURNOUT(pin) OPCODE_PINTURNOUT,V(pin),
|
#define PIN_TURNOUT(pin) OPCODE_PINTURNOUT,V(pin),
|
||||||
|
#define PRINT(msg) OPCODE_PRINT,V(__COUNTER__ - PrintMacroTracker2),
|
||||||
#define THROW(id) OPCODE_THROW,V(id),
|
#define THROW(id) OPCODE_THROW,V(id),
|
||||||
#define TURNOUT(id,addr,subaddr) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr),
|
#define TURNOUT(id,addr,subaddr) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr),
|
||||||
#define UNJOIN OPCODE_UNJOIN,NOP,
|
#define UNJOIN OPCODE_UNJOIN,NOP,
|
||||||
#define UNLATCH(sensor_id) OPCODE_UNLATCH,V(sensor_id),
|
#define UNLATCH(sensor_id) OPCODE_UNLATCH,V(sensor_id),
|
||||||
|
|
||||||
// PASS1 Build RouteCode
|
// PASS2 Build RouteCode
|
||||||
|
const int PrintMacroTracker2=__COUNTER__;
|
||||||
#include "myAutomation.h"
|
#include "myAutomation.h"
|
||||||
|
|
||||||
#undef ALIAS
|
|
||||||
#undef EXRAIL
|
|
||||||
#undef AUTOMATION
|
|
||||||
#undef ROUTE
|
|
||||||
#undef SEQUENCE
|
|
||||||
#undef ENDTASK
|
|
||||||
#undef DONE
|
|
||||||
#undef ENDEXRAIL
|
|
||||||
|
|
||||||
#undef AFTER
|
|
||||||
#undef AMBER
|
|
||||||
#undef AT
|
|
||||||
#undef CALL
|
|
||||||
#undef CLOSE
|
|
||||||
#undef DELAY
|
|
||||||
#undef DELAYMINS
|
|
||||||
#undef DELAYRANDOM
|
|
||||||
#undef ENDIF
|
|
||||||
#undef ESTOP
|
|
||||||
#undef FOFF
|
|
||||||
#undef FOLLOW
|
|
||||||
#undef FON
|
|
||||||
#undef FREE
|
|
||||||
#undef FWD
|
|
||||||
#undef GREEN
|
|
||||||
#undef IF
|
|
||||||
#undef IFNOT
|
|
||||||
#undef IFRANDOM
|
|
||||||
#undef IFRESERVE
|
|
||||||
#undef INVERT_DIRECTION
|
|
||||||
#undef JOIN
|
|
||||||
#undef LATCH
|
|
||||||
#undef ONCLOSE
|
|
||||||
#undef ONTHROW
|
|
||||||
#undef PAUSE
|
|
||||||
#undef POM
|
|
||||||
#undef READ_LOCO
|
|
||||||
#undef RED
|
|
||||||
#undef RESERVE
|
|
||||||
#undef RESET
|
|
||||||
#undef RESUME
|
|
||||||
#undef RETURN
|
|
||||||
#undef REV
|
|
||||||
#undef START
|
|
||||||
#undef SERVO
|
|
||||||
#undef SETLOCO
|
|
||||||
#undef SET
|
|
||||||
#undef SPEED
|
|
||||||
#undef STOP
|
|
||||||
#undef SIGNAL
|
|
||||||
#undef SERVO_TURNOUT
|
|
||||||
#undef PIN_TURNOUT
|
|
||||||
#undef THROW
|
|
||||||
#undef TURNOUT
|
|
||||||
#undef UNJOIN
|
|
||||||
#undef UNLATCH
|
|
||||||
//==================
|
//==================
|
||||||
|
|
||||||
// Pass2 Macros convert descriptions to a flash string constant in withrottle format.
|
|
||||||
// Most macros are simply ignored in this pass.
|
|
||||||
#define ALIAS(name,value)
|
|
||||||
#define EXRAIL const FLASH char RMFT2::RouteDescription[]=
|
|
||||||
#define AUTOMATION(id, description) "]\\[A" #id "}|{" description "}|{4"
|
|
||||||
#define ROUTE(id, description) "]\\[R" #id "}|{" description "}|{2"
|
|
||||||
#define SEQUENCE(id)
|
|
||||||
#define ENDTASK
|
|
||||||
#define DONE
|
|
||||||
#define ENDEXRAIL "";
|
|
||||||
|
|
||||||
#define AFTER(sensor_id)
|
|
||||||
#define AMBER(signal_id)
|
|
||||||
#define AT(sensor_id)
|
|
||||||
#define CALL(route)
|
|
||||||
#define CLOSE(id)
|
|
||||||
#define DELAY(mindelay)
|
|
||||||
#define DELAYMINS(mindelay)
|
|
||||||
#define DELAYRANDOM(mindelay,maxdelay)
|
|
||||||
#define ENDIF
|
|
||||||
#define ESTOP
|
|
||||||
#define FOFF(func)
|
|
||||||
#define FOLLOW(route)
|
|
||||||
#define FON(func)
|
|
||||||
#define FREE(blockid)
|
|
||||||
#define FWD(speed)
|
|
||||||
#define GREEN(signal_id)
|
|
||||||
#define IF(sensor_id)
|
|
||||||
#define IFNOT(sensor_id)
|
|
||||||
#define IFRANDOM(percent)
|
|
||||||
#define IFRESERVE(block)
|
|
||||||
#define INVERT_DIRECTION
|
|
||||||
#define JOIN
|
|
||||||
#define LATCH(sensor_id)
|
|
||||||
#define ONCLOSE(turnout_id)
|
|
||||||
#define ONTHROW(turnout_id)
|
|
||||||
#define PAUSE
|
|
||||||
#define POM(cv,value)
|
|
||||||
#define READ_LOCO
|
|
||||||
#define RED(signal_id)
|
|
||||||
#define RESERVE(blockid)
|
|
||||||
#define RESET(sensor_id)
|
|
||||||
#define RESUME
|
|
||||||
#define RETURN
|
|
||||||
#define REV(speed)
|
|
||||||
#define START(route)
|
|
||||||
#define SERVO(id,position,profile)
|
|
||||||
#define SETLOCO(loco)
|
|
||||||
#define SET(sensor_id)
|
|
||||||
#define SPEED(speed)
|
|
||||||
#define STOP
|
|
||||||
#define SIGNAL(redpin,amberpin,greenpin)
|
|
||||||
#define SERVO_TURNOUT(pin,activeAngle,inactiveAngle)
|
|
||||||
#define PIN_TURNOUT(pin)
|
|
||||||
#define THROW(id)
|
|
||||||
#define TURNOUT(id,addr,subaddr)
|
|
||||||
#define UNJOIN
|
|
||||||
#define UNLATCH(sensor_id)
|
|
||||||
|
|
||||||
#include "myAutomation.h"
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user