diff --git a/CVReader.ino b/CVReader.ino index 9ba6724..9b2edd8 100644 --- a/CVReader.ino +++ b/CVReader.ino @@ -22,10 +22,10 @@ void myFilter(Print & stream, byte & opcode, byte & paramCount, int p[]) { DCC::setFn(p[0],p[1],p[2]==1); opcode=0; // tell parser to ignore this command break; - case '#': // Diagnose parser <#....> - DIAG(F("# paramCount=%d\n"),paramCount); + case '$': // Diagnose parser <$....> + DIAG(F("$ paramCount=%d\n"),paramCount); for (int i=0;i + StringFormatter::send(stream,F("<# %d>"), MAX_LOCOS); + return; default: //anything else will drop out to break; diff --git a/DCCWaveform.cpp b/DCCWaveform.cpp index bdeacc4..6081132 100644 --- a/DCCWaveform.cpp +++ b/DCCWaveform.cpp @@ -140,8 +140,9 @@ bool DCCWaveform::interrupt1() { state = 0; break; } + // ACK check is prog track only + if (ackPending) checkAck(); return false; - } @@ -190,11 +191,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(); } @@ -271,13 +267,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 } diff --git a/Hardware.cpp b/Hardware.cpp index 532240e..7643f32 100644 --- a/Hardware.cpp +++ b/Hardware.cpp @@ -47,10 +47,6 @@ int Hardware::getCurrentRaw(bool isMainTrack) { } -unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) { - return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR)); -} - void Hardware::setCallback(int duration, void (*isr)()) { Timer1.initialize(duration); // We don't want the timer to set pins because these often clash with motor shields etc.