-
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?
-
Thanks @Gordon, works great!
what would be the best way to advertise more frequently ? ( the fastest we can) -
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! -
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); }
-
-
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.git instead.but I still have the same errors as trying to install any version of noble I found. (screenshot attached)
-
Hello,
using this code from https://www.espruino.com/BLE+Advertising
var presses = 0;
NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[presses]});setWatch(function() {
presses++;
NRF.setAdvertising({},{manufacturer: 0x0590, manufacturerData:[presses]});
}, BTN, {edge:"rising", repeat:1, debounce:20})I am trying to see the presses on https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements.html
but I can't see the manufacturer data coming in ? Any idea what could be changed to make it work ?
thank you!
-
Hello,
Did anyone managed to tweak the puck.js script https://www.puck-js.com/puck.js
with this : https://googlechrome.github.io/samples/web-bluetooth/automatic-reconnect.htmlto allow auto reconnection ?
-
-
Hi,
I started to have the open brackets / close brackets error on a script I have been using for a while and was compiling fine till today. No changes have been made to it . There is no error visible in the IDEI found out this function is where is the problem but I really don't see any brackets error on it ??? :
function rescaleToMidiCC (value, oldMin, oldMax){
newMin = 0;
newMax = 127;
rescaled = Math.round((value - oldMin) * (newMax - newMin) / (oldMax - oldMin) + newMin);
rescaled = Math.min(127, Math.max(0, rescaled));
return rescaled;
}deleting this part of the code and the script compiles
-
I tried all the above, it worked as advertised but didn't resolved or permit the auto-connection ( the device now show in the main bluetooth menu but still need to get connected every time in the bluetooth audio midi setup windows). I assume its coming from the OS side more than the espruino itself.
note: I had a weird behavior with NRF.setServices ( NRF.setSecurity({passkey:"123456", lesc:1, bond :1});)
Where It asked for the passkey only a few restart after and then the Espruino Web IDE will throw random errors when trying to upload new code . had to perform a reset(); save(); to go back to normal. -
Thanks @Gordon !
will look at it and report back.
In the meantime I worked on a hot fix using applescript to automatically click the button "connect" if it appears in the bluetooth midi window ::) -
-
😂
ahaha no!
resolved with the help of Joe Bowbeer <3full discussion and solution:
https://github.com/joebowbeer/PuckCC/issues/1#issuecomment-1524715536 -
Hi all,
I am trying to implement 2 functions to this module. One to receive CC messages and one to rename the device. I am pretty limited in my knowledge when it comes to this subject.
If anyone can help it will be greatly appreciated!thank you!
this is where I am at, and both function doesn't work for now 😎:
/* Copyright (c) 2017 Gordon Williams, George Mandis, Joe Bowbeer, Pur3 Ltd. See the file LICENSE for copying permission. */ /* usage: var midi = require("ble_midi"); midi.init(); midi.send(channel, controller, value); */ /// Turns the device into a MIDI controller exports.init = function () { 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], onWrite: function (evt) { if ( evt.data.length == 6 && evt.data[0] == 0x80 && evt.data[1] == 0x80 && (evt.data[2] & 0xf0) == 0xb0 ) { var timestamp = ((evt.data[0] & 0x3f) << 7) | (evt.data[1] & 0x7f); var channel = evt.data[2] & 0x0f; var controller = evt.data[3]; var value = evt.data[4]; exports.onCC(timestamp, channel, controller, value); } } } } }); NRF.setAdvertising([ // Flags: LE Limited Discoverable Mode, BR/EDR Not Supported 0x02, 0x01, 0x05, // Complete Local Name: PuckCC 0x07, 0x09, 0x50, 0x75, 0x63, 0x6b, 0x43, 0x43, // MIDI 0x11, 0x06, 0x00, 0xc7, 0xc4, 0x4e, 0xe3, 0x6c, 0x51, 0xa7, 0x33, 0x4b, 0xe8, 0xed, 0x5a, 0x0e, 0xb8, 0x03, ]); }; /// Sends a raw MIDI command exports.cmd = function (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 exports.send = function (channel, controller, value) { this.cmd(0xb0 + channel, controller, value); }; /// Send a 'note on' (0x90) MIDI command exports.noteOn = function (channel, note, velocity) { this.cmd(0x90 + channel, note, velocity); }; /// Send a 'note off' (0x80) MIDI command exports.noteOff = function (channel, note, velocity) { this.cmd(0x80 + channel, note, velocity); }; /// Sets the name of the MIDI device exports.setName = function (name) { var nameBytes = []; for (var i = 0; i < name.length; ++i) nameBytes.push(name.charCodeAt(i)); NRF.setAdvertising([ // Flags: LE Limited Discoverable Mode, BR/EDR Not Supported 0x02, 0x01, 0x05, // Complete Local Name 0x07, 0x09, nameBytes, // MIDI 0x11, 0x06, 0x00, 0xc7, 0xc4, 0x4e, 0xe3, 0x6c, 0x51, 0xa7, 0x33, 0x4b, 0xe8, 0xed, 0x5a, 0x0e, 0xb8, 0x03, ]); };
-
Hi,
I am trying to use the puck.js as a BLE midi device ( send and receive)
I am connecting the device with a mac or iphone. The mac systems are not very friendly when it comes to connect a bluetooth midi device, aka you need to go in a menu to connect the device and if the connection get lost you have to redo the all the menu thingy.Apple documentation states that the device will reconnect itself automatically if the device accept pairing:
https://developer.apple.com/documentation/coremidi/midi_bluetooth/Is there anyway to use the BLEmidi module but to get the device get pairing also ( like when being HID for example)?
thank you!
-
Hi @Gordon
thanks for your reply!
I am not that familiar with the espruino env (coming from arduino IDE)
tbh this was me trying to take a shortcut and being lazy using chat-gpt to find answers ::)
I did read examples instead and ended up figuring out ::) -
-
Hello, I am trying to send the accelerometer angles as midi cc when a button is being pushed.
But I am struggling getting the accelerometer data separately. Any help is welcome!
thank you!// Include the MIDI library NRF.setServices({ 0x180D: { 0x2A37: { value : [0], writable : true } } }, { advertise: ['180D'] }); // Set up the button pin var BUTTON_PIN = BTN; pinMode(BUTTON_PIN, "input_pullup"); // Set up the accelerometer var accel = require("puckjsv2-accel").use({ frequency: 10, samples: 10 }); // Function to send accelerometer data as MIDI CC values function sendAccelerometerData() { // Get the accelerometer data var data = accel.get(); // Send MIDI CC messages for each axis MIDI.send([0xB0, 1, data.x >> 3]); MIDI.send([0xB0, 2, data.y >> 3]); MIDI.send([0xB0, 3, data.z >> 3]); } // Set up a timer to continuously send accelerometer data var sendTimer = null; function startSending() { sendTimer = setInterval(function() { sendAccelerometerData(); }, 50); } function stopSending() { clearInterval(sendTimer); } // Set up button events to start and stop sending setWatch(function(e) { if (e.state == false) { // Button was released, stop sending stopSending(); } else { // Button was pressed, start sending startSending(); } }, BUTTON_PIN, { edge: "both", debounce: 50, repeat: true });
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: