1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'master' into 0.17

This commit is contained in:
Nick O'Leary 2017-04-10 15:45:21 +01:00
commit 67337e013a
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
5 changed files with 27 additions and 4 deletions

View File

@ -193,6 +193,10 @@
</select>
</div>
<br/>
<div class="form-row" id="node-set-freq">
<label for="node-input-freq"> <span data-i18n="rpi-gpio.label.freq"></span></label>
<input type="text" id="node-input-freq" placeholder="100">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
@ -210,6 +214,7 @@
<p>When using PWM mode - expects an input value of a number 0 - 100. It can be floating point.</p>
<p>PWM mode can be used to drive a servo using input values between 10 and 20 only.
The GPIO2 pin is best for this as it uses hardware to do the PWM.</p>
<p>Setting high PWM frequency might occupy more CPU than expected (default is 100Hz)</p>
<p>Requires the RPi.GPIO python library version 0.5.10 (or better) in order to work.</p>
<p><b>Note:</b> we are using the actual physical pin numbers on connector P1 as they are easier to locate.</p>
</script>
@ -224,6 +229,7 @@
pin: { value:"",required:true,validate:RED.validators.number() },
set: { value:"" },
level: { value:"0" },
freq: {value:""},
out: { value:"out" }
},
inputs:1,
@ -297,11 +303,13 @@
$('#node-input-set').prop('checked', false);
$("#dig-tip").hide();
$("#pwm-tip").show();
$('#node-set-freq').show();
}
else {
$('#node-set-tick').show();
$("#dig-tip").show();
$("#pwm-tip").hide();
$('#node-set-freq').hide();
}
};
$("#node-input-out").change(function () { hidestate(); });

View File

@ -137,6 +137,7 @@ module.exports = function(RED) {
this.pin = n.pin;
this.set = n.set || false;
this.level = n.level || 0;
this.freq = n.freq || 100;
this.out = n.out || "out";
var node = this;
if (!pinsInUse.hasOwnProperty(this.pin)) {
@ -173,7 +174,7 @@ module.exports = function(RED) {
node.child = spawn(gpioCommand, [node.out,node.pin,node.level]);
node.status({fill:"green",shape:"dot",text:node.level});
} else {
node.child = spawn(gpioCommand, [node.out,node.pin]);
node.child = spawn(gpioCommand, [node.out,node.pin,node.freq]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
}
node.running = true;

View File

@ -35,8 +35,13 @@ if len(sys.argv) > 2:
if cmd == "pwm":
#print "Initialised pin "+str(pin)+" to PWM"
try:
freq = int(sys.argv[3])
except:
freq = 100
GPIO.setup(pin,GPIO.OUT)
p = GPIO.PWM(pin, 100)
p = GPIO.PWM(pin, freq)
p.start(0)
while True:

View File

@ -659,7 +659,8 @@
"pikeyboard": "Pi Keyboard",
"left": "Left",
"right": "Right",
"middle": "Middle"
"middle": "Middle",
"freq": "Frequency (Hz)"
},
"resistor": {
"none": "none",
@ -681,7 +682,7 @@
"pin": "<b>Pins in Use</b>: ",
"in": "Tip: Only Digital Input is supported - input must be 0 or 1.",
"dig": "Tip: For digital output - input must be 0 or 1.",
"pwm": "Tip: For PWM output - input must be between 0 to 100."
"pwm": "Tip: For PWM output - input must be between 0 to 100; setting high frequency might occupy more CPU than expected."
},
"types": {
"digout": "digital output",

View File

@ -246,6 +246,14 @@ Node.prototype.error = function(logMessage,msg) {
}
};
Node.prototype.debug = function(msg) {
log_helper(this, Log.DEBUG, msg);
}
Node.prototype.trace = function(msg) {
log_helper(this, Log.TRACE, msg);
}
/**
* If called with no args, returns whether metric collection is enabled
*/