rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
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
10public:
11 static bool isBefore(float x, float y) { return std::isless(x, y); }
12};
13
15public:
16 static bool isBefore(float x, float y) { return std::islessequal(x, y); }
17};
18
20public:
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);
26private:
27 bool m_state = false;
28};
29
30template <typename RisingChecker, typename FallingChecker>
31bool Hysteresis::test(const float value, const float rising, const float falling) {
32 return test(RisingChecker::isBefore(rising, value), FallingChecker::isBefore(value, falling));
33}
bool m_state
Definition hysteresis.h:27
bool test(float value, float rising, float falling)
Definition hysteresis.h:31
static bool isBefore(float x, float y)
Definition hysteresis.h:11
static bool isBefore(float x, float y)
Definition hysteresis.h:16
union test_buffers test
Definition test.c:50