1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00
This commit is contained in:
Dave Conway-Jones 2019-08-06 19:25:24 +01:00
commit 68178cd93c
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -117,19 +117,19 @@ module.exports = function(RED) {
if (RED.settings.verbose) { node.log("out: "+msg.payload); } if (RED.settings.verbose) { node.log("out: "+msg.payload); }
if (!inerror) { if (!inerror) {
if (node.out === "out") { if (node.out === "out") {
PiGPIO.write(node.pin, msg.payload); PiGPIO.write(node.pin, out);
} }
if (node.out === "pwm") { if (node.out === "pwm") {
PiGPIO.set_PWM_dutycycle(node.pin, parseInt(msg.payload * 2.55)); PiGPIO.set_PWM_dutycycle(node.pin, parseInt(out * 2.55));
} }
if (node.out === "ser") { if (node.out === "ser") {
var r = (node.sermax - node.sermin) * 100; var r = (node.sermax - node.sermin) * 100;
PiGPIO.setServoPulsewidth(node.pin, parseInt(1500 - (r/2) + (msg.payload * r / 100))); PiGPIO.setServoPulsewidth(node.pin, parseInt(1500 - (r/2) + (out * r / 100)));
} }
node.status({fill:"green",shape:"dot",text:msg.payload.toString()}); node.status({fill:"green",shape:"dot",text:out.toString()});
} }
else { else {
node.status({fill:"grey",shape:"ring",text:"N/C: " + msg.payload.toString()}); node.status({fill:"grey",shape:"ring",text:"N/C: " + out.toString()});
} }
} }
else { node.warn(RED._("pi-gpiod:errors.invalidinput")+": "+out); } else { node.warn(RED._("pi-gpiod:errors.invalidinput")+": "+out); }