Feature: Configurable interval for retriggerable long clicks#90
Closed
michpro wants to merge 1 commit intoLennartHennigs:masterfrom
Closed
Feature: Configurable interval for retriggerable long clicks#90michpro wants to merge 1 commit intoLennartHennigs:masterfrom
michpro wants to merge 1 commit intoLennartHennigs:masterfrom
Conversation
This was referenced Mar 17, 2026
Owner
|
Thanks for this PR! The sentinel-value approach here ( I've opened #91 as a hybrid — it takes the cleaner implementation approach from this PR and combines it with the bundled API style from #86 ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Currently, when using
setLongClickDetectedRetriggerable(true), the interval between consecutive long click events is strictly bound to the initiallongclick_time_ms.In many UX scenarios, users expect a longer initial threshold to prevent accidental triggers (e.g., hold for 3 seconds to start an action) but a much faster retrigger interval while the button is held down (e.g., continuous scrolling every 500ms).
Hardware Compatibility Issue (Capacitive Sensors): This strict coupling also creates issues with popular capacitive touch sensor modules like the TTP223. These chips automatically recalibrate after being touched continuously for about 16 seconds, effectively cutting off the signal even if the user is still touching the sensor. If a developer sets a long initial press time (e.g., 3-4 seconds) to avoid accidental triggers, they would only get 3 to 4 retrigger events before the hardware forcibly ends the press state.
Solution
This PR introduces the ability to decouple the initial long press detection time from the continuous retrigger interval. This solves the hardware limitation mentioned above, allowing developers to trigger multiple fast events within the sensor's physical 16-second active window, while maintaining a safe, long initial hold threshold.
longclick_interval_msproperty.setLongClickInterval(unsigned int ms)andgetLongClickInterval()._checkForLongClick()to calculate timing based on the new interval.Backward Compatibility: 100% maintained. If
setLongClickInterval()is not explicitly called, the algorithm automatically falls back to usinglongclick_time_msas the interval, preserving the exact behavior of existing sketches.Example
A new example sketch (
LongpressRetriggerInterval.ino) has been added to demonstrate this behavior: