Fix masks to make press/release/up/down consistent#3
Open
davidc wants to merge 4 commits intobrooksbUWO:mainfrom
Open
Fix masks to make press/release/up/down consistent#3davidc wants to merge 4 commits intobrooksbUWO:mainfrom
davidc wants to merge 4 commits intobrooksbUWO:mainfrom
Conversation
…r latest Arduino and ESP-IDF.
… pattern matches the article with don't-cares in the middle. Fix isUp/isDown to react as quickly as press/release and reflect the same state.
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.
#2 will need merging first.
Fixes part of #1
The second issue, press and release being sent simultaneously, was due to the masks being all wrong.
You're masking off only the latest 6 bits, but we actually care about both the oldest (highest) bits and the newest (lowest) bits, with some "don't cares" in the middle, as referenced in the Hackaday article. I've adjusted the masks to suit
However, in the case of PATTERN_DOWN/PATTERN_UP, we do want to be looking at only those last 6 bits, so it changes state as quickly as a press/release event does. Otherwise if you're waiting for all 16 bits, you could be in a situation where a button is pressed, a press event is generated, but isUp/isDown is out of sync until an additional 10 cycles have passed! In this case we need an additional mask, which I've added.
I'm sending a pull request, I've kept the masks as pure binary as then they're much more human readable, there's no risk of them getting out of sync with the comments, and there's no performance penalty to doing so. I've also updated the documentation to match.