mirror of https://github.com/rusefi/rusefi-1.git
progress #363 - refactoring, less confusing code and a step towards a bug fix
This commit is contained in:
parent
614a30647d
commit
1381c814fa
|
@ -208,18 +208,23 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
||||||
bool isSynchronizationPoint;
|
bool isSynchronizationPoint;
|
||||||
|
|
||||||
if (TRIGGER_SHAPE(isSynchronizationNeeded)) {
|
if (TRIGGER_SHAPE(isSynchronizationNeeded)) {
|
||||||
|
// this is getting a little out of hand, any ideas?
|
||||||
|
|
||||||
|
bool primaryGap = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
|
||||||
|
&& currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo);
|
||||||
|
|
||||||
|
bool secondaryGap = cisnan(TRIGGER_SHAPE(secondSyncRatioFrom)) || (toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioFrom)
|
||||||
|
&& toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioTo));
|
||||||
|
|
||||||
|
bool thirdGap = cisnan(TRIGGER_SHAPE(thirdSyncRatioFrom)) || (durationBeforePrevious > thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioFrom)
|
||||||
|
&& durationBeforePrevious < thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioTo));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Here I prefer to have two multiplications instead of one division, that's a micro-optimization
|
* Here I prefer to have two multiplications instead of one division, that's a micro-optimization
|
||||||
*/
|
*/
|
||||||
isSynchronizationPoint =
|
isSynchronizationPoint = primaryGap
|
||||||
currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
|
&& secondaryGap
|
||||||
&& currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo)
|
&& thirdGap;
|
||||||
&& toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioFrom)
|
|
||||||
&& toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioTo)
|
|
||||||
// this is getting a little out of hand, any ideas?
|
|
||||||
&& durationBeforePrevious > thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioFrom)
|
|
||||||
&& durationBeforePrevious < thirdPreviousDuration * TRIGGER_SHAPE(thirdSyncRatioTo)
|
|
||||||
;
|
|
||||||
|
|
||||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||||
if (engineConfiguration->isPrintTriggerSynchDetails || someSortOfTriggerError) {
|
if (engineConfiguration->isPrintTriggerSynchDetails || someSortOfTriggerError) {
|
||||||
|
|
Loading…
Reference in New Issue