refactoring - crankDivider etc etc
This commit is contained in:
parent
eaff083377
commit
5adb42f939
|
@ -474,6 +474,15 @@ bool TriggerNoiseFilter::noiseFilter(efitick_t nowNt,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getCrankDivider(operation_mode_e operationMode) {
|
||||||
|
if (operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == TWO_STROKE) {
|
||||||
|
// That's easy - trigger cycle matches engine cycle
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return operationMode == FOUR_STROKE_CRANK_SENSOR ? 2 : SYMMETRICAL_CRANK_SENSOR_DIVIDER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is NOT invoked for VR falls.
|
* This method is NOT invoked for VR falls.
|
||||||
*/
|
*/
|
||||||
|
@ -518,18 +527,10 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal, efitick_t timesta
|
||||||
* If we only have a crank position sensor with four stroke, here we are extending crank revolutions with a 360 degree
|
* If we only have a crank position sensor with four stroke, here we are extending crank revolutions with a 360 degree
|
||||||
* cycle into a four stroke, 720 degrees cycle.
|
* cycle into a four stroke, 720 degrees cycle.
|
||||||
*/
|
*/
|
||||||
int triggerIndexForListeners;
|
|
||||||
operation_mode_e operationMode = engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE);
|
operation_mode_e operationMode = engine->getOperationMode(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
if (operationMode == FOUR_STROKE_CAM_SENSOR || operationMode == TWO_STROKE) {
|
int crankDivider = getCrankDivider(operationMode);
|
||||||
// That's easy - trigger cycle matches engine cycle
|
|
||||||
triggerIndexForListeners = triggerState.getCurrentIndex();
|
|
||||||
} else {
|
|
||||||
int crankDivider = operationMode == FOUR_STROKE_CRANK_SENSOR ? 2 : SYMMETRICAL_CRANK_SENSOR_DIVIDER;
|
|
||||||
|
|
||||||
int crankInternalIndex = triggerState.getTotalRevolutionCounter() % crankDivider;
|
int crankInternalIndex = triggerState.getTotalRevolutionCounter() % crankDivider;
|
||||||
|
int triggerIndexForListeners = triggerState.getCurrentIndex() + (crankInternalIndex * getTriggerSize());
|
||||||
triggerIndexForListeners = triggerState.getCurrentIndex() + (crankInternalIndex * getTriggerSize());
|
|
||||||
}
|
|
||||||
if (triggerIndexForListeners == 0) {
|
if (triggerIndexForListeners == 0) {
|
||||||
virtualZeroTimer.reset(timestamp);
|
virtualZeroTimer.reset(timestamp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue