0

I have something feeding commands into a nodejs program through noble (its talking to a BLE device that has a serial service), and I'd like to write a bit of a debounce / smooth. So for example:

"If [x-command] comes in more than 2 times in under [x-mills] set a flag to true."

What would be some ways to do this? ie: use an array for samples? write a timeout? etc.

mishap_n
  • 578
  • 2
  • 10
  • 23

1 Answers1

0

I think the simple way is: store time of last call for each command in global array and compare stored time and current on new command. Also you can don't override stored time if bounce is detect.

Aikon Mogwai
  • 4,954
  • 2
  • 18
  • 31