From 8fee275f53a8c922de6f5961fa69be0eb95fd696 Mon Sep 17 00:00:00 2001 From: rusefi Date: Sun, 3 Feb 2019 01:49:41 -0500 Subject: [PATCH] Refactor Trigger System #635 better field names --- .../trigger/decoders/trigger_structure.cpp | 8 ++++---- .../trigger/decoders/trigger_structure.h | 4 ++-- firmware/controllers/trigger/trigger_decoder.cpp | 14 +++++++------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index a7f9db2d38..757bc7b715 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -87,8 +87,8 @@ void TriggerShape::initialize(operation_mode_e operationMode, bool needSecondTri memset(expectedEventCount, 0, sizeof(expectedEventCount)); wave.reset(); previousAngle = 0; - memset(frontOnlyIndexes, 0, sizeof(frontOnlyIndexes)); - memset(isFrontEvent, 0, sizeof(isFrontEvent)); + memset(riseOnlyIndexes, 0, sizeof(riseOnlyIndexes)); + memset(isRiseEvent, 0, sizeof(isRiseEvent)); #if EFI_UNIT_TEST || defined(__DOXYGEN__) memset(&triggerSignals, 0, sizeof(triggerSignals)); #endif @@ -227,7 +227,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, t wave->setState(/* switchIndex */ 0, /* value */ initialState[i]); } - isFrontEvent[0] = TV_RISE == stateParam; + isRiseEvent[0] = TV_RISE == stateParam; wave.setSwitchTime(0, angle); wave.channels[channelIndex].setState(/* channelIndex */ 0, /* value */ state); return; @@ -255,7 +255,7 @@ void TriggerShape::addEvent(angle_t angle, trigger_wheel_e const channelIndex, t wave.setSwitchTime(i + 1, wave.getSwitchTime(i)); } */ - isFrontEvent[index] = TV_RISE == stateParam; + isRiseEvent[index] = TV_RISE == stateParam; if (index != privateTriggerDefinitionSize) { firmwareError(ERROR_TRIGGER_DRAMA, "are we ever here?"); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.h b/firmware/controllers/trigger/decoders/trigger_structure.h index 879883b379..1c4aa09a5e 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.h +++ b/firmware/controllers/trigger/decoders/trigger_structure.h @@ -188,12 +188,12 @@ public: // todo: maybe even automate this flag calculation? pin_state_t initialState[PWM_PHASE_MAX_WAVE_PER_PWM]; - int8_t isFrontEvent[PWM_PHASE_MAX_COUNT]; + bool isRiseEvent[PWM_PHASE_MAX_COUNT]; /** * this table translates trigger definition index into 'front-only' index. This translation is not so trivial * in case of a multi-channel signal with overlapping waves, for example Ford Aspire/Mitsubishi */ - int frontOnlyIndexes[PWM_PHASE_MAX_COUNT]; + int riseOnlyIndexes[PWM_PHASE_MAX_COUNT]; /** * This is a pretty questionable option which is considered by 'addEvent' method diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index de4f6309b6..068d5e3909 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -125,7 +125,7 @@ void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE float firstAngle = shape->getAngle(shape->triggerShapeSynchPointIndex); assertAngleRange(shape->triggerShapeSynchPointIndex, "firstAngle", CUSTOM_ERR_6551); - int frontOnlyIndex = 0; + int riseOnlyIndex = 0; for (int eventIndex = 0; eventIndex < length; eventIndex++) { if (eventIndex == 0) { @@ -133,7 +133,7 @@ void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE shape->eventAngles[0] = 0; // this value would be used in case of front-only shape->eventAngles[1] = 0; - shape->frontOnlyIndexes[0] = 0; + shape->riseOnlyIndexes[0] = 0; } else { assertAngleRange(shape->triggerShapeSynchPointIndex, "triggerShapeSynchPointIndex", CUSTOM_ERR_6552); int triggerDefinitionCoordinate = (shape->triggerShapeSynchPointIndex + eventIndex) % engine->engineCycleEventCount; @@ -143,16 +143,16 @@ void calculateTriggerSynchPoint(TriggerShape *shape, TriggerState *state DECLARE efiAssertVoid(CUSTOM_ERR_6596, !cisnan(angle), "trgSyncNaN"); fixAngle(angle, "trgSync", CUSTOM_ERR_6559); if (engineConfiguration->useOnlyRisingEdgeForTrigger) { - if (shape->isFrontEvent[triggerDefinitionIndex]) { - frontOnlyIndex += 2; - shape->eventAngles[frontOnlyIndex] = angle; - shape->eventAngles[frontOnlyIndex + 1] = angle; + if (shape->isRiseEvent[triggerDefinitionIndex]) { + riseOnlyIndex += 2; + shape->eventAngles[riseOnlyIndex] = angle; + shape->eventAngles[riseOnlyIndex + 1] = angle; } } else { shape->eventAngles[eventIndex] = angle; } - shape->frontOnlyIndexes[eventIndex] = frontOnlyIndex; + shape->riseOnlyIndexes[eventIndex] = riseOnlyIndex; } } }