3#include <elapsedMillis.h>
4#include <FunctionalInterrupt.h>
10void DigitalInputState::get_configuration(JsonObject& root) {
11 root[
"read_delay"] = read_delay_;
14static const char SCHEMA2[]
PROGMEM = R
"###({
17 "read_delay": { "title": "Read delay", "type": "number", "description": "The time, in milliseconds, between each read of the input" }
21String DigitalInputState::get_config_schema() { return FPSTR(SCHEMA2); }
23bool DigitalInputState::set_configuration(
const JsonObject& config) {
24 String expected[] = {
"read_delay"};
25 for (
auto str : expected) {
26 if (!config.containsKey(str)) {
30 read_delay_ = config[
"read_delay"];
34void DigitalInputCounter::get_configuration(JsonObject& root) {
38static const char SCHEMA[]
PROGMEM = R
"###({
41 "read_delay": { "title": "Read delay", "type": "number", "description": "The time, in milliseconds, between each read of the input" }
45String DigitalInputCounter::get_config_schema() { return FPSTR(SCHEMA); }
47bool DigitalInputCounter::set_configuration(
const JsonObject& config) {
48 String expected[] = {
"read_delay"};
49 for (
auto str : expected) {
50 if (!config.containsKey(str)) {
58void DigitalInputDebounceCounter::handleInterrupt() {
59 if (since_last_event_ > ignore_interval_ms_) {
61 since_last_event_ = 0;
65void DigitalInputDebounceCounter::get_configuration(JsonObject& root) {
67 root[
"ignore_interval"] = ignore_interval_ms_;
70static const char DEBOUNCE_SCHEMA[]
PROGMEM = R
"###({
73 "read_delay": { "title": "Read delay", "type": "number", "description": "The time, in milliseconds, between each read of the input" },
74 "ignore_interval": { "title": "Ignore interval", "type": "number", "description": "The time, in milliseconds, to ignore events after a recorded event" }
78String DigitalInputDebounceCounter::get_config_schema() {
79 return FPSTR(DEBOUNCE_SCHEMA);
82bool DigitalInputDebounceCounter::set_configuration(
const JsonObject& config) {
83 String expected[] = {
"read_delay",
"ignore_interval"};
84 for (
auto str : expected) {
85 if (!config.containsKey(str)) {
87 "Cannot set DigitalInputDebounceConfiguration configuration: missing "
95 ignore_interval_ms_ = config[
"ignore_interval"];
100 ReactESP::app->onInterrupt(
pin_, interrupt_type_, [
this]() {
105 ReactESP::app->onTick([
this]() {
106 if (triggered_ && (
output != last_output_)) {
const uint8_t PAGE_css_bootstrap[] PROGMEM