From e29fe83f1796641daf4a1055ccd5631f686da1f6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 25 Sep 2023 22:36:18 -0400 Subject: [PATCH] only:docs&readability --- firmware/controllers/engine_cycle/knock_controller.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/firmware/controllers/engine_cycle/knock_controller.cpp b/firmware/controllers/engine_cycle/knock_controller.cpp index 22c577d6ab..3d3b4e77ab 100644 --- a/firmware/controllers/engine_cycle/knock_controller.cpp +++ b/firmware/controllers/engine_cycle/knock_controller.cpp @@ -61,7 +61,6 @@ bool KnockControllerBase::onKnockSenseCompleted(uint8_t cylinderNumber, float db // All-cylinders peak detector m_knockLevel = allCylinderPeakDetector.detect(dbv, lastKnockTime); - // TODO: retard timing, then put it back! if (isKnock) { m_knockCount++; @@ -105,10 +104,15 @@ void KnockControllerBase::onFastCallback() { // Adjust knock retard under lock chibios_rt::CriticalSectionLocker csl; + // Reduce knock retard at the requested rate float newRetard = m_knockRetard - applyAmount; // don't allow retard to go negative - m_knockRetard = maxF(0, newRetard); + if (newRetard < 0) { + m_knockRetard = 0; + } else { + m_knockRetard = newRetard; + } } }