mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Better error handling for Pibrella buzzer. (and more useful).
This commit is contained in:
parent
842d3e3c7e
commit
36bbddffe5
@ -85,7 +85,7 @@
|
|||||||
<script type="text/x-red" data-help-name="rpi-pibrella out">
|
<script type="text/x-red" data-help-name="rpi-pibrella out">
|
||||||
<p>Raspberry Pi Pibrella output node. The Pibrella board must be fitted.</p>
|
<p>Raspberry Pi Pibrella output node. The Pibrella board must be fitted.</p>
|
||||||
<p>Will set the selected output high (on) or low (off) depending on the value passed in. Expects a <b>msg.payload</b> with either a 0 or 1 (or true or false).</p>
|
<p>Will set the selected output high (on) or low (off) depending on the value passed in. Expects a <b>msg.payload</b> with either a 0 or 1 (or true or false).</p>
|
||||||
<p>The Buzzer is a divider so low numbers are high notes. 0 is off, and the sensible lowest note is around 250-300.</p>
|
<p>The Buzzer is a divider so low numbers are high notes. 0 is off, and the sensible lowest note is around 250-300. 2 is the highest note. 1 is just a buzz (so you can use 0/1 type inputs).</p>
|
||||||
<p>Requires the WiringPi gpio command in order to work.</p>
|
<p>Requires the WiringPi gpio command in order to work.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -107,12 +107,15 @@ function PibrellaOut(n) {
|
|||||||
exec("gpio pwm-ms");
|
exec("gpio pwm-ms");
|
||||||
node.on("input", function(msg) {
|
node.on("input", function(msg) {
|
||||||
var out = Number(msg.payload);
|
var out = Number(msg.payload);
|
||||||
if (out == 1) { out = 2; } // doesn't work with 1...
|
if (out == 1) { // fixed buzz
|
||||||
if (out == 0) { exec("gpio pwm 1 0"); }
|
exec("gpio pwm 1 511");
|
||||||
else {
|
exec("gpio pwmc 100");
|
||||||
|
}
|
||||||
|
else if ((out >= 2) && (out <= 9999)) { // set buzz to a value
|
||||||
exec("gpio pwm 1 511");
|
exec("gpio pwm 1 511");
|
||||||
exec("gpio pwmc "+out);
|
exec("gpio pwmc "+out);
|
||||||
}
|
}
|
||||||
|
else { exec("gpio pwm 1 0"); } // turn it off
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user