5#include <FunctionalInterrupt.h>
6#include <elapsedMillis.h>
10bool DigitalInputState::to_json(JsonObject& root) {
11 root[
"read_delay"] = read_delay_;
15bool DigitalInputState::from_json(
const JsonObject& config) {
16 String
const expected[] = {
"read_delay"};
17 for (
auto str : expected) {
18 if (!config[str].is<JsonVariant>()) {
22 read_delay_ = config[
"read_delay"];
32 String
const expected[] = {
"read_delay"};
33 for (
auto str : expected) {
34 if (!config[str].is<JsonVariant>()) {
42void DigitalInputDebounceCounter::handleInterrupt() {
43 if (since_last_event_ > ignore_interval_ms_) {
45 since_last_event_ = 0;
49bool DigitalInputDebounceCounter::to_json(JsonObject& root) {
51 root[
"ignore_interval"] = ignore_interval_ms_;
55bool DigitalInputDebounceCounter::from_json(
const JsonObject& config) {
56 String
const expected[] = {
"read_delay",
"ignore_interval"};
57 for (
auto str : expected) {
58 if (!config[str].is<JsonVariant>()) {
61 "Cannot set DigitalInputDebounceConfiguration configuration: missing "
69 ignore_interval_ms_ = config[
"ignore_interval"];
74 return R
"###({"type":"object","properties":{"read_delay":{"title":"Read delay","type":"number","description":"The time, in milliseconds, between each read of the input"}} })###";
82 return R
"###({"type":"object","properties":{"read_delay":{"title":"Read delay","type":"number","description":"The time, in milliseconds, between each read of the input"}} })###";
90 return R
"###({"type":"object","properties":{"read_delay":{"title":"Read delay","type":"number","description":"The time, in milliseconds, between each read of the input"},"ignore_interval":{"title":"Ignore interval","type":"number","description":"The time, in milliseconds, to ignore events after a recorded event"}} })###";
const String ConfigSchema(const SmartSwitchController &obj)
bool ConfigRequiresRestart(const HTTPServer &obj)