tidy up mcp3008 init

This commit is contained in:
Dave Conway-Jones 2021-11-29 08:49:45 +00:00
parent 4868364860
commit d4faa55ab8
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-pi-mcp3008",
"version" : "0.5.1",
"version" : "0.5.2",
"description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter",
"dependencies" : {
"mcp-spi-adc": "^3.2.0"

View File

@ -25,12 +25,12 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.pin = n.pin || 0;
this.interval = n.interval || 1000;
this.dnum = parseInt(n.dnum || 0);
this.bus = parseInt(n.bus || 0);
this.dnum = parseInt(n.dnum) || 0;
this.bus = parseInt(n.bus) || 0;
this.dev = n.dev || "3008";
this.mcp3xxx = [];
this.cb = function (err) { if (err) { node.error("Error: "+err); } };
this.opt = { speedHz:20000, deviceNumber:node.dnum, busNumber:node.bus };
this.opt = { speedHz:20000, deviceNumber:this.dnum, busNumber:this.bus };
var chans = parseInt(this.dev.substr(3));
var node = this;