Closed IllyaMoskvin closed 5 years ago
Already implemented in PR #27, but that doesn't feel like the cleanest way of going about it. Also, it's out of date and has merge conflicts with the current master. I might be biased due to style issues though.
Checking the network, it looks like @PatrickGlatz added new states to support triple click. See relevant commits and change comparison. Not a generalized implementation, but looks solid if all you need is a triple click.
I added #27 and it works fine for one additional method, but no more. In other words, 3 or 4 clicks can be added, but adding both only leaves the last one added working.
Leaving the original methods and adding this idea to specify number of clicks seems to be the perfect solution. Backward compatibility for me is not an issue since it is so easy to update the method syntax.
single and double clicks are the usual interactions we know from the web. long press and hold is there as well. That's what the library was created for. I lik to stay with this functionality because I personally don't like libraries that are huge just because they cover a lot of cases e.g. use them in a Tiny85 processor will be problematic. Extending as you did is exactly what should be done on a project basis.
Thanks for the reply, @mathertel. I understand where you're coming from with regard to wanting to keep the library lightweight. I do think that the attachMultiClick
approach I described in the opening post is a generalization. Extending the current pattern to accommodate these use-cases does not feel like the best way to handle this. A refactor would be necessary. If implemented correctly, it may result in a smaller codebase. However, I think it may also require fundamental changes to the code that may result in it no longer being a finite state machine. Given this fact, I understand why you chose to close this issue. Supporting this functionality may not be in scope for this library.
For the project I've built, I ended up using @PatrickGlatz's fork. I had a need for triple-click, but no more. For the curious, my project's source code can be found here:
https://github.com/IllyaMoskvin/aic-nixie/blob/master/NixieMain/NixieMain.ino
It would be nice if this library could support triple clicks, quadruple clicks, etc.
Tentatively, it doesn't seem as if it'd be too hard to do this in a backwards-compatible way. I'd like to try to implement it. I recently made a project with a really nice wooden case, but only one button, so I'm pretty invested in seeing how much functionality can be squeezed out of a single button.
Would you be interested in accepting a pull request that solves this issue?
If so, in terms of approach, what are your thought about the following API?
I figure
attachClick
andattachDoubleClick
can callattachMultiClick
behind-the-scenes.Probably related to the need behind #42.