mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +01:00
Auto power on and POWEROFF macro
This commit is contained in:
parent
fc9aa71d9f
commit
d077e3a2ff
10
RMFT2.cpp
10
RMFT2.cpp
|
@ -19,6 +19,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "RMFT2.h"
|
#include "RMFT2.h"
|
||||||
#include "DCC.h"
|
#include "DCC.h"
|
||||||
|
#include "DCCWaveform.h"
|
||||||
#include "DIAG.h"
|
#include "DIAG.h"
|
||||||
#include "WiThrottle.h"
|
#include "WiThrottle.h"
|
||||||
#include "DCCEXParser.h"
|
#include "DCCEXParser.h"
|
||||||
|
@ -326,6 +327,8 @@ int RMFT2::locateRouteStart(int16_t _route) {
|
||||||
void RMFT2::driveLoco(byte speed) {
|
void RMFT2::driveLoco(byte speed) {
|
||||||
if (loco<=0) return; // Prevent broadcast!
|
if (loco<=0) return; // Prevent broadcast!
|
||||||
if (diag) DIAG(F("EXRAIL drive %d %d %d"),loco,speed,forward^invert);
|
if (diag) DIAG(F("EXRAIL drive %d %d %d"),loco,speed,forward^invert);
|
||||||
|
if (DCCWaveform::mainTrack.getPowerMode()==POWERMODE::OFF)
|
||||||
|
DCCWaveform::mainTrack.setPowerMode(POWERMODE::ON);
|
||||||
DCC::setThrottle(loco,speed, forward^invert);
|
DCC::setThrottle(loco,speed, forward^invert);
|
||||||
speedo=speed;
|
speedo=speed;
|
||||||
}
|
}
|
||||||
|
@ -477,6 +480,11 @@ void RMFT2::loop2() {
|
||||||
if (loco) DCC::writeCVByteMain(loco, operand, GET_OPERAND(1));
|
if (loco) DCC::writeCVByteMain(loco, operand, GET_OPERAND(1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OPCODE_POWEROFF:
|
||||||
|
DCCWaveform::mainTrack.setPowerMode(POWERMODE::OFF);
|
||||||
|
DCCWaveform::progTrack.setPowerMode(POWERMODE::OFF);
|
||||||
|
break;
|
||||||
|
|
||||||
case OPCODE_RESUME:
|
case OPCODE_RESUME:
|
||||||
pausingTask=NULL;
|
pausingTask=NULL;
|
||||||
driveLoco(speedo);
|
driveLoco(speedo);
|
||||||
|
@ -572,6 +580,8 @@ void RMFT2::loop2() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case OPCODE_JOIN:
|
case OPCODE_JOIN:
|
||||||
|
DCCWaveform::mainTrack.setPowerMode(POWERMODE::ON);
|
||||||
|
DCCWaveform::progTrack.setPowerMode(POWERMODE::ON);
|
||||||
DCC::setProgTrackSyncMain(true);
|
DCC::setProgTrackSyncMain(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
2
RMFT2.h
2
RMFT2.h
|
@ -40,7 +40,7 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN,
|
OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN,
|
||||||
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_SENDLOCO,
|
OPCODE_START,OPCODE_SETLOCO,OPCODE_SENDLOCO,
|
||||||
OPCODE_PAUSE, OPCODE_RESUME,
|
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,
|
||||||
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
|
||||||
OPCODE_PRINT,
|
OPCODE_PRINT,
|
||||||
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,OPCODE_ENDTASK,OPCODE_ENDEXRAIL
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
#define PAUSE
|
#define PAUSE
|
||||||
#define PRINT(msg)
|
#define PRINT(msg)
|
||||||
#define POM(cv,value)
|
#define POM(cv,value)
|
||||||
|
#define POWEROFF
|
||||||
#define READ_LOCO
|
#define READ_LOCO
|
||||||
#define RED(signal_id)
|
#define RED(signal_id)
|
||||||
#define RESERVE(blockid)
|
#define RESERVE(blockid)
|
||||||
|
@ -188,6 +189,7 @@ const int StringMacroTracker1=__COUNTER__;
|
||||||
#undef ONTHROW
|
#undef ONTHROW
|
||||||
#undef PAUSE
|
#undef PAUSE
|
||||||
#undef POM
|
#undef POM
|
||||||
|
#undef POWEROFF
|
||||||
#undef PRINT
|
#undef PRINT
|
||||||
#undef READ_LOCO
|
#undef READ_LOCO
|
||||||
#undef RED
|
#undef RED
|
||||||
|
@ -265,6 +267,7 @@ const int StringMacroTracker1=__COUNTER__;
|
||||||
#define ONTHROW(turnout_id) OPCODE_ONTHROW,V(turnout_id),
|
#define ONTHROW(turnout_id) OPCODE_ONTHROW,V(turnout_id),
|
||||||
#define PAUSE OPCODE_PAUSE,NOP,
|
#define PAUSE OPCODE_PAUSE,NOP,
|
||||||
#define POM(cv,value) OPCODE_POM,V(cv),OPCODE_PAD,V(value),
|
#define POM(cv,value) OPCODE_POM,V(cv),OPCODE_PAD,V(value),
|
||||||
|
#define POWEROFF OPCODE_POWEROFF,NOP,
|
||||||
#define PRINT(msg) OPCODE_PRINT,V(__COUNTER__ - StringMacroTracker2),
|
#define PRINT(msg) OPCODE_PRINT,V(__COUNTER__ - StringMacroTracker2),
|
||||||
#define READ_LOCO OPCODE_READ_LOCO1,NOP,OPCODE_READ_LOCO2,NOP,
|
#define READ_LOCO OPCODE_READ_LOCO1,NOP,OPCODE_READ_LOCO2,NOP,
|
||||||
#define RED(signal_id) OPCODE_RED,V(signal_id),
|
#define RED(signal_id) OPCODE_RED,V(signal_id),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user