-
Notifications
You must be signed in to change notification settings - Fork 41
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
Pin::getEdge/setEdge #4
Comments
Let me give this some thought! Trying to decide if this is best as a parameter to |
I think my main concern about having this is an I'm leaning towards methods on an |
I feel it's more logical to define the edge you're interested in detecting at the same time you're registering the callback to handle occurrences of that edge. For example, let's say I want a callback to fire whenever a button is pressed. I'd want to listen for any FALLING (or RISING) events and do some action. However, hooking that same callback up to a pin set to BOTH means the callback would fire twice. If I forget to set the pin's edge beforehand, or if it's modified at some other point in time, my callback isn't going to work as expected. For Arduino, setting the edge is done when registering the interrupt callback: https://www.arduino.cc/en/Reference/AttachInterrupt RPi.GPIO does the same thing with their |
Edge detection is primarily used for interrupt detection - sometimes we only care about interrupts LOW -> HIGH for example. However, it looks like this is being set via the
Pin
class (and can be done for output pins, which isn't useful). Would it make more sense to set this on the interrupt watcher instead?The text was updated successfully, but these errors were encountered: