It can be possible to puck do the following

Posted on
  • Hi there,

    It can be possible to puck do the following:

    Press Puck 1 time to send this kb.tap(kb.KEY["7"], kb.MODIFY.ALT|kb.MODIFY.CTRL);
    Press Puck 2 times to send this kb.tap(kb.KEY[8], 0);
    Press Puck 3 times to send this kb.tap(kb.KEY[9], 0);
    

    Many regards,

  • Yes, definitely - you just need some code a bit like the following:

    var kb = require("ble_hid_keyboard");
    NRF.setServices(undefined, { hid : kb.report });
    
    var keyTimeout, keyClicks = 0;
    
    function onClick(count) {
      if (count==1) {
        // kb.tap(kb.KEY["7"], kb.MODIFY.ALT|kb.MODIFY.CTRL);
        digitalPulse(LED1,1,100); // red
      } else if (count==2) {
        // kb.tap(kb.KEY[8], 0);
        digitalPulse(LED2,1,100); // green
      } else if (count==3) {
        // kb.tap(kb.KEY[9], 0);
        digitalPulse(LED3,1,100); // blue
      } else {
        // some other number?
      }
    }
    
    setWatch(function() {
      keyClicks++;
      if (keyTimeout) clearTimeout(keyTimeout);
      keyTimeout = setTimeout(function() {
        keyTimeout = undefined;
        onClick(keyClicks);
        keyClicks=0;
      }, 500);  
    }, BTN, {repeat:true, debounce:20, edge:"rising"});
    

    That uses a 500ms (1/2 second) delay - so your multiple clicks have to be faster than that. It's easy enough to change though.

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

It can be possible to puck do the following

Posted by Avatar for nsilva @nsilva

Actions