rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
util
math
deadband.h
Go to the documentation of this file.
1
/**
2
* @file deadband.h
3
*
4
* @date April 6, 2020
5
* @author Matthew Kennedy, (c) 2020
6
*/
7
8
#pragma once
9
10
#include "
efilib.h
"
11
12
template
<
int
TDeadband>
13
class
Deadband
{
14
public
:
15
bool
gt
(
float
lhs,
float
rhs) {
16
// If we're within the deadband, be "sticky" with the previous value
17
float
absError = std::abs(lhs - rhs);
18
19
// If there's enough error, actually compare values
20
if
(absError > TDeadband) {
21
m_lastState
= lhs > rhs;
22
}
23
24
return
m_lastState
;
25
}
26
27
// Deadband has no concept of equal - only greater and less, so to compute gt, we just swap args
28
bool
lt
(
float
lhs,
float
rhs) {
29
return
gt
(rhs, lhs);
30
}
31
32
private
:
33
bool
m_lastState
=
false
;
34
};
Deadband
Definition
deadband.h:13
Deadband::m_lastState
bool m_lastState
Definition
deadband.h:33
Deadband::gt
bool gt(float lhs, float rhs)
Definition
deadband.h:15
Deadband::lt
bool lt(float lhs, float rhs)
Definition
deadband.h:28
efilib.h
Generated on Sat Sep 27 2025 00:10:07 for rusEFI by
1.9.8