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:
parent
ea13342c7b
commit
61e5b9b929
@ -23,12 +23,6 @@ function DuinoNode(n) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.pin = n.pin || "10";
|
this.pin = n.pin || "10";
|
||||||
node = this;
|
node = this;
|
||||||
try {
|
|
||||||
this.board = new duino.Board();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
util.log("[duino] - Error establishing board connection!");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.on("input", function(message) {
|
this.on("input", function(message) {
|
||||||
if (typeof(message.payload) == "string") {
|
if (typeof(message.payload) == "string") {
|
||||||
@ -36,6 +30,12 @@ function DuinoNode(n) {
|
|||||||
}
|
}
|
||||||
// Send message as RC triState
|
// Send message as RC triState
|
||||||
if (message.payload.inputType === "RC") {
|
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;
|
var rcCode = message.payload.rcCode;
|
||||||
|
|
||||||
if (rcCode.length != 8) {
|
if (rcCode.length != 8) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user