Avatar for user155285

user155285

Member since Apr 2023 • Last active Mar 2024
  • 9 conversations
  • 27 comments

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    Thanks!
    got it working, as blemidi on osx is broken in term of auto reconnection I am basically making a workaround with advertisements. I am using the motion example, is there a way to advertise at interval 20 but only when the device is moving?

    here is the code:

    NRF.setTxPower(4);
    //NRF.setConnectionInterval(20);
    
    function rescaleToMidiCC(value, oldMin, oldMax) {
      var newMin = 0;
      var newMax = 127;
      var rescaled = Math.round((value - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin);
      rescaled = Math.min(127, Math.max(0, rescaled));
      return rescaled;
    }
    
    
    require("puckjsv2-accel-movement").on();­
    var idleTimeout;
    
    Puck.on('accel',function(a) {
      LED.set();
    
      if (idleTimeout) clearTimeout(idleTimeout);
      idleTimeout = setTimeout(function() {
        idleTimeout = undefined;
        LED.reset();
        //active = false ;
      },500);
      const accel = Puck.accel();
      var x = ((accel.acc.x/128000)*10) *127;
      var y = ((accel.acc.y/128000)*10) *127;
      x = rescaleToMidiCC(x, -120, 120);
      y = rescaleToMidiCC(y, -120, 120);
      print(x + " " + y);
      NRF.setAdvertising({}, { manufacturer: 0x0590, manufacturerData:           [x,y], interval:20});
    
    });
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    I did:
    NRF.setTxPower(4);
    NRF.setConnectionInterval(20);
    NRF.setAdvertising({}, { manufacturer: 0x0590, manufacturerData: [pushbuttonCounter] },{interval:20});

    but still get the same result (or actually a tiny slower). I get a burst of 5 lines printed every second or so. Would I need to change something on the bleak side?

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    Thanks @Gordon, works great!
    what would be the best way to advertise more frequently ? ( the fastest we can)

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    Hi Gordon,
    I closed it because I realized it was a stupid mistake on my end ::)

    if you look closely , the midi send part isn't inside Puck.on('accel',function(a) {}
    The code was working but I was just never calling that part¯_(ツ)_/¯
    The if (active) statement is also completely useless ...

    This being said, using ble midi, needs the device to restart after uploading the code, meaning I need to flash vs ram. I noticed that after a few different uploads the device will start to act oddly ( aka bits of older code will still be there but merged with the new ones?)
    In this case what is the best approach to avoid this or start fresh? hard reset? reset() + save() ?
    thank you!

  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    hi,
    I am trying to send midi cc only on motion detection, but I get nothing coming and the terminl issue me an error: WARNING: SD ERR 0x11 (BUSY) (:835)

    I am using require("puckjsv2-accel-movement").on();­ and suspect I am using setservices twice then which could be the problem? but not really sure where to look at.

    here is the code:

    require("puckjsv2-accel-movement").on();­
    
    /// Sends a raw MIDI command
    function cmd(cmd, d1, d2) {
      NRF.updateServices({
        "03B80E5A-EDE8-4B33-A751-6CE34EC4C700": {
          "7772E5DB-3868-4112-A1A9-F2669D106BF3": {
            value: [0x80, 0x80, cmd, d1, d2],
            notify: true
          }
        }
      });
    }
    
    /// Send a 'control change' (0xB0) MIDI command
    function midisend(channel, controller, value) { cmd(0xB0+channel,controller,value); }
    
    
    
    function rescaleToMidiCC(value, oldMin, oldMax) {
      var newMin = 0;
      var newMax = 127;
      var rescaled = Math.round((value - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin);
      rescaled = Math.min(127, Math.max(0, rescaled));
      return rescaled;
    }
    
    
    
    /// Turns the device into a MIDI controller
    function init(name) {
      //NRF.setSecurity({passkey:"123456", lesc:1, bond :1});
      NRF.setServices({
        "03B80E5A-EDE8-4B33-A751-6CE34EC4C700": { // MIDI
          "7772E5DB-3868-4112-A1A9-F2669D106BF3": {
            readable: true,
            writable: true,
            notify: true,
            value: [0x80, 0x80, 0x00, 0x00, 0x00]
              }
        }
      });
      NRF.setAdvertising([
        // Flags: LE Limited Discoverable Mode, BR/EDR Not Supported
        0x02, 0x01, 0x05,
        // Complete Local Name: PuckCC
        0x07, 0x09,
        name.charCodeAt(0),
        name.charCodeAt(1),
        name.charCodeAt(2),
        name.charCodeAt(3),
        name.charCodeAt(4),
        name.charCodeAt(5),
        // MIDI
        0x11, 0x06, 0x00, 0xC7, 0xC4, 0x4E, 0xE3, 0x6C, 0x51,
        0xA7, 0x33, 0x4B, 0xE8, 0xED, 0x5A, 0x0E, 0xB8, 0x03
      ]);
      //NRF.startBonding(true);
      //NRF.setConnectionInterval(20);
      NRF.setTxPower(4);
    
    }
    
    init("PuckOI");
    
    
    var idleTimeout;
    var active;
    Puck.on('accel',function(a) {
      LED.set();
      active = true ;
      if (idleTimeout) clearTimeout(idleTimeout);
      idleTimeout = setTimeout(function() {
        idleTimeout = undefined;
        LED.reset();
        active = false ;
      },1000);
    });
    
    if (active) {
    print("yes");
    //Puck.accelOn(); // default is 12.5Hz, with gyro
    //Puck.accelOn(1.6);// for 1.6Hz low power, without gyro
    // Turn events off with Puck.accelOff();
    
      const accel = Puck.accel();
      var x = ((accel.acc.x/128000)*10) *127;
      var y = ((accel.acc.y/128000)*10) *127;
      x = rescaleToMidiCC(x, -80, 80);
      y = rescaleToMidiCC(y, -80, 80);
      midisend(0,1,x);
      midisend(0,2,y);
    }
    
  • in Puck.js, Pixl.js and MDBT42
    Avatar for user155285

    Hello,
    is annoying out there managed to read accelerometer datas of the puckjs thru advertisement (manufacturer data) using the bleak python library?
    I tried all the different tutorial on the subject but not luck :/

    • 5 comments
    • 412 views
  • in General
    Avatar for user155285

    yea I sadly tried this one too ..
    noble-mac isn't available on npm so I tried :
    npm install git+https://github.com/Timeular/noble-mac.gi­t instead.

    but I still have the same errors as trying to install any version of noble I found. (screenshot attached)

Actions