fix mcp3008 to close only the channels it has

This commit is contained in:
Dave Conway-Jones 2019-08-12 15:40:30 +01:00
parent e20cf97fce
commit 75df218a23
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 4 additions and 4 deletions

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-pi-mcp3008",
"version" : "0.2.0",
"version" : "0.2.1",
"description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter",
"dependencies" : {
"mcp-spi-adc": "^2.0.3"
"mcp-spi-adc": "^2.0.6"
},
"repository" : {
"type":"git",

View File

@ -62,8 +62,8 @@ module.exports = function(RED) {
node.on("close", function(done) {
if (mcp3xxx.length !== 0) {
var j=0;
for (var i=0; i<8; i++) {
mcp3xxx[i].close(function() { j += 1; if (j === 8) {done()} });
for (var i=0; i<chans; i++) {
mcp3xxx[i].close(function() { j += 1; if (j === chans) {done()} });
}
mcp3xxx = [];
}