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

make Pi SRF topic editable/optional

This commit is contained in:
Dave Conway-Jones 2017-05-13 12:46:24 +01:00
parent 13fbfc4f22
commit d7e7756dcf
No known key found for this signature in database
GPG Key ID: 81B04231572A9A2D
3 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-pisrf",
"version" : "0.0.4",
"version" : "0.0.5",
"description" : "A Node-RED node for a Raspberry Pi to use a SRF04 or SRF05 range finder",
"dependencies" : {
},

View File

@ -4,6 +4,10 @@
<label for="node-input-pins"><i class="fa fa-circle"></i> Pins</label>
<input type="text" id="node-input-pins" placeholder="Trigger,Echo">
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-bars"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="optional topic">
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
@ -26,6 +30,7 @@
color:"#c6dbef",
defaults: {
name: { value:"" },
topic: { value:"SRF" },
pins: { value:"", required:true, validate:RED.validators.regex(/^\d+,\d+$/) }
},
inputs:0,

View File

@ -24,6 +24,7 @@ module.exports = function(RED) {
function PiSrfNode(n) {
RED.nodes.createNode(this, n);
this.topic = n.topic;
this.pins = n.pins;
var node = this;
@ -36,7 +37,7 @@ module.exports = function(RED) {
if (RED.settings.verbose) { node.log("out: " + data + " :"); }
data = data.toString().trim();
if (data.length > 0) {
node.send({topic:"SRF",payload:data});
node.send({topic:node.topic, payload:data});
}
});