diff --git a/DCC.cpp b/DCC.cpp index e9e9cee..591f8c5 100644 --- a/DCC.cpp +++ b/DCC.cpp @@ -45,11 +45,18 @@ const byte FN_GROUP_4=0x08; const byte FN_GROUP_5=0x10; FSH* DCC::shieldName=NULL; +byte DCC::joinRelay=UNUSED_PIN; -void DCC::begin(const FSH * motorShieldName, MotorDriver * mainDriver, MotorDriver* progDriver) { +void DCC::begin(const FSH * motorShieldName, MotorDriver * mainDriver, MotorDriver* progDriver, + byte joinRelayPin) { shieldName=(FSH *)motorShieldName; DIAG(F("\n"), F(VERSION), F(ARDUINO_TYPE), shieldName, F(GITHUB_SHA)); + joinRelay=joinRelayPin; + if (joinRelay!=UNUSED_PIN) { + pinMode(joinRelay,OUTPUT); + digitalWrite(joinRelay,HIGH); // high is relay disengaged + } // Load stuff from EEprom (void)EEPROM; // tell compiler not to warn this is unused EEStore::init(); @@ -223,6 +230,7 @@ void DCC::writeCVBitMain(int cab, int cv, byte bNum, bool bValue) { } void DCC::setProgTrackSyncMain(bool on) { + if (joinRelay!=UNUSED_PIN) digitalWrite(joinRelay,on?LOW:HIGH); DCCWaveform::progTrackSyncMain=on; } void DCC::setProgTrackBoost(bool on) { diff --git a/DCC.h b/DCC.h index a7646a8..f1c4aa0 100644 --- a/DCC.h +++ b/DCC.h @@ -64,7 +64,8 @@ const byte MAX_LOCOS = 50; class DCC { public: - static void begin(const FSH * motorShieldName, MotorDriver *mainDriver, MotorDriver *progDriver); + static void begin(const FSH * motorShieldName, MotorDriver *mainDriver, MotorDriver *progDriver, + byte joinRelayPin=UNUSED_PIN); static void loop(); // Public DCC API functions @@ -109,6 +110,7 @@ private: byte groupFlags; unsigned long functions; }; + static byte joinRelay; static byte loopStatus; static void setThrottle2(uint16_t cab, uint8_t speedCode); static void updateLocoReminder(int loco, byte speedCode);