reset instant RPM in case of cam resync (#4544)

This commit is contained in:
Matthew Kennedy 2022-09-06 18:38:35 -07:00 committed by GitHub
parent c717a081e3
commit 670c2e4afe
2 changed files with 13 additions and 3 deletions

View File

@ -212,13 +212,17 @@ int TriggerDecoderBase::getTotalRevolutionCounter() const {
void PrimaryTriggerDecoder::resetTriggerState() {
TriggerDecoderBase::resetTriggerState();
memset(timeOfLastEvent, 0, sizeof(timeOfLastEvent));
memset(spinningEvents, 0, sizeof(spinningEvents));
spinningEventIndex = 0;
prevInstantRpmValue = 0;
m_instantRpm = 0;
resetHasFullSync();
resetInstantRpm();
}
void PrimaryTriggerDecoder::resetInstantRpm() {
memset(timeOfLastEvent, 0, sizeof(timeOfLastEvent));
memset(spinningEvents, 0, sizeof(spinningEvents));
spinningEventIndex = 0;
}
void PrimaryTriggerDecoder::movePreSynchTimestamps() {
@ -393,6 +397,10 @@ 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?
resetInstantRpm();
}
return totalShift;

View File

@ -235,6 +235,8 @@ private:
TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
uint32_t index, efitick_t nowNt);
void resetInstantRpm();
float m_instantRpm = 0;
float m_instantRpmRatio = 0;