mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Add frequency select to pigpiod node
This commit is contained in:
parent
4bdb6216d3
commit
3a007399f6
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-node-pi-gpiod",
|
"name": "node-red-node-pi-gpiod",
|
||||||
"version": "0.1.1",
|
"version": "0.2.0",
|
||||||
"description": "A node-red node for PiGPIOd",
|
"description": "A node-red node for PiGPIOd",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"js-pigpio": "*"
|
"js-pigpio": "*"
|
||||||
|
@ -399,6 +399,28 @@
|
|||||||
<option value="1" data-i18n="pi-gpiod.initpin1"></option>
|
<option value="1" data-i18n="pi-gpiod.initpin1"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row" id="node-set-freq">
|
||||||
|
<label for="node-input-freq"> <span data-i18n="rpi-gpio.label.freq"></span></label>
|
||||||
|
Frequency: <select id="node-input-freq" style="width:80px;">
|
||||||
|
<option value="8000">8000</option>
|
||||||
|
<option value="4000">4000</option>
|
||||||
|
<option value="2000">2000</option>
|
||||||
|
<option value="1600">1600</option>
|
||||||
|
<option value="1000">1000</option>
|
||||||
|
<option value="800">800</option>
|
||||||
|
<option value="500">500</option>
|
||||||
|
<option value="400">400</option>
|
||||||
|
<option value="320">320</option>
|
||||||
|
<option value="250">250</option>
|
||||||
|
<option value="200">200</option>
|
||||||
|
<option value="160">160</option>
|
||||||
|
<option value="80">80</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="40">40</option>
|
||||||
|
<option value="20">20</option>
|
||||||
|
<option value="10">10</option>
|
||||||
|
</select> Hz
|
||||||
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-host"><i class="fa fa-globe"></i> <span data-i18n="pi-gpiod.label.host"></label>
|
<label for="node-input-host"><i class="fa fa-globe"></i> <span data-i18n="pi-gpiod.label.host"></label>
|
||||||
<input type="text" id="node-input-host" placeholder="localhost" style="width:250px;">
|
<input type="text" id="node-input-host" placeholder="localhost" style="width:250px;">
|
||||||
@ -450,7 +472,8 @@
|
|||||||
level: { value:"0" },
|
level: { value:"0" },
|
||||||
out: { value:"out" },
|
out: { value:"out" },
|
||||||
sermin: { value:"1000" },
|
sermin: { value:"1000" },
|
||||||
sermax: { value:"2000" }
|
sermax: { value:"2000" },
|
||||||
|
freq: { value:"800" }
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
outputs:0,
|
outputs:0,
|
||||||
@ -478,29 +501,32 @@
|
|||||||
|
|
||||||
var hidestate = function () {
|
var hidestate = function () {
|
||||||
if ($("#node-input-out").val() === "pwm") {
|
if ($("#node-input-out").val() === "pwm") {
|
||||||
|
$('#node-set-freq').show();
|
||||||
$('#node-set-tick').hide();
|
$('#node-set-tick').hide();
|
||||||
$('#node-set-state').hide();
|
$('#node-set-state').hide();
|
||||||
$('#node-set-minimax').hide();
|
$('#node-set-minimax').hide();
|
||||||
$('#node-input-set').prop('checked', false);
|
$('#node-input-set').prop('checked', false);
|
||||||
$("#dig-tip").hide();
|
$('#dig-tip').hide();
|
||||||
$("#pwm-tip").show();
|
$('#pwm-tip').show();
|
||||||
$("#ser-tip").hide();
|
$('#ser-tip').hide();
|
||||||
}
|
}
|
||||||
else if ($("#node-input-out").val() === "ser") {
|
else if ($("#node-input-out").val() === "ser") {
|
||||||
|
$('#node-set-freq').hide();
|
||||||
$('#node-set-tick').hide();
|
$('#node-set-tick').hide();
|
||||||
$('#node-set-state').hide();
|
$('#node-set-state').hide();
|
||||||
$('#node-set-minimax').show();
|
$('#node-set-minimax').show();
|
||||||
$('#node-input-set').prop('checked', false);
|
$('#node-input-set').prop('checked', false);
|
||||||
$("#dig-tip").hide();
|
$('#dig-tip').hide();
|
||||||
$("#pwm-tip").hide();
|
$('#pwm-tip').hide();
|
||||||
$("#ser-tip").show();
|
$('#ser-tip').show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$('#node-set-freq').hide();
|
||||||
$('#node-set-tick').show();
|
$('#node-set-tick').show();
|
||||||
$('#node-set-minimax').hide();
|
$('#node-set-minimax').hide();
|
||||||
$("#dig-tip").show();
|
$('#dig-tip').show();
|
||||||
$("#pwm-tip").hide();
|
$('#pwm-tip').hide();
|
||||||
$("#ser-tip").hide();
|
$('#ser-tip').hide();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$("#node-input-out").change(function () { hidestate(); });
|
$("#node-input-out").change(function () { hidestate(); });
|
||||||
|
@ -86,6 +86,7 @@ module.exports = function(RED) {
|
|||||||
this.set = n.set || false;
|
this.set = n.set || false;
|
||||||
this.level = parseInt(n.level || 0);
|
this.level = parseInt(n.level || 0);
|
||||||
this.out = n.out || "out";
|
this.out = n.out || "out";
|
||||||
|
this.freq = parseInt(n.freq) || 800;
|
||||||
this.sermin = Number(n.sermin)/100;
|
this.sermin = Number(n.sermin)/100;
|
||||||
this.sermax = Number(n.sermax)/100;
|
this.sermax = Number(n.sermax)/100;
|
||||||
if (this.sermin > this.sermax) {
|
if (this.sermin > this.sermax) {
|
||||||
@ -120,6 +121,7 @@ module.exports = function(RED) {
|
|||||||
PiGPIO.write(node.pin, out);
|
PiGPIO.write(node.pin, out);
|
||||||
}
|
}
|
||||||
if (node.out === "pwm") {
|
if (node.out === "pwm") {
|
||||||
|
PiGPIO.set_PWM_frequency(node.pin, node.freq);
|
||||||
PiGPIO.set_PWM_dutycycle(node.pin, parseInt(out * 2.55));
|
PiGPIO.set_PWM_dutycycle(node.pin, parseInt(out * 2.55));
|
||||||
}
|
}
|
||||||
if (node.out === "ser") {
|
if (node.out === "ser") {
|
||||||
|
Loading…
Reference in New Issue
Block a user