8static const char DEBOUNCE_SCHEMA[]
PROGMEM = R
"###({
11 "min_delay": { "title": "Minimum delay", "type": "number", "description": "The minimum time in ms between inputs for output to happen" }
51 if (input != debounced_value_ || !value_received_) {
52 debounced_value_ = input;
58 reaction_ = ReactESP::app->onDelay(ms_min_delay_, [
this, input]() {
59 this->reaction_ =
nullptr;
60 this->debounced_value_ = input;
63 value_received_ =
true;
69 bool value_received_ =
false;
73 doc[
"min_delay"] = ms_min_delay_;
76 virtual bool set_configuration(
const JsonObject& config)
override {
77 String expected[] = {
"min_delay"};
78 for (
auto str : expected) {
79 if (!config.containsKey(str)) {
83 ms_min_delay_ = config[
"min_delay"];
87 virtual String get_config_schema()
override {
return FPSTR(DEBOUNCE_SCHEMA); }
virtual void load_configuration()
Implements debounce code for a button or switch.
DebounceTemplate(int ms_min_delay=15, String config_path="")
virtual void set_input(T input, uint8_t input_channel=0) override
const uint8_t PAGE_css_bootstrap[] PROGMEM
DebounceTemplate< float > DebounceFloat
DebounceTemplate< bool > Debounce
DebounceTemplate< bool > DebounceBool
DebounceTemplate< int > DebounceInt