only correct timing in dynamic mode (#1247)
* only correct in dynamic mode * redundant check
This commit is contained in:
parent
22267e5479
commit
f958047d14
|
@ -197,31 +197,35 @@ angle_t getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
if (cisnan(engineLoad)) {
|
||||
return 0; // any error should already be reported
|
||||
}
|
||||
|
||||
angle_t angle;
|
||||
if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||
|
||||
bool isCranking = ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
if (isCranking) {
|
||||
angle = getCrankingAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
assertAngleRange(angle, "crAngle", CUSTOM_ERR_6680);
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "cr_AngleN", 0);
|
||||
if (CONFIG(useAdvanceCorrectionsForCranking)) {
|
||||
angle_t correction = getAdvanceCorrections(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
if (!cisnan(correction)) { // correction could be NaN during settings update
|
||||
angle += correction;
|
||||
}
|
||||
}
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "cr_AngleN2", 0);
|
||||
} else {
|
||||
angle = getRunningAdvance(rpm, engineLoad PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
|
||||
if (cisnan(angle)) {
|
||||
warning(CUSTOM_ERR_6610, "NaN angle from table");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow correction only if set to dynamic
|
||||
// AND we're either not cranking OR allowed to correct in cranking
|
||||
bool allowCorrections = CONFIG(timingMode) == TM_DYNAMIC
|
||||
&& (!isCranking || CONFIG(useAdvanceCorrectionsForCranking));
|
||||
|
||||
if (allowCorrections) {
|
||||
angle_t correction = getAdvanceCorrections(rpm PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
if (!cisnan(correction)) { // correction could be NaN during settings update
|
||||
angle += correction;
|
||||
}
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "AngleN3", 0);
|
||||
}
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "_AngleN4", 0);
|
||||
|
||||
angle -= engineConfiguration->ignitionOffset;
|
||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(angle), "_AngleN5", 0);
|
||||
fixAngle(angle, "getAdvance", CUSTOM_ERR_ADCANCE_CALC_ANGLE);
|
||||
|
|
Loading…
Reference in New Issue