SensESP 3.3.0
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
45class [[deprecated("Use RepeatSensor and Arduino analogReadMilliVolts() instead")]] AnalogInput : public FloatSensor {
46 public:
47 AnalogInput(uint8_t pin = A0, unsigned int read_delay = 200,
48 const String& config_path = "", float output_scale = 1024.);
49
50 virtual ~AnalogInput() {
51 if (repeat_event_ != nullptr) {
52 repeat_event_->remove(event_loop());
53 }
54 }
55
56 virtual bool to_json(JsonObject& root) override;
57 virtual bool from_json(const JsonObject& config) override;
58
59 protected:
60 uint8_t pin{};
61 unsigned int read_delay;
63 std::unique_ptr<BaseAnalogReader> analog_reader_{};
64 reactesp::RepeatEvent* repeat_event_ = nullptr;
65 void update();
66};
67
68const String ConfigSchema(AnalogInput& obj);
69
70inline bool ConfigRequiresRestart(const AnalogInput& obj) { return true; }
71
72} // namespace sensesp
73
74#endif
Sensor for reading the MCU analog input pins.
reactesp::RepeatEvent * repeat_event_
std::unique_ptr< BaseAnalogReader > analog_reader_
AnalogInput(uint8_t pin=A0, unsigned int read_delay=200, const String &config_path="", float output_scale=1024.)
unsigned int read_delay
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
Definition sensesp.cpp:9
Sensor< float > FloatSensor
Definition sensor.h:47
bool ConfigRequiresRestart(const HTTPServer &obj)