GCC Code Coverage Report


Directory: ./
File: firmware/controllers/trigger/instant_rpm_calculator.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 9 0 9
Functions: 100.0% 2 0 2
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /**
2 * instant_rpm_calculator.h
3 */
4
5 #pragma once
6 #include "trigger_structure.h"
7
8 class InstantRpmCalculator {
9 public:
10 InstantRpmCalculator();
11 556524 float getInstantRpm() const {
12 556524 return m_instantRpm;
13 }
14
15 #if EFI_ENGINE_CONTROL && EFI_SHAFT_POSITION_INPUT
16 void updateInstantRpm(
17 uint32_t current_index,
18 TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
19 uint32_t index, efitick_t nowNt);
20 #endif
21 /**
22 * Update timeOfLastEvent[] on every trigger event - even without synchronization
23 * Needed for early spin-up RPM detection.
24 */
25 void setLastEventTimeForInstantRpm(efitick_t nowNt);
26
27 void movePreSynchTimestamps();
28
29 234 void resetInstantRpm() {
30 234 setArrayValues(timeOfLastEvent, 0);
31 234 setArrayValues(spinningEvents, 0);
32 234 spinningEventIndex = 0;
33 234 prevInstantRpmValue = 0;
34 234 m_instantRpm = 0;
35 234 }
36
37 /**
38 * timestamp of each trigger wheel tooth
39 */
40 uint32_t timeOfLastEvent[PWM_PHASE_MAX_COUNT];
41
42 size_t spinningEventIndex = 0;
43
44 // we might need up to one full trigger cycle of events - which on 60-2 means storage for ~120
45 // todo: change the implementation to reuse 'timeOfLastEvent'
46 uint32_t spinningEvents[120];
47 /**
48 * instant RPM calculated at this trigger wheel tooth
49 */
50 float instantRpmValue[PWM_PHASE_MAX_COUNT];
51 /**
52 * Stores last non-zero instant RPM value to fix early instability
53 */
54 float prevInstantRpmValue = 0;
55
56
57 float m_instantRpm = 0;
58 private:
59 float calculateInstantRpm(
60 TriggerWaveform const & triggerShape, TriggerFormDetails *triggerFormDetails,
61 uint32_t index, efitick_t nowNt);
62
63 float m_instantRpmRatio = 0;
64 };
65