• Hello, i'm new here and i dont' understanding the aim of 'debounce' with Puck.js. I would like to send info when the puck is clicked, when I click once, it is as if I had clicked 5 times. How can i set an interval between two clicks ? I think the actual delay is too short. This is an exemple :

    setWatch(function() {
      console.log("Pressed");
    }, BTN, {edge:"rising", debounce:50, repeat:true});
    

    Thanks for your help :)

  • Every electro mechanical switch bounce, that means that the on and off transition is not a single flank but a sequence of ons and offs until the switch settles to a steady on or off status.

    The debouncing catches the first state change and then 'waits' a bit and checks again to consider it a state change and assesses what the final state is. In other words, the debounce option makes it easy for the program to overcome the flaws of switches. Some switches bounce more than others.

    By default, Espruino board built-in (mounted) switches use the debounce:10 option on the setWatch(...) even if you do not code it. For externally connected and watched switches (or signals in general), you have to define the debounce:## option yourself.

    For something you like you try to do, take a look at this conversation: Software Buttons - Many buttons from just one hardware button. The 'module' can figure sequences of long and short presse and pauses between these sequences following the concept of Morse Code. Long vs. Short press and the pauses between the presses of a sequence as well as the pause between sequences are configurable. The 'module' also detects sequences out of the order and ignores them as a whole.

  • Thanks for your answer, this will help me a lot ! Have a great day :)

  • @user142416, enjoy the updated code (post #29... could not test it yet, though... if it does not work, used what is in post #25).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

What is the aim of 'debounce' ? How can i set a interval between two clicks with Puck JS ?

Posted by Avatar for user142416 @user142416

Actions