refactoring: reducing code duplication around cam index math

This commit is contained in:
rusefi 2024-03-17 20:28:09 -04:00
parent c6d0b4a846
commit 12b91c01cc
1 changed files with 3 additions and 2 deletions

View File

@ -61,10 +61,11 @@ angle_t HpfpLobe::findNextLobe() {
// Calculate impact of VVT // Calculate impact of VVT
angle_t vvt = 0; angle_t vvt = 0;
if (engineConfiguration->hpfpCam != HPFP_CAM_NONE) { if (engineConfiguration->hpfpCam != HPFP_CAM_NONE) {
int camIndex = engineConfiguration->hpfpCam - 1;
// TODO: Is the sign correct here? + means ATDC? // TODO: Is the sign correct here? + means ATDC?
vvt = engine->triggerCentral.getVVTPosition( vvt = engine->triggerCentral.getVVTPosition(
(engineConfiguration->hpfpCam - 1) / 2 & 1, // Bank BANK_BY_INDEX(camIndex),
(engineConfiguration->hpfpCam - 1) & 1); // Cam CAM_BY_INDEX(camIndex);
} }
return engineConfiguration->hpfpPeakPos + vvt + next_index * 720 / lobes; return engineConfiguration->hpfpPeakPos + vvt + next_index * 720 / lobes;