Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add getDirection() support to ModulinoKnob and example ⚑ #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

AntonioBerna
Copy link
Contributor

@AntonioBerna AntonioBerna commented May 1, 2025

πŸ“ Description

This PR introduces support for detecting rotation direction in the ModulinoKnob class via a new method:

  • βœ… getDirection() returns 1 for clockwise, -1 for counter-clockwise, and 0 when no movement is detected (debounced).
  • 🧠 Internal debouncing is handled via DEBOUNCE_DELAY to avoid noisy reads.
  • πŸ› οΈ The begin() logic now initializes internal state (_lastPosition, _lastDebounceTime) accordingly.
  • πŸ§ͺ The basic example sketch has been updated to demonstrate the use of getDirection().

πŸ” Related Work

Fixed #9

Added support for character and string-based input to `isPressed()` in `ModulinoButtons`,
so it now accepts both index (0–2) and letter identifiers (`'A'`, `'B'`, `'C'`) matching
the physical button labeling.

Closes arduino-libraries#3
@per1234 per1234 added the enhancement New feature or request label May 2, 2025
@leonardocavagnis leonardocavagnis self-requested a review May 8, 2025 14:08
Copy link
Contributor

@leonardocavagnis leonardocavagnis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contribution!
Please, take a look to my review. Minor fixes

.gitignore Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file.
It is already included in the PR #33

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this file :)
this modifies doesn't add any feature to the PR

src/Modulino.h Outdated
@@ -255,12 +256,27 @@ class ModulinoKnob : public Module {
}
return ret;
}
int16_t get() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it.
it is already included in the PR #32

src/Modulino.h Outdated
uint8_t buf[3];
auto res = read(buf, 3);
if (res == false) {
return 0;
}
get(buf);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here
it is already included in the PR #32

@AntonioBerna
Copy link
Contributor Author

@leonardocavagnis I apologize for creating problems with the files but I had accidentally merged the changes of PR #33 into the main branch of the Modulino repository fork and when I created the branch for PR #34 the changes were automatically added.

With commit 66200f1 this PR is affected to pull request is merged indirectly or is still processing updates.

For this reason with commit cff95ab everything should be fixed correctly.

I remain waiting for further developments. Enjoy πŸŽ‰

Copy link
Contributor

@leonardocavagnis leonardocavagnis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@leonardocavagnis leonardocavagnis merged commit 3c36732 into arduino-libraries:main May 9, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add function for Modulino Knob to detect direction
3 participants