diff --git a/config/nuimo-config.js b/config/nuimo-config.js index 35941e7..cb54f66 100644 --- a/config/nuimo-config.js +++ b/config/nuimo-config.js @@ -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"); @@ -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); } diff --git a/listener/nuimo-listener.js b/listener/nuimo-listener.js index 210e9a6..7ff55fd 100644 --- a/listener/nuimo-listener.js +++ b/listener/nuimo-listener.js @@ -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); }