I'm not entirely sure you got my point about this. You set up peakafter accFiltered=0, so
when gate_open=true, peak is full of zeros and if the next sample is less than the first you get something like 0,20,19 in peak and that is enough to register as a step.
If you got rid of if (!gate_open) accFiltered = 0; and instead just had gate_open && peak[1] > peak[0] && peak[1] > peak[2] && accFiltered > stepCounterThreshold you wouldn't have the issue.
JS test harness would be good, but I guess if we have all the data, we already have a working test harness in https://github.com/gfwilliams/step-count that uses the actual C code from Bangle.js, so long-term it feels safer to use than than to maintain two different step counters - one in JS and one in C
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'm not entirely sure you got my point about this. You set up
peak
after accFiltered=0, sowhen gate_open=true,
peak
is full of zeros and if the next sample is less than the first you get something like0,20,19
inpeak
and that is enough to register as a step.If you got rid of
if (!gate_open) accFiltered = 0;
and instead just hadgate_open && peak[1] > peak[0] && peak[1] > peak[2] && accFiltered > stepCounterThreshold
you wouldn't have the issue.JS test harness would be good, but I guess if we have all the data, we already have a working test harness in https://github.com/gfwilliams/step-count that uses the actual C code from Bangle.js, so long-term it feels safer to use than than to maintain two different step counters - one in JS and one in C