Avoid initial message for GPIO interrupt pins
Closed this issue · 1 comments
I have configured an interrupt pin as follows:
int_pid = Process.whereis( InterruptPin )
Gpio.set_int(int_pid, :falling)
However when my app starts up, I'm seeing a :rising
message, which is confusing.
Another user who is listening for :both
mentioned:
upon the set_int you get a message with the current state. And as my purpose is a push button I am not interested in that state, it could trigger code that shouldn’t run.
@fhunleth wrote:
the "initial message" is supposed to be a feature. It prevents the race condition between getting the initial state of the pin and turning on interrupts. E.g., without it, you could get the state of the pin, it could change states, and then you could start waiting on it for interrupts. If that happened, you'd be out of sync.
I've wondered whether this should be configurable. I hadn't added it, since for my use cases I was more interested in the level of the pin rather than the actual event. If you're truly only interested in transitions, then I agree that the initial notification is bogus. I think it's worth an Issue or a PR. Everyone who's interested in the level of the pin will ask for:both
rather than:rising
or:falling
.
I think we can close this.