9 uint16_t double_click_interval,
10 uint16_t ultra_long_click_delay)
13 long_click_delay_{long_click_delay},
14 ultra_long_click_delay_{ultra_long_click_delay},
15 double_click_interval_{double_click_interval},
16 delayed_click_report_{NULL} {
36 "ClickType received PRESS on click count %d (millis: %ld, last release: "
59 ESP_LOGD(__FILENAME__,
60 "ClickType press is double click. Removed queued SingleClick "
71 ESP_LOGD(__FILENAME__,
72 "ClickType received UNPRESS for click count %d (millis: %ld, press "
84 "ClickType detected LongSingleClick (millis: %ld, press duration %ld "
93 "ClickType detected DoubleClick (millis: %ld, press duration %ld ms)",
102 uint64_t
const time_of_event = millis();
108 "ClickType detected SingleClick (millis: %ld, queue time: %ld, "
109 "press duration %ld ms)",
110 millis(),
static_cast<long>(time_of_event),
111 static_cast<long>(pd));
125 ESP_LOGW(__FILENAME__,
126 "ClickType detected UNPRESS with no pending PRESS (millis=%ld)",
133 5, [
this, value]() { this->
emit(value); });
146 "ClickType detected UltraLongSingleClick (millis: %ld, press duration "
161 String
const expected[] = {
"long_click_delay",
"ultra_long_click_delay",
162 "double_click_interval"};
163 for (
auto str : expected) {
164 if (!config[str].is<JsonVariant>()) {
175 return R
"({"type":"object","properties":{"long_click_delay":{"title":"Long Click Delay","type":"integer"},"double_click_interval":{"title":"Double Click Interval","type":"integer"},"ultra_long_click_delay":{"title":"Ultra Long Click Delay","type":"integer"}}})";
ClickType is a transform that consumes button clicks and translates them as events of type ClickTypes...
void emitDelayed(ClickTypes value)
elapsedMillis press_duration_
Timmer to time button presses.
virtual bool from_json(const JsonObject &config) override
elapsedMillis release_duration_
Timer to time interval between button releases.
uint16_t long_click_delay_
void on_ultra_long_click()
reactesp::DelayEvent * delayed_click_report_
uint16_t double_click_interval_
ClickType(const String &config_path="", uint16_t long_click_delay=1300, uint16_t double_click_interval=400, uint16_t ultra_long_click_delay=5000)
virtual void set(const bool &input) override
void on_button_press()
Processes incoming values that represent a "ButonPress" event.
void on_button_release()
Processes incoming value that represent a "ButtonRelease" event.
void on_click_completed()
static bool is_click(ClickTypes value)
virtual bool to_json(JsonObject &root) override
uint16_t ultra_long_click_delay_
virtual bool load() override
Load and populate the object from a persistent storage.
void emit(const ClickTypes &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()