I have been experimenting with adding support for interrupts to uLisp, and I would be interested in any suggestions.
The idea is that your uLisp program will be able to respond to events such as button presses without having to wait in a loop testing the input.
The proposed format is:
(attach-interrupt interrupt function mode )
This will attach a function to an interrupt; the function is evaluated when the interrupt occurs. Note that the interrupt parameter should be the interrupt number, not the Arduino pin number.
The function should be a function of one argument; it will be called with the number of interrupts that have occurred since the last evaluation of the interrupt handling function; this will normally be 1, but may be more if the interrupt handling function took longer than the rate of interrupts. There may be a latency of a few milliseconds, because of garbage collection, before the interrupt gets handled, but it shouldn’t be possible to miss an interrupt.
The mode argument specifies which edge the interrupt is triggered on, like the Arduino function.