Skip to content

Instantly share code, notes, and snippets.

@NielsLeenheer
Last active April 4, 2020 12:13
Show Gist options
  • Save NielsLeenheer/d30db39e39e3f7a52d12c2eaafa67c7d to your computer and use it in GitHub Desktop.
Save NielsLeenheer/d30db39e39e3f7a52d12c2eaafa67c7d to your computer and use it in GitHub Desktop.
Toggle screen-mirroring on the new MacBook Pro using a Puck.js
var kb = require("ble_hid_keyboard");
var services = {
0x180a: {
0x2a50: {
value: [
0x01, /* Use USB Vendor IDs */
0xac, 0x05, /* Apple */
0x5a, 0x02, /* Internal Keyboard */
0x00, 0x00
],
readable: true,
}
}
};
NRF.setServices(services, {
advertise: [ 0x180a ],
hid: kb.report
});
function btnPressed() {
LED1.write(true);
setTimeout(function() {
LED1.write(false);
}, 200);
NRF.sendHIDReport([kb.MODIFY.GUI, 0, kb.KEY.F1, 0, 0, 0, 0, 0], function() {
NRF.sendHIDReport([0, 0, 0, 0, 0, 0, 0, 0]);
});
}
setWatch(btnPressed, BTN, {
edge: "rising",
repeat: true,
debounce: 50
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment