1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-25 13:41:23 +01:00

JOIN relay pin

This commit is contained in:
Asbelos 2021-02-18 10:25:58 +00:00
parent 3134523626
commit 57ea4bfe49
2 changed files with 12 additions and 2 deletions

10
DCC.cpp
View File

@ -45,11 +45,18 @@ const byte FN_GROUP_4=0x08;
const byte FN_GROUP_5=0x10; const byte FN_GROUP_5=0x10;
FSH* DCC::shieldName=NULL; 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; shieldName=(FSH *)motorShieldName;
DIAG(F("<iDCC-EX V-%S / %S / %S G-%S>\n"), F(VERSION), F(ARDUINO_TYPE), shieldName, F(GITHUB_SHA)); DIAG(F("<iDCC-EX V-%S / %S / %S G-%S>\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 // Load stuff from EEprom
(void)EEPROM; // tell compiler not to warn this is unused (void)EEPROM; // tell compiler not to warn this is unused
EEStore::init(); EEStore::init();
@ -223,6 +230,7 @@ void DCC::writeCVBitMain(int cab, int cv, byte bNum, bool bValue) {
} }
void DCC::setProgTrackSyncMain(bool on) { void DCC::setProgTrackSyncMain(bool on) {
if (joinRelay!=UNUSED_PIN) digitalWrite(joinRelay,on?LOW:HIGH);
DCCWaveform::progTrackSyncMain=on; DCCWaveform::progTrackSyncMain=on;
} }
void DCC::setProgTrackBoost(bool on) { void DCC::setProgTrackBoost(bool on) {

4
DCC.h
View File

@ -64,7 +64,8 @@ const byte MAX_LOCOS = 50;
class DCC class DCC
{ {
public: 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(); static void loop();
// Public DCC API functions // Public DCC API functions
@ -109,6 +110,7 @@ private:
byte groupFlags; byte groupFlags;
unsigned long functions; unsigned long functions;
}; };
static byte joinRelay;
static byte loopStatus; static byte loopStatus;
static void setThrottle2(uint16_t cab, uint8_t speedCode); static void setThrottle2(uint16_t cab, uint8_t speedCode);
static void updateLocoReminder(int loco, byte speedCode); static void updateLocoReminder(int loco, byte speedCode);