Have you looked at the signal with a scope? I guess there's probably quite a lot of noise.
It might be that the time taken to execute the code means that not everything gets processed in time and the input buffer overflows. You could check that with E.getErrorFlags()
You could try having a single watch (which would halve the effort Espruino was having to do). I'd suggested this code in another thread, and something like that might work?
Also, I'd really consider replacing:
b++;
if (b < 28){
n = (n<<1) | ((d>=0.0007)?1:0);
} else {
c = (c<<1) | ((d>=0.0007)?1:0);
}
with:
n="";
// ....
n+=(d>0.0007)?1:0;
and then just working out what c should be later on with .substr.
That'll execute a lot faster, and has the bonus that you can just check the length of 'n' rather than keeping a separate variable.
I guess you could also use an Espruino (or the same one?) to generate a signal - without using the radio modules. That way you can make sure the decoder works before you start having to deal with all the noise coming in.
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.
Have you looked at the signal with a scope? I guess there's probably quite a lot of noise.
It might be that the time taken to execute the code means that not everything gets processed in time and the input buffer overflows. You could check that with E.getErrorFlags()
You could try having a single watch (which would halve the effort Espruino was having to do). I'd suggested this code in another thread, and something like that might work?
Also, I'd really consider replacing:
with:
and then just working out what
c
should be later on with.substr
.That'll execute a lot faster, and has the bonus that you can just check the length of 'n' rather than keeping a separate variable.
I guess you could also use an Espruino (or the same one?) to generate a signal - without using the radio modules. That way you can make sure the decoder works before you start having to deal with all the noise coming in.