You are reading a single comment by @Gordon and its replies.
Click here to read the full conversation.
-
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}); });
You need:
It's meant to go in the second argument, not the third - then hopefully things will work better