hoist dwell check out of loop

This commit is contained in:
Matthew Kennedy 2024-08-31 00:37:27 -07:00
parent 7593cd61d4
commit 3fc42222cc
1 changed files with 6 additions and 5 deletions

View File

@ -312,11 +312,6 @@ static void scheduleSparkEvent(bool limitedSpark, IgnitionEvent *event,
int rpm, efitick_t edgeTimestamp, float currentPhase, float nextPhase) {
angle_t sparkAngle = event->sparkAngle;
const floatms_t dwellMs = engine->ignitionState.sparkDwell;
if (std::isnan(dwellMs) || dwellMs <= 0) {
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
return;
}
if (std::isnan(sparkAngle)) {
warning(ObdCode::CUSTOM_ADVANCE_SPARK, "NaN advance");
return;
@ -457,6 +452,12 @@ void onTriggerEventSparkLogic(int rpm, efitick_t edgeTimestamp, float currentPha
engine->outputChannels.sparkCutReason = (int8_t)limitedSparkState.reason;
bool limitedSpark = !limitedSparkState.value;
const floatms_t dwellMs = engine->ignitionState.sparkDwell;
if (std::isnan(dwellMs) || dwellMs <= 0) {
warning(ObdCode::CUSTOM_DWELL, "invalid dwell to handle: %.2f at %d", dwellMs, rpm);
return;
}
if (!engine->ignitionEvents.isReady) {
prepareIgnitionSchedule();
}