13 switch (cylinderNumber) {
59 auto distToMinimum = baseTiming - (-20);
63 auto retardAmount = distToMinimum * retardFraction;
66 auto maximumFuelTrim = 0.3f;
69 float trimFuelPercent = clampF(0.f, (
float)
engineConfiguration->knockFuelTrim, maximumFuelTrim * 100.f);
70 float trimFuelAmountPercent = trimFuelPercent * trimFuelFraction;
71 float trimFuelAmount = trimFuelAmountPercent / 100.f;
75 chibios_rt::CriticalSectionLocker csl;
102 constexpr auto callbackPeriodSeconds = FAST_CALLBACK_PERIOD_MS / 1000.0f;
104 auto applyRetardAmount =
engineConfiguration->knockRetardReapplyRate * callbackPeriodSeconds;
105 auto applyFuelAmount =
engineConfiguration->knockFuelTrimReapplyRate * 0.01f * callbackPeriodSeconds;
112 chibios_rt::CriticalSectionLocker csl;
115 if(TPSValue < engineConfiguration->knockSuppressMinTps) {
144 return interpolate2d(
146 config->knockNoiseRpmBins,
154 config->maxKnockRetardTable,
167#if EFI_SOFTWARE_KNOCK
191#if EFI_SOFTWARE_KNOCK
typedef __attribute__
Ignition Mode.
RpmCalculator rpmCalculator
void onSparkFireKnockSense(uint8_t cylinderIndex, efitick_t nowNt)
angle_t timingAdvance[MAX_CYLINDER_COUNT]
float getKnockRetard() const
float getFuelTrimMultiplier() const
virtual float getMaximumRetard() const =0
uint32_t getKnockCount() const
PD allCylinderPeakDetector
void onFastCallback() override
PD peakDetectors[MAX_CYLINDER_COUNT]
void onKnockSenseCompleted(uint8_t cylinderNumber, float dbv, efitick_t lastKnockTime)
virtual float getKnockThreshold() const =0
float getKnockThreshold() const override
float getMaximumRetard() const override
TValue detect(TValue currentValue, efitick_t nowNt)
static float getOrZero(SensorType type)
static EngineAccessor engine
static constexpr persistent_config_s * config
static constexpr engine_configuration_s * engineConfiguration
float samplingTimeSeconds
static void startKnockSampling(Engine *p_engine)
int getCylinderKnockBank(uint8_t cylinderNumber)
UNUSED(samplingTimeSeconds)
static uint8_t cylinderNumberCopy
efitick_t scheduleByAngle(scheduling_s *timer, efitick_t nowNt, angle_t angle, action_s const &action)
TPSValue("TPS", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 22, 0.01, 0.0, 0.0, "%")
void onStartKnockSampling(uint8_t cylinderNumber, float samplingSeconds, uint8_t channelIdx)
int8_t m_knockCyl[MAX_CYLINDER_COUNT]
float m_knockFuelTrimMultiplier