rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
controllers
hysteresis.h
Go to the documentation of this file.
1
//
2
// Created by kifir on 8/23/24.
3
//
4
5
#pragma once
6
7
#include <cmath>
8
9
class
StrictChecker
{
10
public
:
11
static
bool
isBefore
(
float
x,
float
y) {
return
std::isless(x, y); }
12
};
13
14
class
UnstrictChecker
{
15
public
:
16
static
bool
isBefore
(
float
x,
float
y) {
return
std::islessequal(x, y); }
17
};
18
19
class
Hysteresis
{
20
public
:
21
// returns true if value > rising, false if value < falling, previous if falling < value < rising.
22
template
<
typename
RisingChecker = StrictChecker,
typename
FallingChecker = StrictChecker>
23
bool
test
(
float
value,
float
rising,
float
falling);
24
25
bool
test
(
bool
risingCondition,
bool
fallingCondition);
26
private
:
27
bool
m_state
=
false
;
28
};
29
30
template
<
typename
RisingChecker,
typename
FallingChecker>
31
bool
Hysteresis::test
(
const
float
value,
const
float
rising,
const
float
falling) {
32
return
test
(RisingChecker::isBefore(rising, value), FallingChecker::isBefore(value, falling));
33
}
Hysteresis
Definition
hysteresis.h:19
Hysteresis::m_state
bool m_state
Definition
hysteresis.h:27
Hysteresis::test
bool test(float value, float rising, float falling)
Definition
hysteresis.h:31
StrictChecker
Definition
hysteresis.h:9
StrictChecker::isBefore
static bool isBefore(float x, float y)
Definition
hysteresis.h:11
UnstrictChecker
Definition
hysteresis.h:14
UnstrictChecker::isBefore
static bool isBefore(float x, float y)
Definition
hysteresis.h:16
test
union test_buffers test
Definition
test.c:50
Generated on Sat Sep 27 2025 00:10:06 for rusEFI by
1.9.8