1#ifndef SENSESP_SENSORS_DIGITAL_INPUT_H_
2#define SENSESP_SENSORS_DIGITAL_INPUT_H_
4#include <elapsedMillis.h>
23 pinMode(
pin_, pin_mode);
53 String config_path =
"")
56 read_delay_{read_delay},
61 [
this]() { this->
emit(digitalRead(
pin_)); });
67 virtual bool to_json(JsonObject& root)
override;
68 virtual bool from_json(
const JsonObject& config)
override;
96 unsigned int read_delay, String config_path =
"")
98 config_path, [this]() { this->
counter_++; }) {
99 event_loop()->onInterrupt(
pin_, interrupt_type_, interrupt_handler_);
110 virtual bool to_json(JsonObject& root)
override;
111 virtual bool from_json(
const JsonObject& config)
override;
115 unsigned int read_delay, String config_path,
116 std::function<
void()> interrupt_handler)
120 interrupt_type_{interrupt_type},
121 interrupt_handler_{interrupt_handler} {
130 std::function<void()> interrupt_handler_;
161 unsigned int read_delay,
162 unsigned int ignore_interval_ms,
163 String config_path =
"")
165 config_path, [this]() { this->handleInterrupt(); }),
166 ignore_interval_ms_{ignore_interval_ms} {}
169 void handleInterrupt();
171 unsigned int ignore_interval_ms_;
172 elapsedMillis since_last_event_;
173 virtual bool to_json(JsonObject& root)
override;
174 virtual bool from_json(
const JsonObject& config)
override;
177const String
ConfigSchema(
const DigitalInputDebounceCounter& obj);
204 String config_path =
"")
206 Sensor<bool>(config_path),
207 interrupt_type_{interrupt_type},
219 if (triggered_ && (
output_ != last_output_)) {
233 virtual bool to_json(JsonObject& doc)
override {
return true; }
234 virtual bool from_json(
const JsonObject& config)
override {
return true; }
virtual bool load() override
Load and populate the object from a persistent storage.
Sensor template class for any sensor producing actual values.
void emit(const bool &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
bool ConfigRequiresRestart(const HTTPServer &obj)