|
|
@ -69,7 +69,11 @@ void IRAM_ATTR onSpeedSensorChange(bool newState) |
|
|
|
if(impulseDuration > 500) return; // impulse was too long, ignore it (maybe magnet stopped near the sensor)
|
|
|
|
if(impulseDuration > 500) return; // impulse was too long, ignore it (maybe magnet stopped near the sensor)
|
|
|
|
|
|
|
|
|
|
|
|
unsigned long timeSinceLastImpulse = utils::elapsed(speedSensorLastImpulseTime, now); |
|
|
|
unsigned long timeSinceLastImpulse = utils::elapsed(speedSensorLastImpulseTime, now); |
|
|
|
if(timeSinceLastImpulse < 30) |
|
|
|
|
|
|
|
|
|
|
|
// TODO: find a simple formula that works for any wheel diameter and number of magnets
|
|
|
|
|
|
|
|
unsigned long minInterval = speedSensorLastImpulseInterval == (unsigned long)-1 ? 200 : std::min((unsigned long)200, (unsigned long)30 + speedSensorLastImpulseInterval / 2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(timeSinceLastImpulse < minInterval) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// too little time between impulses, probably some bouncing, ignore it
|
|
|
|
// too little time between impulses, probably some bouncing, ignore it
|
|
|
|
} |
|
|
|
} |
|
|
|