SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
enable.h
Go to the documentation of this file.
1#ifndef _enable_H_
2#define _enable_H_
3
5
6namespace sensesp {
7
8static const char ENABLE_TRANSFORM_SCHEMA[] PROGMEM = R"({
9 "type": "object",
10 "properties": {
11 "enabled": { "type": "boolean", "title": "Enable", "description": "Enable or disable the transform output" }
12 }
13 })";
14
24template <typename T>
25class Enable : public Transform<T, T> {
26 public:
27 Enable(bool enabled = true, String config_path = "")
28 : Transform<T, T>(config_path) {
29 this->enabled_ = enabled;
30 this->load_configuration();
31 }
32 virtual void set_input(T input, uint8_t input_channel = 0) override {
33 if (enabled_) {
34 this->emit(input);
35 }
36 }
37 virtual void get_configuration(JsonObject& doc) override {
38 doc["enabled"] = enabled_;
39 }
40 virtual bool set_configuration(const JsonObject& config) override {
41 if (config.containsKey("enabled")) {
42 enabled_ = config["enabled"];
43 } else {
44 return false;
45 }
46 return true;
47 }
48 virtual String get_config_schema() override {
50 };
51
52 private:
53 bool enabled_;
54};
55
56} // namespace sensesp
57
58#endif
virtual void load_configuration()
On/off switch for signals: input is emitted as-is if the enable flag is set in the web UI.
Definition enable.h:25
Enable(bool enabled=true, String config_path="")
Definition enable.h:27
virtual void set_input(T input, uint8_t input_channel=0) override
Definition enable.h:32
virtual bool set_configuration(const JsonObject &config) override
Definition enable.h:40
virtual void get_configuration(JsonObject &doc) override
Definition enable.h:37
virtual String get_config_schema() override
Definition enable.h:48
Construct a new transform based on a single function.
The main Transform class. A transform is identified primarily by the type of value that is produces (...
Definition transform.h:54
void emit(T new_value)
const uint8_t PAGE_css_bootstrap[] PROGMEM