From 4e639480ff71dfeb0c21a40d06a913cb8c4cd3ef Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Mon, 24 Jan 2022 15:15:18 -0800 Subject: [PATCH] fix (#3833) --- firmware/controllers/trigger/trigger_central.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 3ab3646353..bb561dc849 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -77,7 +77,15 @@ public: bool engineMovedRecently(efitick_t nowNt) const { constexpr float oneRevolutionLimitInSeconds = 60.0 / RPM_LOW_THRESHOLD; - return getSecondsSinceTriggerEvent(nowNt) < oneRevolutionLimitInSeconds / triggerShape.getSize(); + auto maxAverageToothTime = oneRevolutionLimitInSeconds / triggerShape.getSize(); + + // Some triggers may have long gaps (with many teeth), don't count that as stopped! + auto maxAllowedGap = maxAverageToothTime * 10; + + // Clamp between 0.1 seconds ("instant" for a human) and worst case of one engine cycle on low tooth count wheel + maxAllowedGap = clampF(0.1f, maxAllowedGap, oneRevolutionLimitInSeconds); + + return getSecondsSinceTriggerEvent(nowNt) < maxAverageToothTime; } bool engineMovedRecently() const {