6 const String& config_path)
22 String
const expected[] = {
"Vin",
"R2"};
23 for (
auto str : expected) {
24 if (!config[str].is<JsonVariant>()) {
27 "Cannot set VoltageDividerR1: configuration: missing json field %s\n",
40 return R
"({"type":"object","properties":{"Vin":{"title":"Voltage in","type":"number"},"R2":{"title":"Resistance (ohms) of R2","type":"number"}}})";
44 const String& config_path)
60 String
const expected[] = {
"Vin",
"R1"};
61 for (
auto str : expected) {
62 if (!config[str].is<JsonVariant>()) {
65 "Cannot set VoltageDividerR2: configuration: missing json field %s\n",
78 return R
"({"type":"object","properties":{"Vin":{"title":"Voltage in","type":"number"},"R1":{"title":"Resistance (ohms) of R1","type":"number"}}})";
virtual bool load() override
Load and populate the object from a persistent storage.
void emit(const float &new_value)
Uses the voltage divider formula to calculate (and output) the resistance of R1 in the circuit.
virtual bool from_json(const JsonObject &config) override
virtual void set(const float &Vout) override
virtual bool to_json(JsonObject &root) override
VoltageDividerR1(float R2, float Vin=3.3, const String &config_path="")
Uses the voltage divider formula to calculate (and output) the resistance of R2 in the circuit.
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &root) override
VoltageDividerR2(float R1, float Vin=3.3, const String &config_path="")
virtual void set(const float &Vout) override
const String ConfigSchema(const SmartSwitchController &obj)