Hardware I/O updates#4931
Conversation
This function is used like this: GPIO.waitFor(pin number, rising/falling/change, timeout or -1) While it's using an interrupt internally, in the way it is used it doesn't relate to the interrupt functions (attachInterrupt, etc) at all. To prevent confusion, rename it to waitFor. (Another possible name would be waitForPin.)
This provided constants that translated from the physical header pin numbers to GPIO lines. Instead, we (and the majority of other Pi related documentation out there) now just use GPIO numbers exclusively. The class hasn't been used in examples since a few versions, and also wasn't ever properly documented in the reference, so unlikely that many people will notice.
|
@benfry What kind of vibes are you getting from |
|
Are there other things you'd be waiting on other than interrupts? Is there a simpler way of saying "interrupt" or is that the language that folks will see/use in this context 100% of the time anyway? |
|
@benfry Thinking that The function would just make this more readable by turning it into Which can be optionally abort after a timeout as to not block program execution forever Right now the function returns a boolean indicating success or failure, but I guess a way nicer way would be to throw an exception. This way a giant block of GPIO code could just be wrapped in a big |
|
Yeah, that's what I'm trying to get at… the We go out of our way to avoid exceptions for day-to-day functions—they're only in the API for advanced features like |
|
I wouldn't require the exception to be handled by the sketch code, but - thinking aloud - this would be the simplest case: Pin never rises? Well, then we're stuck here forever. Not the end of the world. Hit stop, figure out what's going on, etc. If we want to handle this case, and not use exceptions, then I fear people will have to use it like this: Which might be okay once, but not so nice if there are multiple of these after each other. If And if one of these ever takes longer than the 10 milliseconds we get a nice big error in the message area, that immediately points the user to the right line, and says "something here took longer than you said it would". Wish I had this when coding Arduino :) And the most advanced users could still use something more elaborate like Looks good? And about the name? |
This simplifies the semantic of the variant with three arguments, since we now don't have the "-1 means wait forever" case any longer.
Previously, it returned a boolean indicating success. But the code on the caller-side will be nicer to read with exceptions.
|
Would a callback be better? We have lame callbacks by using (public) function names (see |
|
I still believe the error in the message area (that can optionally be circumvented with |
Hardcode i2c interface, add background, fix indentation
This makes bright pixels be illuminated on the display.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Different updates to the IO library that came up while writing the chapter on Hardware I/O.