You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • 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());).

    If it's more than 10ms I'd use setWatch though

About

Avatar for Gordon @Gordon started