mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Send out (msg.payload converted to 1/0) instead of msg.payload (#562)
Re https://discourse.nodered.org/t/node-red-node-pi-gpiod-true-false-vs-0-1/13941/10?u=cymplecy
This commit is contained in:
parent
5bd616eae6
commit
6efe530888
@ -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); }
|
||||||
|
Loading…
Reference in New Issue
Block a user