mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
Cleaner prog/main sync
Trying to reduce gap between prog and main signals when joined as a siding.
This commit is contained in:
parent
9cc8843e15
commit
3b7325f948
@ -183,8 +183,7 @@ void DCCWaveform::setSignal(bool high) {
|
|||||||
if (progTrackSyncMain) {
|
if (progTrackSyncMain) {
|
||||||
if (!isMainTrack) return; // ignore PROG track waveform while in sync
|
if (!isMainTrack) return; // ignore PROG track waveform while in sync
|
||||||
// set both tracks to same signal
|
// set both tracks to same signal
|
||||||
Hardware::setSignal(true, high);
|
Hardware::setSyncSignal(high);
|
||||||
Hardware::setSignal(false, high);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Hardware::setSignal(isMainTrack,high);
|
Hardware::setSignal(isMainTrack,high);
|
||||||
|
16
Hardware.cpp
16
Hardware.cpp
@ -64,6 +64,22 @@ void Hardware::setSignal(bool isMainTrack, bool high) {
|
|||||||
if (pin2 != UNUSED_PIN) WritePin(pin2, high ? LOW : HIGH);
|
if (pin2 != UNUSED_PIN) WritePin(pin2, high ? LOW : HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Hardware::setSyncSignal(bool high) {
|
||||||
|
// This sets the same signal down both tracks at the same time.
|
||||||
|
// Speed notes....
|
||||||
|
// Objective is to get the two track signals to change as close as possible
|
||||||
|
// the high ? HIGH:LOW will only be evaluated once
|
||||||
|
// The UNUSED_PIN check will be done at compile time.
|
||||||
|
// If even more speed is required, its possible (not SAMD) to pre-prepare the
|
||||||
|
// DIO pinnumber->pincode translation so the WritePin (digitalWrite2) does not
|
||||||
|
// have to calculate the register and bit numbers every time.
|
||||||
|
|
||||||
|
WritePin(MAIN_SIGNAL_PIN, high ? HIGH : LOW);
|
||||||
|
WritePin(PROG_SIGNAL_PIN, high ? HIGH : LOW);
|
||||||
|
if (MAIN_SIGNAL_PIN_ALT != UNUSED_PIN) WritePin(MAIN_SIGNAL_PIN_ALT, high ? LOW : HIGH);
|
||||||
|
if (PROG_SIGNAL_PIN_ALT != UNUSED_PIN) WritePin(PROG_SIGNAL_PIN_ALT, high ? LOW : HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
int Hardware::getCurrentRaw(bool isMainTrack) {
|
int Hardware::getCurrentRaw(bool isMainTrack) {
|
||||||
// tooo much crap for a interrupt routine. Will see how that goes.
|
// tooo much crap for a interrupt routine. Will see how that goes.
|
||||||
byte faultpin = isMainTrack ? MAIN_FAULT_PIN : PROG_FAULT_PIN;
|
byte faultpin = isMainTrack ? MAIN_FAULT_PIN : PROG_FAULT_PIN;
|
||||||
|
@ -24,6 +24,7 @@ class Hardware {
|
|||||||
static void init();
|
static void init();
|
||||||
static void setPower(bool isMainTrack, bool on);
|
static void setPower(bool isMainTrack, bool on);
|
||||||
static void setSignal(bool isMainTrack, bool high);
|
static void setSignal(bool isMainTrack, bool high);
|
||||||
|
static void setSyncSignal( bool high);
|
||||||
static unsigned int getCurrentMilliamps(bool isMainTrack, int rawValue);
|
static unsigned int getCurrentMilliamps(bool isMainTrack, int rawValue);
|
||||||
static int getCurrentRaw(bool isMainTrack);
|
static int getCurrentRaw(bool isMainTrack);
|
||||||
static void setBrake(bool isMainTrack, bool on);
|
static void setBrake(bool isMainTrack, bool on);
|
||||||
|
Loading…
Reference in New Issue
Block a user