Skip to content

Commit

Permalink
Send out (msg.payload converted to 1/0) instead of msg.payload (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
cymplecy authored and dceejay committed Aug 3, 2019
1 parent 5bd616e commit 6efe530
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions hardware/pigpiod/pi-gpiod.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,19 @@ module.exports = function(RED) {
if (RED.settings.verbose) { node.log("out: "+msg.payload); }
if (!inerror) {
if (node.out === "out") {
PiGPIO.write(node.pin, msg.payload);
PiGPIO.write(node.pin, out);
}
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") {
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 {
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); }
Expand Down

0 comments on commit 6efe530

Please sign in to comment.