mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add option to set frequency
This commit is contained in:
parent
84a445d9d8
commit
0984f91f8b
@ -7,6 +7,8 @@
|
|||||||
"resistor": "Resistor?",
|
"resistor": "Resistor?",
|
||||||
"readinitial": "Read initial state of pin on deploy/restart?",
|
"readinitial": "Read initial state of pin on deploy/restart?",
|
||||||
"type": "Type",
|
"type": "Type",
|
||||||
|
"setfreq": "Set frequency?",
|
||||||
|
"freq": "Frequency",
|
||||||
"initpin": "Initialise pin state?",
|
"initpin": "Initialise pin state?",
|
||||||
"debounce": "Debounce",
|
"debounce": "Debounce",
|
||||||
"limits": "Limits",
|
"limits": "Limits",
|
||||||
|
@ -381,6 +381,15 @@
|
|||||||
<option value="ser" data-i18n="pi-gpiod.servo"></option>
|
<option value="ser" data-i18n="pi-gpiod.servo"></option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-row" id="node-set-freq-tick">
|
||||||
|
<label> </label>
|
||||||
|
<input type="checkbox" id="node-input-setfreq" style="display:inline-block; width:auto; vertical-align:top;">
|
||||||
|
<label for="node-input-setfreq" style="width:70%;"><span data-i18n="pi-gpiod.label.setfreq"></span></label>
|
||||||
|
</div>
|
||||||
|
<div class="form-row" id="node-set-frequency">
|
||||||
|
<label> <span data-i18n="pi-gpiod.label.freq"></label>
|
||||||
|
<input type="text" id="node-input-freq" style="width:70px;"> Hz
|
||||||
|
</div>
|
||||||
<div class="form-row" id="node-set-minimax">
|
<div class="form-row" id="node-set-minimax">
|
||||||
<label> <span data-i18n="pi-gpiod.label.limits"></label>
|
<label> <span data-i18n="pi-gpiod.label.limits"></label>
|
||||||
<span data-i18n="pi-gpiod.label.min"></span> <input type="text" id="node-input-sermin" style="width:70px;"> uS
|
<span data-i18n="pi-gpiod.label.min"></span> <input type="text" id="node-input-sermin" style="width:70px;"> uS
|
||||||
@ -448,6 +457,8 @@
|
|||||||
set: { value:"" },
|
set: { value:"" },
|
||||||
level: { value:"0" },
|
level: { value:"0" },
|
||||||
out: { value:"out" },
|
out: { value:"out" },
|
||||||
|
setfreq: { value:""},
|
||||||
|
freq: { value:"800" },
|
||||||
sermin: { value:"1000" },
|
sermin: { value:"1000" },
|
||||||
sermax: { value:"2000" }
|
sermax: { value:"2000" }
|
||||||
},
|
},
|
||||||
@ -479,8 +490,9 @@
|
|||||||
if ($("#node-input-out").val() === "pwm") {
|
if ($("#node-input-out").val() === "pwm") {
|
||||||
$('#node-set-tick').hide();
|
$('#node-set-tick').hide();
|
||||||
$('#node-set-state').hide();
|
$('#node-set-state').hide();
|
||||||
$('#node-set-minimax').hide();
|
|
||||||
$('#node-input-set').prop('checked', false);
|
$('#node-input-set').prop('checked', false);
|
||||||
|
$('#node-set-freq-tick').show();
|
||||||
|
$('#node-set-minimax').hide();
|
||||||
$("#dig-tip").hide();
|
$("#dig-tip").hide();
|
||||||
$("#pwm-tip").show();
|
$("#pwm-tip").show();
|
||||||
$("#ser-tip").hide();
|
$("#ser-tip").hide();
|
||||||
@ -488,14 +500,20 @@
|
|||||||
else if ($("#node-input-out").val() === "ser") {
|
else if ($("#node-input-out").val() === "ser") {
|
||||||
$('#node-set-tick').hide();
|
$('#node-set-tick').hide();
|
||||||
$('#node-set-state').hide();
|
$('#node-set-state').hide();
|
||||||
$('#node-set-minimax').show();
|
|
||||||
$('#node-input-set').prop('checked', false);
|
$('#node-input-set').prop('checked', false);
|
||||||
|
$('#node-set-freq-tick').hide();
|
||||||
|
$("#node-set-frequency").hide();
|
||||||
|
$('#node-input-setfreq').prop('checked', false);
|
||||||
|
$('#node-set-minimax').show();
|
||||||
$("#dig-tip").hide();
|
$("#dig-tip").hide();
|
||||||
$("#pwm-tip").hide();
|
$("#pwm-tip").hide();
|
||||||
$("#ser-tip").show();
|
$("#ser-tip").show();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('#node-set-tick').show();
|
$('#node-set-tick').show();
|
||||||
|
$('#node-set-freq-tick').hide();
|
||||||
|
$("#node-set-frequency").hide();
|
||||||
|
$('#node-input-setfreq').prop('checked', false);
|
||||||
$('#node-set-minimax').hide();
|
$('#node-set-minimax').hide();
|
||||||
$("#dig-tip").show();
|
$("#dig-tip").show();
|
||||||
$("#pwm-tip").hide();
|
$("#pwm-tip").hide();
|
||||||
@ -515,6 +533,16 @@
|
|||||||
$("#node-input-set").change(function () { setstate(); });
|
$("#node-input-set").change(function () { setstate(); });
|
||||||
setstate();
|
setstate();
|
||||||
|
|
||||||
|
var setfreqstate = function () {
|
||||||
|
if ($('#node-input-setfreq').is(":checked")) {
|
||||||
|
$("#node-set-frequency").show();
|
||||||
|
} else {
|
||||||
|
$("#node-set-frequency").hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$("#node-input-setfreq").change(function () { setfreqstate(); });
|
||||||
|
setfreqstate();
|
||||||
|
|
||||||
$('#pinform input').on('change', function() {
|
$('#pinform input').on('change', function() {
|
||||||
this.pin = $("#pinform input[type='radio']:checked").val();
|
this.pin = $("#pinform input[type='radio']:checked").val();
|
||||||
$("#node-input-pin").val(this.pin);
|
$("#node-input-pin").val(this.pin);
|
||||||
|
@ -86,6 +86,10 @@ 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.setfreq = n.setfreq || false;
|
||||||
|
this.freq = Number(n.freq || 800);
|
||||||
|
if (this.freq < 5) { this.freq = 5; }
|
||||||
|
if (this.freq > 40000) { this.freq = 40000; }
|
||||||
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) {
|
||||||
@ -142,10 +146,10 @@ module.exports = function(RED) {
|
|||||||
} else {
|
} else {
|
||||||
node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
|
node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
|
||||||
}
|
}
|
||||||
// if (node.out === "pwm") {
|
if (node.setfreq) {
|
||||||
// PiGPIO.set_PWM_frequency(1000);
|
PiGPIO.set_PWM_frequency(node.pin,node.freq);
|
||||||
// PiGPIO.set_PWM_range(1000);
|
}
|
||||||
// }
|
//PiGPIO.set_PWM_range(node.pin,1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user