SensESP 3.6.1-alpha
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
analog_input.h
Go to the documentation of this file.
1#ifndef SENSESP_SENSORS_ANALOG_INPUT_H_
2#define SENSESP_SENSORS_ANALOG_INPUT_H_
3
4#include <memory>
5
6#include "ReactESP.h"
7#include "analog_reader.h"
9#include "sensor.h"
10
11namespace sensesp {
12
48class AnalogInput : public FloatSensor {
49 public:
50 AnalogInput(uint8_t pin = A0, unsigned int read_delay = 200,
51 const String& config_path = "", float output_scale = 1024.);
52
53 virtual ~AnalogInput() {
54 if (repeat_event_ != nullptr) {
55 repeat_event_->remove(event_loop());
56 }
57 }
58
59 virtual bool to_json(JsonObject& root) override;
60 virtual bool from_json(const JsonObject& config) override;
61
62 protected:
63 uint8_t pin_{};
64 unsigned int read_delay_;
66 std::unique_ptr<BaseAnalogReader> analog_reader_{};
67 reactesp::RepeatEvent* repeat_event_ = nullptr;
68 void update();
69};
70
71const String ConfigSchema(AnalogInput& obj);
72
73inline bool ConfigRequiresRestart(const AnalogInput& obj) { return true; }
74
75} // namespace sensesp
76
77#endif
Sensor for reading the MCU analog input pins.
reactesp::RepeatEvent * repeat_event_
std::unique_ptr< BaseAnalogReader > analog_reader_
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &root) override
unsigned int read_delay_
Sensor template class for any sensor producing actual values.
Definition sensor.h:42
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
Definition sensesp.cpp:9
bool ConfigRequiresRestart(const HTTPServer &obj)