PuckJS button event issues.

Posted on
  • Hi All,

    I am getting some issues with my code to handle the button event on the puck js. I think puck is too sensitive that its button event is fired even on movement of device. How can i improve this. Is their any documentation for what are all possible options we can pass to

    setWatch();
    

    Code which i am using is as followed. Please

       setWatch(function(){
    },BTN,{edge:"rising",repeat:true});
    

    Should i use debounce, Can you give me some idea about debounce what is use of this.

  • Hi, there's quite a bit of documentation on setWatch in the Espruino reference: http://www.espruino.com/Reference#l__global_setWatch

    Yes you should use debounce, as it stops those multiple events caused by the physical contacts in the button bouncing together and apart. I tend to use 50 (milliseconds) as a reasonable start value.

    setWatch(function(){
    },BTN,{edge:"rising",repeat:true,debounce:50});
    
  • @Gordon Thanks for the feedback.

    I have check but a strange behavior in puck. I am getting events for some other pins. I have setWatch for button but got event for Pin D0

    { "lastTime": 859.655, "time": 859.96, "pin": D0, "state": false }
    
    

    how should we handle this. Please suggest.

  • Hi - that's to be expected - the button is actually connected to pin D0 - so BTN == D0. It's just that when you print it, Espruino chooses to print D0 and not BTN to the screen

  • @Gordon i am getting some issue which i am trying to handle. On my clients PuckJS it is so sensitive that even when puck is moved its event it getting triggered. But on my end its not that sensitive.

  • Has your client updated to the 1v92 firmware? That could be an issue

  • Can you share us the link how to do this.

  • http://www.espruino.com/Puck.js#firmware-updates

    Type process.version on the LHS of the Web IDE to check

  • Thanks @Gordon

  • Mr. Harry, i would like to make a counter and keep track of time interval between every click, if possibile in serverless way just using a webpage ... as You expert in button of puckjs can send me some suggestion or code examples, i'm truly newbie in js etc. BR
    Sincerely
    Carlo

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

PuckJS button event issues.

Posted by Avatar for Harry @Harry

Actions