SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
difference.cpp
Go to the documentation of this file.
1#include "difference.h"
2
3namespace sensesp {
4
5// Difference
6
8 : FloatTransform(config_path), k1{k1}, k2{k2} {
10}
11
13 inputs[inputChannel] = input;
14 received |= 1 << inputChannel;
15 if (received == 0b11) {
16 received = 0;
17 this->emit(k1 * inputs[0] - k2 * inputs[1]);
18 }
19}
20
22 root["k1"] = k1;
23 root["k2"] = k2;
24}
25
26static const char SCHEMA[] PROGMEM = R"({
27 "type": "object",
28 "properties": {
29 "k1": { "title": "Input #1 multiplier", "type": "number" },
30 "k2": { "title": "Input #2 multiplier", "type": "number" }
31 }
32 })";
33
35
37 String expected[] = {"k1", "k2"};
38 for (auto str : expected) {
39 if (!config.containsKey(str)) {
40 return false;
41 }
42 }
43 k1 = config["k1"];
44 k2 = config["k2"];
45 return true;
46}
47
48} // namespace sensesp
virtual void load_configuration()
virtual bool set_configuration(const JsonObject &config) override
Difference(float k1, float k2, String config_path="")
Definition difference.cpp:7
virtual void get_configuration(JsonObject &doc) override
virtual void set_input(float input, uint8_t inputChannel) override
virtual String get_config_schema() override
Construct a new transform based on a single function.
const uint8_t PAGE_css_bootstrap[] PROGMEM