• Hi at all!

    The following program has a button connected to pin D25 (MDBT42Q firmware 2v03). When the button is pressed, the "volumeUp" command is sent to the device connected by BLE. Only when button is pressed.

    I have tried the program in both Puck.js and MDBT42Q.

    var controls = require("ble_hid_controls");
    
    // Clean all previous watches
    clearWatch();
    
    // Configure PIN D25 with internal pulldown resistence
    // Wiring to VCC.
    pinMode(D25, "input_pulldown");
    
    NRF.setServices(undefined, {hid: controls.report});
    
    setWatch(function (ptt) {
      if (ptt.state) {
        LED.set();
        NRF.sendHIDReport(32, () => {});
      } else {
        LED.reset();
        NRF.sendHIDReport(0, () => {});
      }
    }, D25, {edge: "both", debounce: 50, repeat: true});
    

    However, when loading the code with WebIDE with the option of "Minification" Esprima (offline) an error occurs when the button is pressed for the first time. The program keeps sending the "volumeUp" command continuously.

    This is the minimized code that returns dump ():

    // Code saved with E.setBootCode
    Modules.addCached('ble_hid_controls','fu­nction b(a,b){NRF.sendHIDReport(a,function(){NR­F.sendHIDReport(0,b)})}exports.report=ne­w Uint8Array([5,12,9,1,161,1,21,0,37,1,117­,1,149,5,9,181,9,182,9,183,9,205,9,226,1­29,6,149,2,9,233,9,234,129,2,149,1,129,1­,192]);exports.next=function(a){b(1,a)};­exports.prev=function(a){b(2,a)};exports­.stop=function(a){b(4,a)};exports.playpa­use=function(a){b(8,a)};exports.mute=fun­ction(a){b(16,a)};exports.volumeUp=funct­ion(a){b(32,a)};exports.volumeDown=funct­ion(a){b(64,a)}');var controls=require('ble_hid_controls');cle­arWatch(),pinMode(D25,'input_pulldown'),­NRF.setServices(undefined,{hid:controls.­report}),setWatch(function(a){a.state?(L­ED.set(),NRF.sendHIDReport(32,()=>;)):(L­ED.reset(),NRF.sendHIDReport(0,()=>;));}­,D25,{edge:'both',debounce:50,repeat:!0}­);
    

    For now, the size of the code is not a problem but I would like to apply the best possible optimization.

    Any ideas?

    Thanks in advance

About

Avatar for migsanvi @migsanvi started