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
6namespace sensesp {
7
8// Web UI parameter name definition
10 {"lower_threshold", "Lower threshold"},
11 {"upper_threshold", "Upper threshold"},
12 {"low_output", "Low output"},
13 {"high_output", "High output"}};
14
31template <class IN, class OUT>
32// Hysteresis inherits from a specialized LambdaTransform type
33class Hysteresis : public LambdaTransform<IN, OUT, IN, IN, OUT, OUT> {
34 public:
38 // the lambda function needs to be defined in this awkward
39 // location because it needs to be able to capture `this`
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 },
53
54 private:
55 OUT last_value_;
56};
57
58} // namespace sensesp
59#endif
Hysteresis function.
Definition hysteresis.h:33
Hysteresis(IN lower_threshold, IN upper_threshold, OUT low_output, OUT high_output, String config_path="")
Definition hysteresis.h:35
Construct a new transform based on a single function.
const ParamInfo hysteresis_param_info[4]
Definition hysteresis.h:9