mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
parent
9f81067d7d
commit
8d0fdd9fbf
@ -1,13 +1,12 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
language: node_js
|
language: node_js
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
# allow_failures:
|
||||||
- node_js: 16
|
# - node_js: 16
|
||||||
include:
|
include:
|
||||||
- node_js: 16
|
- node_js: 16
|
||||||
- node_js: 14
|
- node_js: 14
|
||||||
- node_js: 12
|
- node_js: 12
|
||||||
- node_js: 10
|
|
||||||
# - python: 2.7
|
# - python: 2.7
|
||||||
# language: python
|
# language: python
|
||||||
# before_script: pip install flake8
|
# before_script: pip install flake8
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-pi-mcp3008",
|
"name" : "node-red-node-pi-mcp3008",
|
||||||
"version" : "0.5.0",
|
"version" : "0.5.1",
|
||||||
"description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter",
|
"description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"mcp-spi-adc": "^3.2.0"
|
"mcp-spi-adc": "^3.2.0"
|
||||||
|
@ -29,7 +29,6 @@ module.exports = function(RED) {
|
|||||||
this.bus = parseInt(n.bus || 0);
|
this.bus = parseInt(n.bus || 0);
|
||||||
this.dev = n.dev || "3008";
|
this.dev = n.dev || "3008";
|
||||||
this.mcp3xxx = [];
|
this.mcp3xxx = [];
|
||||||
var node = this;
|
|
||||||
this.cb = function (err) { if (err) { node.error("Error: "+err); } };
|
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:node.dnum, busNumber:node.bus };
|
||||||
var chans = parseInt(this.dev.substr(3));
|
var chans = parseInt(this.dev.substr(3));
|
||||||
@ -40,14 +39,14 @@ module.exports = function(RED) {
|
|||||||
fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
|
fs.statSync("/dev/spidev"+node.bus+"."+node.dnum);
|
||||||
if (node.mcp3xxx.length === 0) {
|
if (node.mcp3xxx.length === 0) {
|
||||||
for (var i=0; i<chans; i++) {
|
for (var i=0; i<chans; i++) {
|
||||||
if (node.dev === "3002") { mcp3xxx.push(mcpadc.openMcp3002(i, opt, cb)); }
|
if (node.dev === "3002") { node.mcp3xxx.push(mcpadc.openMcp3002(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3004") { mcp3xxx.push(mcpadc.openMcp3004(i, opt, cb)); }
|
if (node.dev === "3004") { node.mcp3xxx.push(mcpadc.openMcp3004(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3008") { mcp3xxx.push(mcpadc.openMcp3008(i, opt, cb)); }
|
if (node.dev === "3008") { node.mcp3xxx.push(mcpadc.openMcp3008(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3201") { mcp3xxx.push(mcpadc.openMcp3201(i, opt, cb)); }
|
if (node.dev === "3201") { node.mcp3xxx.push(mcpadc.openMcp3201(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3202") { mcp3xxx.push(mcpadc.openMcp3202(i, opt, cb)); }
|
if (node.dev === "3202") { node.mcp3xxx.push(mcpadc.openMcp3202(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3204") { mcp3xxx.push(mcpadc.openMcp3204(i, opt, cb)); }
|
if (node.dev === "3204") { node.mcp3xxx.push(mcpadc.openMcp3204(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3208") { mcp3xxx.push(mcpadc.openMcp3208(i, opt, cb)); }
|
if (node.dev === "3208") { node.mcp3xxx.push(mcpadc.openMcp3208(i, node.opt, node.cb)); }
|
||||||
if (node.dev === "3304") { mcp3xxx.push(mcpadc.openMcp3304(i, opt, cb)); }
|
if (node.dev === "3304") { node.mcp3xxx.push(mcpadc.openMcp3304(i, node.opt, node.cb)); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
@ -76,7 +75,7 @@ module.exports = function(RED) {
|
|||||||
for (var i=0; i<chans; i++) {
|
for (var i=0; i<chans; i++) {
|
||||||
node.mcp3xxx[i].close(function() { j += 1; if (j === chans) {done()} });
|
node.mcp3xxx[i].close(function() { j += 1; if (j === chans) {done()} });
|
||||||
}
|
}
|
||||||
mcp3xxx = [];
|
node.mcp3xxx = [];
|
||||||
}
|
}
|
||||||
else { done(); }
|
else { done(); }
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user