6 const String& config_path)
12 if (Vout == 0.0f)
return;
23 String
const expected[] = {
"Vin",
"R2"};
24 for (
auto str : expected) {
25 if (!config[str].is<JsonVariant>()) {
28 "Cannot set VoltageDividerR1: configuration: missing json field %s\n",
41 return R
"({"type":"object","properties":{"Vin":{"title":"Voltage in","type":"number"},"R2":{"title":"Resistance (ohms) of R2","type":"number"}}})";
45 const String& config_path)
51 if (
Vin_ == Vout)
return;
62 String
const expected[] = {
"Vin",
"R1"};
63 for (
auto str : expected) {
64 if (!config[str].is<JsonVariant>()) {
67 "Cannot set VoltageDividerR2: configuration: missing json field %s\n",
80 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)