diff --git a/hardware/pigpiod/package.json b/hardware/pigpiod/package.json
index 9310b69e..ffa0a018 100644
--- a/hardware/pigpiod/package.json
+++ b/hardware/pigpiod/package.json
@@ -1,6 +1,6 @@
{
"name": "node-red-node-pi-gpiod",
- "version": "0.1.1",
+ "version": "0.2.0",
"description": "A node-red node for PiGPIOd",
"dependencies" : {
"js-pigpio": "*"
diff --git a/hardware/pigpiod/pi-gpiod.html b/hardware/pigpiod/pi-gpiod.html
index 7f19ce79..86018771 100644
--- a/hardware/pigpiod/pi-gpiod.html
+++ b/hardware/pigpiod/pi-gpiod.html
@@ -399,6 +399,28 @@
+
+
+ Frequency: Hz
+
@@ -450,7 +472,8 @@
level: { value:"0" },
out: { value:"out" },
sermin: { value:"1000" },
- sermax: { value:"2000" }
+ sermax: { value:"2000" },
+ freq: { value:"800" }
},
inputs:1,
outputs:0,
@@ -478,29 +501,32 @@
var hidestate = function () {
if ($("#node-input-out").val() === "pwm") {
+ $('#node-set-freq').show();
$('#node-set-tick').hide();
$('#node-set-state').hide();
$('#node-set-minimax').hide();
$('#node-input-set').prop('checked', false);
- $("#dig-tip").hide();
- $("#pwm-tip").show();
- $("#ser-tip").hide();
+ $('#dig-tip').hide();
+ $('#pwm-tip').show();
+ $('#ser-tip').hide();
}
else if ($("#node-input-out").val() === "ser") {
+ $('#node-set-freq').hide();
$('#node-set-tick').hide();
$('#node-set-state').hide();
$('#node-set-minimax').show();
$('#node-input-set').prop('checked', false);
- $("#dig-tip").hide();
- $("#pwm-tip").hide();
- $("#ser-tip").show();
+ $('#dig-tip').hide();
+ $('#pwm-tip').hide();
+ $('#ser-tip').show();
}
else {
+ $('#node-set-freq').hide();
$('#node-set-tick').show();
$('#node-set-minimax').hide();
- $("#dig-tip").show();
- $("#pwm-tip").hide();
- $("#ser-tip").hide();
+ $('#dig-tip').show();
+ $('#pwm-tip').hide();
+ $('#ser-tip').hide();
}
};
$("#node-input-out").change(function () { hidestate(); });
diff --git a/hardware/pigpiod/pi-gpiod.js b/hardware/pigpiod/pi-gpiod.js
index 352d8c18..07b19d3c 100644
--- a/hardware/pigpiod/pi-gpiod.js
+++ b/hardware/pigpiod/pi-gpiod.js
@@ -86,6 +86,7 @@ module.exports = function(RED) {
this.set = n.set || false;
this.level = parseInt(n.level || 0);
this.out = n.out || "out";
+ this.freq = parseInt(n.freq) || 800;
this.sermin = Number(n.sermin)/100;
this.sermax = Number(n.sermax)/100;
if (this.sermin > this.sermax) {
@@ -120,6 +121,7 @@ module.exports = function(RED) {
PiGPIO.write(node.pin, out);
}
if (node.out === "pwm") {
+ PiGPIO.set_PWM_frequency(node.pin, node.freq);
PiGPIO.set_PWM_dutycycle(node.pin, parseInt(out * 2.55));
}
if (node.out === "ser") {