mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-30 03:26:13 +01:00
Add #ifdef selections
Add #ifdef selections linked to #define in config.exampe.h
This commit is contained in:
parent
873d470f86
commit
8fac20a451
|
@ -155,6 +155,7 @@ void CommandDistributor::broadcastTurnout(int16_t id, bool isClosed ) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
void CommandDistributor::broadcastClockTime(int16_t time, int8_t rate) {
|
void CommandDistributor::broadcastClockTime(int16_t time, int8_t rate) {
|
||||||
// The JMRI clock command is of the form : PFT65871<;>4
|
// The JMRI clock command is of the form : PFT65871<;>4
|
||||||
// The CS broadcast is of the form "<jC mmmm nn" where mmmm is time minutes and dd speed
|
// The CS broadcast is of the form "<jC mmmm nn" where mmmm is time minutes and dd speed
|
||||||
|
@ -165,6 +166,7 @@ void CommandDistributor::broadcastClockTime(int16_t time, int8_t rate) {
|
||||||
broadcastReply(WITHROTTLE_TYPE, F("PFT%d<;>%d\n"), time*60, rate);
|
broadcastReply(WITHROTTLE_TYPE, F("PFT%d<;>%d\n"), time*60, rate);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CommandDistributor::broadcastLoco(byte slot) {
|
void CommandDistributor::broadcastLoco(byte slot) {
|
||||||
DCC::LOCO * sp=&DCC::speedTable[slot];
|
DCC::LOCO * sp=&DCC::speedTable[slot];
|
||||||
|
|
|
@ -45,7 +45,9 @@ public :
|
||||||
static void broadcastLoco(byte slot);
|
static void broadcastLoco(byte slot);
|
||||||
static void broadcastSensor(int16_t id, bool value);
|
static void broadcastSensor(int16_t id, bool value);
|
||||||
static void broadcastTurnout(int16_t id, bool isClosed);
|
static void broadcastTurnout(int16_t id, bool isClosed);
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
static void broadcastClockTime(int16_t time, int8_t rate);
|
static void broadcastClockTime(int16_t time, int8_t rate);
|
||||||
|
#ifdef
|
||||||
static void broadcastPower();
|
static void broadcastPower();
|
||||||
static void broadcastText(const FSH * msg);
|
static void broadcastText(const FSH * msg);
|
||||||
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
template<typename... Targs> static void broadcastReply(clientType type, Targs... msg);
|
||||||
|
|
|
@ -97,7 +97,9 @@ Print *DCCEXParser::stashStream = NULL;
|
||||||
RingStream *DCCEXParser::stashRingStream = NULL;
|
RingStream *DCCEXParser::stashRingStream = NULL;
|
||||||
byte DCCEXParser::stashTarget=0;
|
byte DCCEXParser::stashTarget=0;
|
||||||
|
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
int16_t lastclocktime = 0;
|
int16_t lastclocktime = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// This is a JMRI command parser.
|
// This is a JMRI command parser.
|
||||||
// It doesnt know how the string got here, nor how it gets back.
|
// It doesnt know how the string got here, nor how it gets back.
|
||||||
|
@ -572,9 +574,15 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
|
|
||||||
case 'J' : // throttle info access
|
case 'J' : // throttle info access
|
||||||
{
|
{
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
if ((params<1) | (params>3)) break; // <J>
|
if ((params<1) | (params>3)) break; // <J>
|
||||||
|
#endif
|
||||||
|
#ifndef USEFASTCLOCK
|
||||||
|
if ((params<1) | (params>2)) break; // <J>
|
||||||
|
#endif
|
||||||
int16_t id=(params==2)?p[1]:0;
|
int16_t id=(params==2)?p[1]:0;
|
||||||
switch(p[0]) {
|
switch(p[0]) {
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
case HASH_KEYWORD_C: // <JC mmmm nn> sets time and speed
|
case HASH_KEYWORD_C: // <JC mmmm nn> sets time and speed
|
||||||
if (params==1) { // <JC> returns latest time
|
if (params==1) { // <JC> returns latest time
|
||||||
StringFormatter::send(stream, F("<jC %d>\n"), lastclocktime);
|
StringFormatter::send(stream, F("<jC %d>\n"), lastclocktime);
|
||||||
|
@ -593,6 +601,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
lastclocktime = p[1];
|
lastclocktime = p[1];
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
case HASH_KEYWORD_A: // <JA> returns automations/routes
|
case HASH_KEYWORD_A: // <JA> returns automations/routes
|
||||||
StringFormatter::send(stream, F("<jA"));
|
StringFormatter::send(stream, F("<jA"));
|
||||||
if (params==1) {// <JA>
|
if (params==1) {// <JA>
|
||||||
|
|
10
EXRAIL2.cpp
10
EXRAIL2.cpp
|
@ -92,7 +92,9 @@ LookList * RMFT2::onRedLookup=NULL;
|
||||||
LookList * RMFT2::onAmberLookup=NULL;
|
LookList * RMFT2::onAmberLookup=NULL;
|
||||||
LookList * RMFT2::onGreenLookup=NULL;
|
LookList * RMFT2::onGreenLookup=NULL;
|
||||||
LookList * RMFT2::onChangeLookup=NULL;
|
LookList * RMFT2::onChangeLookup=NULL;
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
LookList * RMFT2::onClockLookup=NULL;
|
LookList * RMFT2::onClockLookup=NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
|
||||||
#define SKIPOP progCounter+=3
|
#define SKIPOP progCounter+=3
|
||||||
|
@ -176,7 +178,9 @@ LookList* RMFT2::LookListLoader(OPCODE op1, OPCODE op2, OPCODE op3) {
|
||||||
onAmberLookup=LookListLoader(OPCODE_ONAMBER);
|
onAmberLookup=LookListLoader(OPCODE_ONAMBER);
|
||||||
onGreenLookup=LookListLoader(OPCODE_ONGREEN);
|
onGreenLookup=LookListLoader(OPCODE_ONGREEN);
|
||||||
onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
|
onChangeLookup=LookListLoader(OPCODE_ONCHANGE);
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
onClockLookup=LookListLoader(OPCODE_ONTIME);
|
onClockLookup=LookListLoader(OPCODE_ONTIME);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Second pass startup, define any turnouts or servos, set signals red
|
// Second pass startup, define any turnouts or servos, set signals red
|
||||||
// add sequences onRoutines to the lookups
|
// add sequences onRoutines to the lookups
|
||||||
|
@ -977,7 +981,9 @@ void RMFT2::loop2() {
|
||||||
case OPCODE_ONAMBER:
|
case OPCODE_ONAMBER:
|
||||||
case OPCODE_ONGREEN:
|
case OPCODE_ONGREEN:
|
||||||
case OPCODE_ONCHANGE:
|
case OPCODE_ONCHANGE:
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
case OPCODE_ONTIME:
|
case OPCODE_ONTIME:
|
||||||
|
#endif
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1110,12 +1116,14 @@ void RMFT2::changeEvent(int16_t vpin, bool change) {
|
||||||
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
|
if (change) handleEvent(F("CHANGE"),onChangeLookup,vpin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
void RMFT2::clockEvent(int16_t clocktime, bool change) {
|
void RMFT2::clockEvent(int16_t clocktime, bool change) {
|
||||||
// Hunt for an ONTIME for this time
|
// Hunt for an ONTIME for this time
|
||||||
if (Diag::CMD)
|
if (Diag::CMD)
|
||||||
DIAG(F("Looking for clock event at : %d"), clocktime);
|
DIAG(F("Looking for clock event at : %d"), clocktime);
|
||||||
if (change) handleEvent(F("CHANGE"),onClockLookup,clocktime);
|
if (change) handleEvent(F("CLOCK"),onClockLookup,clocktime);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void RMFT2::handleEvent(const FSH* reason,LookList* handlers, int16_t id) {
|
void RMFT2::handleEvent(const FSH* reason,LookList* handlers, int16_t id) {
|
||||||
int pc= handlers->find(id);
|
int pc= handlers->find(id);
|
||||||
|
|
|
@ -55,8 +55,10 @@ enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,
|
||||||
OPCODE_SET_TRACK,
|
OPCODE_SET_TRACK,
|
||||||
OPCODE_ONRED,OPCODE_ONAMBER,OPCODE_ONGREEN,
|
OPCODE_ONRED,OPCODE_ONAMBER,OPCODE_ONGREEN,
|
||||||
OPCODE_ONCHANGE,
|
OPCODE_ONCHANGE,
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
OPCODE_ONCLOCKTIME,
|
OPCODE_ONCLOCKTIME,
|
||||||
OPCODE_ONTIME,
|
OPCODE_ONTIME,
|
||||||
|
#endif
|
||||||
|
|
||||||
// OPcodes below this point are skip-nesting IF operations
|
// OPcodes below this point are skip-nesting IF operations
|
||||||
// placed here so that they may be skipped as a group
|
// placed here so that they may be skipped as a group
|
||||||
|
@ -118,7 +120,9 @@ class LookList {
|
||||||
static void turnoutEvent(int16_t id, bool closed);
|
static void turnoutEvent(int16_t id, bool closed);
|
||||||
static void activateEvent(int16_t addr, bool active);
|
static void activateEvent(int16_t addr, bool active);
|
||||||
static void changeEvent(int16_t id, bool change);
|
static void changeEvent(int16_t id, bool change);
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
static void clockEvent(int16_t clocktime, bool change);
|
static void clockEvent(int16_t clocktime, bool change);
|
||||||
|
#endif
|
||||||
static const int16_t SERVO_SIGNAL_FLAG=0x4000;
|
static const int16_t SERVO_SIGNAL_FLAG=0x4000;
|
||||||
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
|
static const int16_t ACTIVE_HIGH_SIGNAL_FLAG=0x2000;
|
||||||
static const int16_t DCC_SIGNAL_FLAG=0x1000;
|
static const int16_t DCC_SIGNAL_FLAG=0x1000;
|
||||||
|
@ -176,7 +180,9 @@ private:
|
||||||
static LookList * onAmberLookup;
|
static LookList * onAmberLookup;
|
||||||
static LookList * onGreenLookup;
|
static LookList * onGreenLookup;
|
||||||
static LookList * onChangeLookup;
|
static LookList * onChangeLookup;
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
static LookList * onClockLookup;
|
static LookList * onClockLookup;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Local variables - exist for each instance/task
|
// Local variables - exist for each instance/task
|
||||||
RMFT2 *next; // loop chain
|
RMFT2 *next; // loop chain
|
||||||
|
|
|
@ -86,8 +86,10 @@
|
||||||
#undef ONDEACTIVATE
|
#undef ONDEACTIVATE
|
||||||
#undef ONDEACTIVATEL
|
#undef ONDEACTIVATEL
|
||||||
#undef ONCLOSE
|
#undef ONCLOSE
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
#undef ONTIME
|
#undef ONTIME
|
||||||
#undef ONCLOCKTIME
|
#undef ONCLOCKTIME
|
||||||
|
#endif
|
||||||
#undef ONGREEN
|
#undef ONGREEN
|
||||||
#undef ONRED
|
#undef ONRED
|
||||||
#undef ONTHROW
|
#undef ONTHROW
|
||||||
|
@ -200,8 +202,10 @@
|
||||||
#define ONACTIVATE(addr,subaddr)
|
#define ONACTIVATE(addr,subaddr)
|
||||||
#define ONACTIVATEL(linear)
|
#define ONACTIVATEL(linear)
|
||||||
#define ONAMBER(signal_id)
|
#define ONAMBER(signal_id)
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
#define ONTIME(value)
|
#define ONTIME(value)
|
||||||
#define ONCLOCKTIME(hours,mins)
|
#define ONCLOCKTIME(hours,mins)
|
||||||
|
#endif
|
||||||
#define ONDEACTIVATE(addr,subaddr)
|
#define ONDEACTIVATE(addr,subaddr)
|
||||||
#define ONDEACTIVATEL(linear)
|
#define ONDEACTIVATEL(linear)
|
||||||
#define ONCLOSE(turnout_id)
|
#define ONCLOSE(turnout_id)
|
||||||
|
|
|
@ -55,13 +55,11 @@
|
||||||
// helper macro for turnout description as HIDDEN
|
// helper macro for turnout description as HIDDEN
|
||||||
#define HIDDEN "\x01"
|
#define HIDDEN "\x01"
|
||||||
|
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
// helper macro to strip leading zeros off time inputs
|
// helper macro to strip leading zeros off time inputs
|
||||||
// (10#mins)%100)
|
// (10#mins)%100)
|
||||||
#define STRIP_ZERO(value) 10##value%100
|
#define STRIP_ZERO(value) 10##value%100
|
||||||
|
#endif
|
||||||
// helper macro to strip leading zeros off time inputs
|
|
||||||
// (10#mins)%100)
|
|
||||||
#define STRIP_ZERO(value) 10##value%100
|
|
||||||
|
|
||||||
// Pass 1 Implements aliases
|
// Pass 1 Implements aliases
|
||||||
#include "EXRAIL2MacroReset.h"
|
#include "EXRAIL2MacroReset.h"
|
||||||
|
@ -305,8 +303,10 @@ const HIGHFLASH int16_t RMFT2::SignalDefinitions[] = {
|
||||||
#define ONACTIVATEL(linear) OPCODE_ONACTIVATE,V(linear+3),
|
#define ONACTIVATEL(linear) OPCODE_ONACTIVATE,V(linear+3),
|
||||||
#define ONAMBER(signal_id) OPCODE_ONAMBER,V(signal_id),
|
#define ONAMBER(signal_id) OPCODE_ONAMBER,V(signal_id),
|
||||||
#define ONCLOSE(turnout_id) OPCODE_ONCLOSE,V(turnout_id),
|
#define ONCLOSE(turnout_id) OPCODE_ONCLOSE,V(turnout_id),
|
||||||
|
#ifdef USEFASTCLOCK
|
||||||
#define ONTIME(value) OPCODE_ONTIME,V(value),
|
#define ONTIME(value) OPCODE_ONTIME,V(value),
|
||||||
#define ONCLOCKTIME(hours,mins) OPCODE_ONTIME,V((STRIP_ZERO(hours)*60)+STRIP_ZERO(mins)),
|
#define ONCLOCKTIME(hours,mins) OPCODE_ONTIME,V((STRIP_ZERO(hours)*60)+STRIP_ZERO(mins)),
|
||||||
|
#endif
|
||||||
#define ONDEACTIVATE(addr,subaddr) OPCODE_ONDEACTIVATE,V(addr<<2|subaddr),
|
#define ONDEACTIVATE(addr,subaddr) OPCODE_ONDEACTIVATE,V(addr<<2|subaddr),
|
||||||
#define ONDEACTIVATEL(linear) OPCODE_ONDEACTIVATE,V(linear+3),
|
#define ONDEACTIVATEL(linear) OPCODE_ONDEACTIVATE,V(linear+3),
|
||||||
#define ONGREEN(signal_id) OPCODE_ONGREEN,V(signal_id),
|
#define ONGREEN(signal_id) OPCODE_ONGREEN,V(signal_id),
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IO_EXFastclock_h
|
#ifndef IO_EXFastclock_h
|
||||||
#define IO_EXFastclock_h
|
#define IO_EXFastclock_h
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
#include "I2CManager.h"
|
#include "I2CManager.h"
|
||||||
|
@ -55,12 +55,12 @@ static void EXFastClock::create(uint8_t _I2CAddress) {
|
||||||
DIAG(F("Clock check result - %d"), _checkforclock);
|
DIAG(F("Clock check result - %d"), _checkforclock);
|
||||||
if (_checkforclock == 0) {
|
if (_checkforclock == 0) {
|
||||||
FAST_CLOCK_EXISTS = true;
|
FAST_CLOCK_EXISTS = true;
|
||||||
DIAG(F("I2C Fast Clock found at x%x"), _I2CAddress);
|
//DIAG(F("I2C Fast Clock found at x%x"), _I2CAddress);
|
||||||
new EXFastClock(_I2CAddress);
|
new EXFastClock(_I2CAddress);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FAST_CLOCK_EXISTS = false;
|
FAST_CLOCK_EXISTS = false;
|
||||||
DIAG(F("No Fast Clock found"));
|
//DIAG(F("No Fast Clock found"));
|
||||||
LCD(6,F("CLOCK NOT FOUND"));
|
LCD(6,F("CLOCK NOT FOUND"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ void _begin() override {
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
_deviceState = DEVSTATE_FAILED;
|
_deviceState = DEVSTATE_FAILED;
|
||||||
LCD(6,F("CLOCK NOT FOUND"));
|
//LCD(6,F("CLOCK NOT FOUND"));
|
||||||
DIAG(F("Fast Clock Not Found at address %d"), _I2CAddress);
|
DIAG(F("Fast Clock Not Found at address %d"), _I2CAddress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,8 @@ void _loop(unsigned long currentMicros) override{
|
||||||
|
|
||||||
if (_clocktime != _previousclocktime) {
|
if (_clocktime != _previousclocktime) {
|
||||||
_previousclocktime = _clocktime;
|
_previousclocktime = _clocktime;
|
||||||
if (Diag::CMD)
|
//if (Diag::CMD)
|
||||||
DIAG(F("Received Clock Time is: %d at rate: %d"), _clocktime, _clockrate);
|
// DIAG(F("Received Clock Time is: %d at rate: %d"), _clocktime, _clockrate);
|
||||||
LCD(6,F(("Clk Time:%d Sp %d")), _clocktime, _clockrate);
|
LCD(6,F(("Clk Time:%d Sp %d")), _clocktime, _clockrate);
|
||||||
RMFT2::clockEvent(_clocktime,1);
|
RMFT2::clockEvent(_clocktime,1);
|
||||||
// Now tell everyone else what the time is.
|
// Now tell everyone else what the time is.
|
||||||
|
@ -132,3 +132,5 @@ void _display() {
|
||||||
DIAG(F("FastCLock on I2C:x%x - %S"), _I2CAddress, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
|
DIAG(F("FastCLock on I2C:x%x - %S"), _I2CAddress, (_deviceState==DEVSTATE_FAILED) ? F("OFFLINE") : F(""));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -224,4 +224,8 @@ The configuration file for DCC-EX Command Station
|
||||||
//
|
//
|
||||||
//#define SERIAL_BT_COMMANDS
|
//#define SERIAL_BT_COMMANDS
|
||||||
|
|
||||||
|
|
||||||
|
// FastClock Enabler
|
||||||
|
// To build the FastClock code into the CS please uncomment the line below
|
||||||
|
//#define USEFASTCLOCK
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue
Block a user