1#ifndef SENSESP_SENSORS_DIGITAL_INPUT_H_
2#define SENSESP_SENSORS_DIGITAL_INPUT_H_
4#include <elapsedMillis.h>
24 pinMode(
pin_, pin_mode);
54 String config_path =
"")
57 read_delay_{read_delay} {
60 repeat_event_ =
event_loop()->onRepeat(read_delay_,
61 [
this]() { this->
emit(digitalRead(
pin_)); });
65 if (repeat_event_ !=
nullptr) {
72 reactesp::RepeatEvent* repeat_event_ =
nullptr;
73 virtual bool to_json(JsonObject& root)
override;
74 virtual bool from_json(
const JsonObject& config)
override;
102 unsigned int read_delay, String config_path =
"")
117 virtual bool to_json(JsonObject& root)
override;
118 virtual bool from_json(
const JsonObject& config)
override;
129 unsigned int read_delay, String config_path,
130 std::function<
void()> interrupt_handler)
135 unsigned int read_delay, String config_path,
136 std::function<
void()> interrupt_handler,
141 interrupt_type_{interrupt_type},
142 interrupt_handler_{interrupt_handler} {
168 std::function<void()> interrupt_handler_;
199 unsigned int read_delay,
200 unsigned int ignore_interval_ms,
201 String config_path =
"")
203 config_path, [this]() { this->handleInterrupt(); },
205 ignore_interval_ms_{ignore_interval_ms} {
215 void handleInterrupt();
217 unsigned int ignore_interval_ms_;
218 elapsedMillis since_last_event_;
219 virtual bool to_json(JsonObject& root)
override;
220 virtual bool from_json(
const JsonObject& config)
override;
223const String
ConfigSchema(
const DigitalInputDebounceCounter& obj);
250 String config_path =
"")
252 Sensor<bool>(config_path),
253 interrupt_type_{interrupt_type},
259 isr_event_ =
event_loop()->onInterrupt(
pin_, interrupt_type_, [
this]() {
268 if (t && (val != last_output_)) {
280 if (tick_event_ !=
nullptr) {
283 if (isr_event_ !=
nullptr) {
292 reactesp::TickEvent* tick_event_ =
nullptr;
293 reactesp::ISREvent* isr_event_ =
nullptr;
294 virtual bool to_json(JsonObject& doc)
override {
return true; }
295 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.
virtual const T & get() const
void emit(const T &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
bool ConfigRequiresRestart(const HTTPServer &obj)