SensESP
2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
hysteresis.h
Go to the documentation of this file.
1
#ifndef _hysteresis_H_
2
#define _hysteresis_H_
3
4
#include "
lambda_transform.h
"
5
6
namespace
sensesp
{
7
8
// Web UI parameter name definition
9
const
ParamInfo
hysteresis_param_info
[4] = {
10
{
"lower_threshold"
,
"Lower threshold"
},
11
{
"upper_threshold"
,
"Upper threshold"
},
12
{
"low_output"
,
"Low output"
},
13
{
"high_output"
,
"High output"
}};
14
31
template
<
class
IN,
class
OUT>
32
// Hysteresis inherits from a specialized LambdaTransform type
33
class
Hysteresis
:
public
LambdaTransform
<IN, OUT, IN, IN, OUT, OUT> {
34
public
:
35
Hysteresis
(
IN
lower_threshold
,
IN
upper_threshold
,
OUT
low_output
,
36
OUT
high_output
,
String
config_path
=
""
)
37
:
LambdaTransform
<
IN
,
OUT
,
IN
,
IN
,
OUT
,
OUT
>(
38
// the lambda function needs to be defined in this awkward
39
// location because it needs to be able to capture `this`
40
[
this
](
IN
input,
IN
lower_threshold
,
IN
upper_threshold
,
41
OUT
low_output
,
OUT
high_output
) {
42
if
(input <
lower_threshold
) {
43
this->last_value_ =
low_output
;
44
}
else
if
(
upper_threshold
<= input) {
45
this->last_value_ =
high_output
;
46
}
47
// If neither of the above conditions were met, input is between
48
// the lower and upper thresholds (in the hysteresis region)
49
return
this->last_value_;
50
},
51
lower_threshold
,
upper_threshold
,
low_output
,
high_output
,
52
hysteresis_param_info
,
config_path
) {}
53
54
private
:
55
OUT last_value_;
56
};
57
58
}
// namespace sensesp
59
#endif
sensesp::Hysteresis
Hysteresis function.
Definition
hysteresis.h:33
sensesp::Hysteresis::Hysteresis
Hysteresis(IN lower_threshold, IN upper_threshold, OUT low_output, OUT high_output, String config_path="")
Definition
hysteresis.h:35
sensesp::LambdaTransform
Construct a new transform based on a single function.
Definition
lambda_transform.h:71
lambda_transform.h
sensesp
Definition
sensesp.h:22
sensesp::hysteresis_param_info
const ParamInfo hysteresis_param_info[4]
Definition
hysteresis.h:9
sensesp::ParamInfo
Definition
lambda_transform.h:43
src
sensesp
transforms
hysteresis.h
Generated by
1.9.8