SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
voltage_multiplier.cpp
Go to the documentation of this file.
2
3namespace sensesp {
4
8
10 // Ohms Law at work!
11 this->emit(input * (((float)R1_ + (float)R2_) / (float)R2_));
12}
13
14void VoltageMultiplier::get_configuration(JsonObject& root) {
15 root["R1"] = R1_;
16 root["R2"] = R2_;
17};
18
19static const char SCHEMA[] PROGMEM = R"###({
20 "type": "object",
21 "properties": {
22 "R1": { "title": "R1", "type": "number", "description": "The measured value of resistor R1" },
23 "R2": { "title": "R2", "type": "number", "description": "The measured value of resistor R2" }
24 }
25 })###";
26
27String VoltageMultiplier::get_config_schema() { return FPSTR(SCHEMA); }
28
29bool VoltageMultiplier::set_configuration(const JsonObject& config) {
30 String expected[] = {"R1", "R2"};
31 for (auto str : expected) {
32 if (!config.containsKey(str)) {
33 return false;
34 }
35 }
36 R1_ = config["R1"];
37 R2_ = config["R2"];
38 return true;
39}
40
41} // namespace sensesp
Construct a new transform based on a single function.
virtual void set_input(float input, uint8_t inputChannel=0)
VoltageMultiplier(uint16_t R1, uint16_t R2, String config_path="")
const uint8_t PAGE_css_bootstrap[] PROGMEM