You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Functions to_json() and from_json() MUST be public :
template <classT>
classDebounce : publicSymmetricTransform<T> {
public:Debounce(int ms_min_delay = 15, String config_path = "")
: SymmetricTransform<T>(config_path), ms_min_delay_{ms_min_delay} {
this->load();
}
virtualvoidset(const T& input) override {
// Input has changed since the last emit, or this is the first// input since the program started to run.if (input != debounced_value_ || !value_received_) {
debounced_value_ = input;
if (event_) {
event_->remove(event_loop());
event_ = nullptr;
}
event_ = event_loop()->onDelay(ms_min_delay_, [this, input]() {
this->event_ = nullptr;
this->debounced_value_ = input;
this->emit(input);
});
value_received_ = true;
}
}
virtualboolto_json(JsonObject& doc) override {
doc["min_delay"] = ms_min_delay_;
returntrue;
}
virtualboolfrom_json(const JsonObject& config) override {
const String expected[] = {"min_delay"};
for (auto str : expected) {
if (!config[str].is<JsonVariant>()) {
returnfalse;
}
}
ms_min_delay_ = config["min_delay"];
returntrue;
}
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; } virtual bool from_json(const JsonObject& config) override { const String expected[] = {"min_delay"}; for (auto str : expected) { if (!config[str].is<JsonVariant>()) { return false; } } ms_min_delay_ = config["min_delay"]; return true; }*/
};
2. ConfigSchema MUST be a template and not only a Debounce<bool> :
//const String ConfigSchema(const Debounce<bool>& obj);template <typename T>
const String ConfigSchema(const Debounce<T>& obj) {
returnR"({ "type": "object", "properties": { "min_delay": { "title": "Minimum delay", "type": "number", "description": "The minimum time in ms between inputs for output to happen" } } })";
}
3. debounce.cpp SHOULD be removed as it remains nothing in this file :
/*#include "debounce.h"namespace sensesp {const String ConfigSchema(const Debounce<bool>& 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*/
The text was updated successfully, but these errors were encountered:
The Debounce class needs to be rewritten for ConfigItem compatibility (SensESP >= 3.0.0).
https://signalk.org/SensESP/generated/docs/debounce_8h_source.html
1. Functions to_json() and from_json() MUST be public :
2. ConfigSchema MUST be a template and not only a
Debounce<bool>
:3. debounce.cpp SHOULD be removed as it remains nothing in this file :
The text was updated successfully, but these errors were encountered: