mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
pigpiod - only allow send if actually connected.
This commit is contained in:
parent
a881a5c4af
commit
d48644e16a
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-red-node-pi-gpiod",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"description": "A node-red node for PiGPIOd",
|
||||
"dependencies" : {
|
||||
"js-pigpio": "*"
|
||||
|
@ -99,6 +99,7 @@ module.exports = function(RED) {
|
||||
var PiGPIO;
|
||||
|
||||
function inputlistener(msg) {
|
||||
if (!inerror) {
|
||||
if (msg.payload === "true") { msg.payload = true; }
|
||||
if (msg.payload === "false") { msg.payload = false; }
|
||||
var out = Number(msg.payload);
|
||||
@ -120,6 +121,7 @@ module.exports = function(RED) {
|
||||
}
|
||||
else { node.warn(RED._("pi-gpiod:errors.invalidinput")+": "+out); }
|
||||
}
|
||||
}
|
||||
|
||||
if (node.pin !== undefined) {
|
||||
PiGPIO = new Pigpio();
|
||||
@ -132,6 +134,7 @@ module.exports = function(RED) {
|
||||
node.retry = setTimeout(function() { doit(); }, 5000);
|
||||
}
|
||||
else {
|
||||
inerror = false;
|
||||
PiGPIO.set_mode(node.pin,PiGPIO.OUTPUT);
|
||||
if (node.set) {
|
||||
setTimeout(function() { PiGPIO.write(node.pin,node.level); }, 25 );
|
||||
|
Loading…
Reference in New Issue
Block a user