I'm using setWatch on an input that has 50hz pulses which are ~0.9ms wide. I was expecting to see two callbacks alternating true/false per pulse, one for each edge - but I actually see multiple successive true or false values. This seems strange.
My code
'''
var states=new Array();
var index=0;
function onpulse(e)
{
states.push(e);
if (index<100) index++;
}
I'm storing the state change data in an array to try to be sure I'm catching
all the events - I thought that printing them might cause some to be lost.
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.
Hi
I'm using setWatch on an input that has 50hz pulses which are ~0.9ms wide. I was expecting to see two callbacks alternating true/false per pulse, one for each edge - but I actually see multiple successive true or false values. This seems strange.
My code
'''
var states=new Array();
var index=0;
function onpulse(e)
{
states.push(e);
if (index<100) index++;
}
setWatch(onpulse,C5,{repeat:true,edge:'both',debounce:0});
'''
I'm storing the state change data in an array to try to be sure I'm catching
all the events - I thought that printing them might cause some to be lost.
The output I get looks like this
'''
What's puzzling me is that there doesn't seem to be any pattern - I was
expecting true,false, true, false...
Any ideas?
Martin