SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
threshold.cpp
Go to the documentation of this file.
1#include "threshold.h"
2
3namespace sensesp {
4
5template <class C, class P>
7 if (input >= min_value_ && input <= max_value_) {
8 this->output = in_range_;
9 } else {
10 this->output = !in_range_;
11 }
12
13 this->notify();
14}
15
17 root["min"] = min_value_;
18 root["max"] = max_value_;
19 root["in_range"] = in_range_;
20}
21
22static const char FLOAT_SCHEMA[] PROGMEM = R"({
23 "type": "object",
24 "properties": {
25 "min": { "title": "Minimum value", "type": "number", "description" : "Minimum value to be 'in range'" },
26 "max": { "title": "Maximum value", "type": "number", "description" : "Maximum value to be 'in range'" },
27 "in_range": { "title": "In range value", "type": "boolean", "description" : "Output value when input value is 'in range'" }
28 }
29 })";
30
32 String expected[] = {"min", "max", "in_range"};
33 for (auto str : expected) {
34 if (!config.containsKey(str)) {
35 return false;
36 }
37 }
38 min_value_ = config["min"];
39 max_value_ = config["max"];
40 in_range_ = config["in_range"];
41 return true;
42}
43
45
47 root["min"] = min_value_;
48 root["max"] = max_value_;
49 root["in_range"] = in_range_;
50}
51
52static const char INT_SCHEMA[] PROGMEM = R"({
53 "type": "object",
54 "properties": {
55 "min": { "title": "Minimum value", "type": "number", "description" : "Minimum value to be 'in range'" },
56 "max": { "title": "Maximum value", "type": "number", "description" : "Maximum value to be 'in range'" },
57 "in_range": { "title": "In range value", "type": "boolean", "description" : "Output value when input value is 'in range'" }
58 }
59 })";
60
62 String expected[] = {"min", "max", "in_range"};
63 for (auto str : expected) {
64 if (!config.containsKey(str)) {
65 return false;
66 }
67 }
68 min_value_ = config["min"];
69 max_value_ = config["max"];
70 in_range_ = config["in_range"];
71 return true;
72}
73
75
76} // namespace sensesp
virtual String get_config_schema() override
Definition threshold.cpp:44
virtual void get_configuration(JsonObject &doc) override
Definition threshold.cpp:16
virtual bool set_configuration(const JsonObject &config) override
Definition threshold.cpp:31
virtual bool set_configuration(const JsonObject &config) override
Definition threshold.cpp:61
virtual void get_configuration(JsonObject &doc) override
Definition threshold.cpp:46
virtual String get_config_schema() override
Definition threshold.cpp:74
Construct a new transform based on a single function.
virtual void set_input(C new_value, uint8_t input_channel=0) override
Definition threshold.cpp:6
const uint8_t PAGE_css_bootstrap[] PROGMEM