rusEFI
The most advanced open source ECU
util
peak_detect.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
rusefi_types.h
"
4
5
/**
6
* Stores the recent peak value, preventing loss of intermittent peaks in a signal.
7
*/
8
template
<
typename
TValue, ef
id
ur_t TTimeoutPeriod>
9
class
PeakDetect
{
10
public
:
11
TValue
detect
(TValue currentValue, efitick_t nowNt) {
12
if
((nowNt >
m_lastPeakTime
+ TTimeoutPeriod) ||
// if timed out
13
(currentValue >
m_peak
)) {
// or current is higher than the previous peak
14
// store new peak and time
15
m_peak
= currentValue;
16
m_lastPeakTime
= nowNt;
17
}
18
19
return
m_peak
;
20
}
21
22
private
:
23
TValue
m_peak
= std::numeric_limits<TValue>::min();
24
efitick_t
m_lastPeakTime
= std::numeric_limits<efitick_t>::min();
25
};
PeakDetect
Definition:
peak_detect.h:9
PeakDetect::m_lastPeakTime
efitick_t m_lastPeakTime
Definition:
peak_detect.h:24
PeakDetect::detect
TValue detect(TValue currentValue, efitick_t nowNt)
Definition:
peak_detect.h:11
PeakDetect::m_peak
TValue m_peak
Definition:
peak_detect.h:23
rusefi_types.h
Generated on Thu May 9 2024 00:06:12 for rusEFI by
1.9.1