trigger refactoring: instance RPM #4740

This commit is contained in:
Andrey 2022-11-06 11:41:27 -05:00
parent e42939560f
commit f7daa5df72
2 changed files with 7 additions and 5 deletions

View File

@ -127,7 +127,13 @@ static bool vvtWithRealDecoder(vvt_mode_e vvtMode) {
angle_t TriggerCentral::syncAndReport(int divider, int remainder) {
angle_t engineCycle = getEngineCycle(getEngineRotationState()->getOperationMode());
return triggerState.syncEnginePhase(divider, remainder, engineCycle);
angle_t totalShift = triggerState.syncEnginePhase(divider, remainder, engineCycle);
if (totalShift != 0) {
// Reset instant RPM, since the engine phase has now changed, invalidating the tooth history buffer
// maybe TODO: could/should we rotate the buffer around to re-align it instead? Is that worth it?
triggerState.instantRpm.resetInstantRpm();
}
return totalShift;
}
static void turnOffAllDebugFields(void *arg) {

View File

@ -370,10 +370,6 @@ angle_t PrimaryTriggerDecoder::syncEnginePhase(int divider, int remainder, angle
if (totalShift > 0) {
camResyncCounter++;
// Reset instant RPM, since the engine phase has now changed, invalidating the tooth history buffer
// maybe TODO: could/should we rotate the buffer around to re-align it instead? Is that worth it?
instantRpm.resetInstantRpm();
}
return totalShift;