From a002292ad4377ccf54b0be244d9601383d8ba292 Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Thu, 12 Dec 2024 10:17:59 +0200 Subject: [PATCH] Fix Debounce configuration issues --- src/sensesp/transforms/debounce.cpp | 9 --------- src/sensesp/transforms/debounce.h | 16 ++++++++++------ 2 files changed, 10 insertions(+), 15 deletions(-) delete mode 100644 src/sensesp/transforms/debounce.cpp diff --git a/src/sensesp/transforms/debounce.cpp b/src/sensesp/transforms/debounce.cpp deleted file mode 100644 index fce2c717c..000000000 --- a/src/sensesp/transforms/debounce.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "debounce.h" - -namespace sensesp { - -const String ConfigSchema(const Debounce& obj) { - return R"###({"type":"object","properties":{"min_delay":{"title":"Minimum delay","type":"number","description":"The minimum time in ms between inputs for output to happen"}}})###"; -} - -} // namespace sensesp diff --git a/src/sensesp/transforms/debounce.h b/src/sensesp/transforms/debounce.h index 9377172eb..638e3b7b8 100644 --- a/src/sensesp/transforms/debounce.h +++ b/src/sensesp/transforms/debounce.h @@ -56,11 +56,6 @@ class Debounce : public SymmetricTransform { } } - private: - int ms_min_delay_; - bool value_received_ = false; - T debounced_value_; - reactesp::DelayEvent* event_ = nullptr; virtual bool to_json(JsonObject& doc) override { doc["min_delay"] = ms_min_delay_; return true; @@ -76,9 +71,18 @@ class Debounce : public SymmetricTransform { ms_min_delay_ = config["min_delay"]; return true; } + + protected: + int ms_min_delay_; + bool value_received_ = false; + T debounced_value_; + reactesp::DelayEvent* event_ = nullptr; }; -const String ConfigSchema(const Debounce& obj); +template +const String ConfigSchema(const Debounce& obj) { + return R"###({"type":"object","properties":{"min_delay":{"title":"Minimum delay","type":"number","description":"The minimum time in ms between inputs for output to happen"}}})###"; +} typedef Debounce DebounceBool; typedef Debounce DebounceInt;