1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Only instantiate a board when we need one

This commit is contained in:
Sean Bedford 2014-03-19 16:57:30 +00:00
parent ea13342c7b
commit 61e5b9b929

View File

@ -23,12 +23,6 @@ function DuinoNode(n) {
RED.nodes.createNode(this,n);
this.pin = n.pin || "10";
node = this;
try {
this.board = new duino.Board();
}
catch (e) {
util.log("[duino] - Error establishing board connection!");
}
this.on("input", function(message) {
if (typeof(message.payload) == "string") {
@ -36,6 +30,12 @@ function DuinoNode(n) {
}
// Send message as RC triState
if (message.payload.inputType === "RC") {
try {
this.board = new duino.Board();
}
catch (e) {
util.log("[duino] - Error establishing board connection!");
}
var rcCode = message.payload.rcCode;
if (rcCode.length != 8) {