You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • What happens if you change:

    setWatch(function () {
    doorOpenedHandler();
    }, door, {repeat: true, edge: "falling", debounce: 0});
    
    setWatch(function () {
    doorClosedHandler();
    }, door, {repeat: true, edge: "rising", debounce: 0});
    

    into

    setWatch(function (e) {
    if (e.state) doorOpenedHandler();
    else doorClosedHandler();
    }, door, {repeat: true, edge: "both", debounce: 0});
    

    Not sure, but it would be interesting to see.

    I don't think the issue is that the queue is overflowing (you'd see with E.getErrorFlags() if it was). It's just that the signal is may be changing very quickly, so by the time there is an IRQ and Espruino reads the pin state, the pin state has changed (although that should mean that the last setWatch that happens is correct).

About

Avatar for Gordon @Gordon started