You are reading a single comment by @tako and its replies. Click here to read the full conversation.
  • Honestly, I've been having a lot of battery issues too recently. I've been having to change them out every few days. Just connected via BLE - getting worse battery life than with v199. Let me know if you'd like me to start my own topic for this.

    E.on('init', function() {
      var debug_log = function debug_log(t) {
        console.log(t);
      };
    
      debug_log(NRF.getAddress());
      debug_log("Battery: " + E.getBattery() + " " + Puck.getBatteryPercentage());
    
      var kb = require("ble_hid_keyboard");
      NRF.setServices(undefined, { hid : kb.report });
    
      var sending = 0;
    
      var catchButton = function catchButton(e) {
        if(!sending) {
          var keyDown = e.state === true;
          var keyUp = e.state === false;
          var click = false;
    
          if(keyDown) {
            //digitalWrite(LED3,1);
          }
    
          if(keyUp) {
            triggerCommand();
          }
        }
      };
    
      var triggerCommand = function triggerCommand() {
        try {
          if(!sending) {
            sending = 1;
            //107 is f16
            NRF.sendHIDReport([0,0,107,0,0,0,0,0], function() {
              setTimeout(function() {
                NRF.sendHIDReport([0,0,0,0,0,0,0,0], function() {
                  setTimeout(function() {
                    debug_log("works");
                    sending = 0;
                  }, 250);
                });
              }, 100);
              //digitalWrite(LED3,0);
            });
          }
        } catch (e) {
          console.log("caught:" + JSON.stringify(e));
          //digitalWrite(LED3,0);
          digitalWrite(LED1,1);
          setTimeout(function() {
            digitalWrite(LED1,0);
            sending = 0;
          }, 100);
        }
      };
    
    
      setWatch(catchButton, BTN, {repeat:true, debounce:50, edge:'both' });
    });
    save();
    
About

Avatar for tako @tako started