Since Espruino does not support interrupt directly and setWatch callback only executes in main loop, I only see only option to setup the IRQ option in setWatch
Realistically the vast majority of hardware is absolutely fine waiting a little while after asserting the IRQ line - you don't generally need to jump in and do stuff immediately, and executing in the main loop is fine.
Having said that, generally when I'm writing modules, if I'm only expecting to wait for a few milliseconds (eg. ~10ms) then I'll just add a while (pin.read()); as you suggest (ideally with a timeout - so var timeout=100;while (--timeout && pin.read());).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Realistically the vast majority of hardware is absolutely fine waiting a little while after asserting the IRQ line - you don't generally need to jump in and do stuff immediately, and executing in the main loop is fine.
Having said that, generally when I'm writing modules, if I'm only expecting to wait for a few milliseconds (eg. ~10ms) then I'll just add a
while (pin.read());
as you suggest (ideally with a timeout - sovar timeout=100;while (--timeout && pin.read());
).If it's more than 10ms I'd use
setWatch
though