SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
ui_controls.cpp
Go to the documentation of this file.
1#include "ui_controls.h"
2
3#include <Arduino.h>
4
5namespace sensesp {
6
7bool StringConfig::to_json(JsonObject& doc) {
8 doc["value"] = value_;
9 return true;
10}
11
12bool StringConfig::from_json(const JsonObject& config) {
13 if (!config["value"].is<String>()) {
14 return false;
15 }
16
17 value_ = config["value"].as<String>();
18
19 return true;
20}
21
22bool NumberConfig::to_json(JsonObject& doc) {
23 doc["value"] = value_;
24 return true;
25}
26
27bool NumberConfig::from_json(const JsonObject& config) {
28 if (!config["value"].is<float>()) {
29 return false;
30 }
31
32 value_ = config["value"];
33
34 return true;
35}
36
37bool CheckboxConfig::to_json(JsonObject& doc) {
38 doc["value"] = value_;
39 return true;
40}
41
42bool CheckboxConfig::from_json(const JsonObject& config) {
43 if (!config["value"].is<bool>()) {
44 return false;
45 }
46
47 value_ = config["value"];
48
49 return true;
50}
51
52bool SelectConfig::to_json(JsonObject& doc) {
53 doc["value"] = value_;
54 return true;
55}
56
57bool SelectConfig::from_json(const JsonObject& config) {
58 if (!config["value"].is<String>()) {
59 return false;
60 }
61
62 value_ = config["value"].as<String>();
63
64 return true;
65}
66
67} // namespace sensesp
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &doc) override
virtual bool to_json(JsonObject &doc) override
virtual bool from_json(const JsonObject &config) override
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &doc) override
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &doc) override