-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlirc.js
More file actions
38 lines (30 loc) · 1.14 KB
/
lirc.js
File metadata and controls
38 lines (30 loc) · 1.14 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
35
36
37
38
// Sending commands
lirc_node = require('lirc_node');
lirc_node.init();
// To see all of the remotes and commands that LIRC knows about:
console.log(lirc_node.remotes);
/*
Let's pretend that the output of lirc_node.remotes looks like this:
{
"tv": ["Power", "VolumeUp", "VolumeDown"],
"xbox360": ["Power", "A", "B"]
}
*/
// Tell the TV to turn on
lirc_node.irsend.send_once("fanremote", "KEY_POWER", function() {
console.log("Sent Fan power command!");
});
// // Tell the Xbox360 to turn on
// lirc_node.irsend.send_once("xbox360", "power", function() {
// console.log("Sent Xbox360 power command!");
// });
// Listening for commands
var listenerId = lirc_node.addListener(function(data) {
console.log("Received IR keypress '" + data.key + "'' from remote '" + data.remote +"'");
});
lirc_node.addListener('KEY_1', 'remote1', function(data) {
console.log("Received IR keypress 'KEY_1' from remote 'remote1'");
// data also has `code` and `repeat` properties from the output of `irw`
// The final argument after this callback is a throttle allowing you to
// specify to only execute this callback once every x milliseconds.
}, 400);