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

Correct place for checkAck() so ack pulse lenth is correct

This commit is contained in:
Harald Barth 2020-07-03 16:03:10 +02:00
parent 3d7a9500cf
commit 0c9b2d962b
2 changed files with 6 additions and 10 deletions

View File

@ -135,8 +135,9 @@ bool DCCWaveform::interrupt1() {
state = 0;
break;
}
// ACK check is prog track only
if (ackPending) checkAck();
return false;
}
@ -185,11 +186,6 @@ void DCCWaveform::interrupt2() {
}
}
}
// ACK check is prog track only and will only be checked if bits_sent=4 ...
// This means only once per 9-bit-byte AND never at the same cycle as the
// relatively expensive packet change code just above.
if (ackPending && bits_sent==4) checkAck();
}
@ -265,13 +261,13 @@ void DCCWaveform::checkAck() {
// detected trailing edge of pulse
ackPulseDuration=micros()-ackPulseStart;
if (ackPulseDuration>1000 && ackPulseDuration<9000) {
if (ackPulseDuration>3000 && ackPulseDuration<8500) {
ackCheckDuration=millis()-ackCheckStart;
ackDetected=true;
ackPending=false;
transmitRepeats=0; // shortcut remaining repeat packets
return; // we have a genuine ACK result
}
}
ackPulseStart=0; // We have detected a too-short or too-long pulse so ignore and wait for next leading edge
}

View File

@ -2,7 +2,7 @@
#define DCCWaveform_h
const int POWER_SAMPLE_MAX = 300;
const int POWER_SAMPLE_MAX = 1000; // XXX only until correct short detection on prog rail is implemented
const int POWER_SAMPLE_ON_WAIT = 100;
const int POWER_SAMPLE_OFF_WAIT = 1000;
const int POWER_SAMPLE_OVERLOAD_WAIT = 4000;