mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
another tidy up on Pi GPIO node
This commit is contained in:
parent
c76ba1dcc7
commit
bb06585748
@ -121,7 +121,6 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
RED.nodes.registerType("rpi-gpio in",GPIOInNode);
|
RED.nodes.registerType("rpi-gpio in",GPIOInNode);
|
||||||
|
|
||||||
|
|
||||||
function GPIOOutNode(n) {
|
function GPIOOutNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.pin = n.pin;
|
this.pin = n.pin;
|
||||||
@ -211,22 +210,6 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var pitype = { type:"" };
|
|
||||||
exec(gpioCommand+" info", function(err,stdout,stderr) {
|
|
||||||
if (err) {
|
|
||||||
RED.log.info(RED._("rpi-gpio.errors.version"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
try {
|
|
||||||
var info = JSON.parse( stdout.trim().replace(/\'/g,"\"") );
|
|
||||||
pitype.type = info["TYPE"];
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
RED.log.info(RED._("rpi-gpio.errors.sawpitype"),stdout.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
|
RED.nodes.registerType("rpi-gpio out",GPIOOutNode);
|
||||||
|
|
||||||
function PiMouseNode(n) {
|
function PiMouseNode(n) {
|
||||||
@ -324,6 +307,22 @@ module.exports = function(RED) {
|
|||||||
}
|
}
|
||||||
RED.nodes.registerType("rpi-keyboard",PiKeyboardNode);
|
RED.nodes.registerType("rpi-keyboard",PiKeyboardNode);
|
||||||
|
|
||||||
|
var pitype = { type:"" };
|
||||||
|
exec(gpioCommand+" info", function(err,stdout,stderr) {
|
||||||
|
if (err) {
|
||||||
|
RED.log.info(RED._("rpi-gpio.errors.version"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
var info = JSON.parse( stdout.trim().replace(/\'/g,"\"") );
|
||||||
|
pitype.type = info["TYPE"];
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
RED.log.info(RED._("rpi-gpio.errors.sawpitype"),stdout.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
RED.httpAdmin.get('/rpi-gpio/:id', RED.auth.needsPermission('rpi-gpio.read'), function(req,res) {
|
RED.httpAdmin.get('/rpi-gpio/:id', RED.auth.needsPermission('rpi-gpio.read'), function(req,res) {
|
||||||
res.json(pitype);
|
res.json(pitype);
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
bouce = 20;
|
bounce = 25;
|
||||||
|
|
||||||
if sys.version_info >= (3,0):
|
if sys.version_info >= (3,0):
|
||||||
print("Sorry - currently only configured to work with python 2.x")
|
print("Sorry - currently only configured to work with python 2.x")
|
||||||
|
Loading…
Reference in New Issue
Block a user