var now = getTime();
var pulsetime = now - lastpulse;
If this gets called twice in quick succession then the second time it's called you'll get a very small time period reported. setWatch does actually have an option called debounce that will automatically discount any spikes off less than the given length in milliseconds, so you could try that
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.
I'd imagine the issue is:
If this gets called twice in quick succession then the second time it's called you'll get a very small time period reported.
setWatch
does actually have an option calleddebounce
that will automatically discount any spikes off less than the given length in milliseconds, so you could try that