Ahh, ok - the code you posted (with onInit()) needs a save() to take effect, but the example code from the keyboard doesn't - and in fact the save() might mess it up (I'll look into that for 1v93).
Also, as before - you need to reboot after running the flash code. But hopefully now it's done you'll have no need for it.
Try:
Device is connected with 1v92 to the web ide.
upload this code from right hand side:
var kb = require("ble_hid_keyboard");
function onInit() {
NRF.setServices(undefined, { hid : kb.report });
// trigger btnPressed whenever the button is pressed
setWatch(btnPressed, BTN, {edge:"rising",repeat:true,debounce:50});
}
function btnPressed() {
// Send 'a'
kb.tap(kb.KEY.A, 0, function() {
// Followed by capital 'A'
kb.tap(kb.KEY.A, kb.MODIFY.SHIFT);
});
}
it's different from the example (as it initialises stuff in onInit)
type save() on left hand side
disconnect from Web IDE.
un-pair
re-pair
press puck button with pc cursor in a text box... should print aA
I've literally just tried it here and it works for me.
If you wanted to use the BLE example code you should be able to do the same steps without typing save() (I just tried here and it works), but then if you ever remove the battery it'll default to whatever was saved on it.
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.
Ahh, ok - the code you posted (with
onInit()
) needs asave()
to take effect, but the example code from the keyboard doesn't - and in fact thesave()
might mess it up (I'll look into that for 1v93).Also, as before - you need to reboot after running the flash code. But hopefully now it's done you'll have no need for it.
Try:
upload this code from right hand side:
it's different from the example (as it initialises stuff in
onInit
)save()
on left hand sideaA
I've literally just tried it here and it works for me.
If you wanted to use the BLE example code you should be able to do the same steps without typing
save()
(I just tried here and it works), but then if you ever remove the battery it'll default to whatever was saved on it.