From cdb9ddb874d8fb3369b11fdfca9d2c8dd531d059 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Sun, 1 May 2016 01:07:55 +1000 Subject: [PATCH] Very experimental dual wheel potential fix. --- decoders.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/decoders.ino b/decoders.ino index 40e770f7..92696245 100644 --- a/decoders.ino +++ b/decoders.ino @@ -51,9 +51,10 @@ inline int stdGetRPM() */ inline void setFilter(unsigned long curGap) { - if(configPage2.triggerFilter == 1) { triggerFilterTime = curGap >> 2; } //Lite filter level is 50% of previous gap + if(configPage2.triggerFilter == 1) { triggerFilterTime = curGap >> 2; } //Lite filter level is 25% of previous gap else if(configPage2.triggerFilter == 2) { triggerFilterTime = curGap >> 1; } //Medium filter level is 50% of previous gap else if (configPage2.triggerFilter == 3) { triggerFilterTime = (curGap * 3) >> 2; } //Aggressive filter level is 75% of previous gap + else { triggerFilterTime = 0; } //trigger filter is turned off. } /* @@ -173,9 +174,13 @@ void triggerPri_DualWheel() { curTime = micros(); curGap = curTime - toothLastToothTime; - if ( curGap < triggerFilterTime ) { return; } //Debounce check. Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. + if ( curGap < triggerFilterTime ) { return; } //Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. toothCurrentCount++; //Increment the tooth counter addToothLogEntry(curGap); + + toothLastMinusOneToothTime = toothLastToothTime; + toothLastToothTime = curTime; + if ( !currentStatus.hasSync ) { return; } if ( toothCurrentCount == 1 || toothCurrentCount > configPage2.triggerTeeth ) @@ -189,8 +194,7 @@ void triggerPri_DualWheel() setFilter(curGap); //Recalc the new filter value - toothLastMinusOneToothTime = toothLastToothTime; - toothLastToothTime = curTime; + } void triggerSec_DualWheel()