Skip to content

Commit

Permalink
cleaning up functions
Browse files Browse the repository at this point in the history
  • Loading branch information
readeral committed Aug 20, 2018
1 parent 0af9a42 commit 5b41d0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
25 changes: 8 additions & 17 deletions config/nuimo-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,10 @@ module.exports = function(RED) {

var node = this;



nuimo.on("discover", (device) => {
node.testFunction = () => {
console.log("testFunction");
}
nuimo.stop();
node.writeMatrix = (instructions) => {
console.log(instructions);
device.setLEDMatrix([0, 0, 0, 0, 1, 0, 0, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 0, 0, 0, 1, 0,
1, 0, 0, 0, 0, 0, 0, 0, 1,
0, 1, 0, 0, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0],
instructions.brightness, instructions.timeout, instructions.options);
device.setLEDMatrix(instructions.matrix, instructions.brightness, instructions.timeout, instructions.options);
}
device.on("connect", () => {
node.warn("Nuimo connected");
Expand Down Expand Up @@ -56,10 +42,15 @@ module.exports = function(RED) {
});

device.connect();

});

nuimo.scan();
}

node.on('close', function () {
nuimo.stop();
nuimo.removeAllListeners();
});
}
RED.nodes.registerType("nuimo-config",nuimoConfigNode);
}
2 changes: 0 additions & 2 deletions listener/nuimo-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ module.exports = function(RED) {
})
nuimo.on("press", () => {
var msg = { payload:"I got pressed!" }
nuimo.testFunction();
node.send(msg);
})

}
RED.nodes.registerType("nuimo-listener",nuimoListenerNode);
}

0 comments on commit 5b41d0f

Please sign in to comment.