Reduce GPIO setup on Pi node to try to make it play nice with other peripherals

This commit is contained in:
Dave C-J 2014-05-06 20:58:36 +01:00
parent d1318d215c
commit fb0cae0935
1 changed files with 31 additions and 31 deletions

View File

@ -76,7 +76,7 @@ module.exports = function(RED) {
this.intype = n.intype;
var node = this;
if (this.pin) {
if (node.pin) {
exec("gpio mode "+node.pin+" "+node.intype, function(err,stdout,stderr) {
if (err) node.error(err);
else {
@ -99,11 +99,11 @@ module.exports = function(RED) {
});
}
else {
this.error("Invalid GPIO pin: "+this.pin);
node.error("Invalid GPIO pin: "+node.pin);
}
this.on("close", function() {
clearInterval(this._interval);
node.on("close", function() {
clearInterval(node._interval);
});
}
@ -112,7 +112,7 @@ module.exports = function(RED) {
this.pin = pintable[n.pin];
var node = this;
if (this.pin) {
if (node.pin) {
process.nextTick(function() {
exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) {
if (err) node.error(err);
@ -133,26 +133,26 @@ module.exports = function(RED) {
});
}
else {
this.error("Invalid GPIO pin: "+this.pin);
node.error("Invalid GPIO pin: "+node.pin);
}
this.on("close", function() {
exec("gpio mode "+this.pin+" in");
node.on("close", function() {
exec("gpio mode "+node.pin+" in");
});
}
exec("gpio mode 0 in",function(err,stdout,stderr) {
if (err) {
util.log('[36-rpi-gpio.js] Error: "gpio" command failed for some reason.');
}
exec("gpio mode 1 in");
exec("gpio mode 2 in");
exec("gpio mode 3 in");
exec("gpio mode 4 in");
exec("gpio mode 5 in");
exec("gpio mode 6 in");
exec("gpio mode 7 in");
});
//exec("gpio mode 0 in",function(err,stdout,stderr) {
// if (err) {
// util.log('[36-rpi-gpio.js] Error: "gpio" command failed for some reason.');
// }
// exec("gpio mode 1 in");
// exec("gpio mode 2 in");
// exec("gpio mode 3 in");
// exec("gpio mode 4 in");
// exec("gpio mode 5 in");
// exec("gpio mode 6 in");
// exec("gpio mode 7 in");
//});
RED.nodes.registerType("rpi-gpio in",GPIOInNode);
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);