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.
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','function b(a,b){NRF.sendHIDReport(a,function(){NRF.sendHIDReport(0,b)})}exports.report=new 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,129,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.playpause=function(a){b(8,a)};exports.mute=function(a){b(16,a)};exports.volumeUp=function(a){b(32,a)};exports.volumeDown=function(a){b(64,a)}');var controls=require('ble_hid_controls');clearWatch(),pinMode(D25,'input_pulldown'),NRF.setServices(undefined,{hid:controls.report}),setWatch(function(a){a.state?(LED.set(),NRF.sendHIDReport(32,()=>;)):(LED.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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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.
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 ()
: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