-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
34 lines (28 loc) · 1.06 KB
/
Copy pathcode.js
File metadata and controls
34 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const kb = require("ble_hid_keyboard");
NRF.setServices(undefined, { hid: kb.report });
// Configurable settings:
const LED_TIMEOUT = 600000; // 10 minutes.
let isMuted = true; // Assume we start muted.
// Toggle the status indication LEDs. Green = unmuted, red = muted.
function setMute(muted) {
isMuted = muted;
if (isMuted) { LED1.set(); } else { LED2.set(); }
setTimeout(isMuted ? "LED1.reset()" : "LED2.reset()", LED_TIMEOUT);
}
// Mute te all devices once connected.
kb.tap(kb.KEY.X, kb.MODIFY.LEFT_CTRL | kb.MODIFY.LEFT_ALT, function () {
setMute(true);
});
// Pressing the button sends CTRL + ALT + M, mapped to a script that toggles mute for all devices.
setWatch(function () {
kb.tap(kb.KEY.M, kb.MODIFY.LEFT_CTRL | kb.MODIFY.LEFT_ALT, function () {
LED1.reset();
LED2.reset();
setMute(!isMuted);
});
}, BTN, { edge: "rising", debounce: 10, repeat: true });
NRF.on('disconnect', function () {
LED1.reset();
LED2.reset();
});
NRF.setAdvertising({}, { name: "Mute Button", interval: 600 });