All of the examples that I've seen for reading GPIO in Mathematica use polling loops of the form:
While[ True, If[DeviceRead["GPIO", pin] ... (*meets some criterion*) (*do something*) ] ]
Instead of this, has anybody tried writing doing event-driven GPIO on Raspberry Pi?
For example, in the popular GPIOzero library in python, it is common to write things like:
from gpiozero import Button, LED from signal import pause button = Button(22) def buttonAction1(): print("Button is pressed") def buttonAction2(): print("Button is released") button.when_pressed = buttonAction1 button.when_released = buttonAction2 pause()
where the functions get called when an event occurs (in this case, a button being pressed or released)
Are there any examples of event-driven GPIO in Mathematica?
I suppose this would be analogous to the notebook-related function EventHandler but for GPIO.
On the other hand, I suppose it might be possible to take advantage of Dynamic functionality (and more specifically DynamicModule) to implement something like this.