-
Notifications
You must be signed in to change notification settings - Fork 1
/
irraw.js
40 lines (33 loc) · 889 Bytes
/
irraw.js
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
39
40
var webduino = require('webduino-js'),
utils = require('./utils'),
IR = require('./lib/IR');
module.exports = function (RED) {
'use strict';
function IRRaw(n) {
var node = this,
boardNode, irraw;
RED.nodes.createNode(this, n);
node.autostartRecv = n.autostartRecv;
node.sendPin = parseInt(n.sendPin);
node.recvPin = parseInt(n.recvPin);
boardNode = RED.nodes.getNode(n.board);
boardNode.mount(node, function (board) {
irraw = new IR(board, node.sendPin, node.recvPin);
if (node.autostartRecv) {
irraw.recv(function (evt) {
node.send({
payload: evt
});
});
}
});
node.on('input', function (msg) {
utils.invoke(irraw, msg, function (evt) {
node.send({
payload: evt
});
});
});
}
RED.nodes.registerType("irraw", IRRaw);
};