Update Pi nodes to allow initial read / level set.

More consitent use of icons
Move to Raspberry Pi category
This commit is contained in:
Dave C-J 2014-10-27 20:28:05 +00:00
parent ecbde5d3d5
commit 48b0c3a68b
11 changed files with 141 additions and 54 deletions

View File

@ -19,13 +19,13 @@
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Expects a msg.payload with PiBorg three digit rgb colour string. 000 -> 222</div>
<div class="form-tips">See info panel for the various input options.</div>
</script>
<script type="text/x-red" data-help-name="ledborg">
<p>PiBorg LedBorg LED output node. Expects a <b>msg.payload</b> with a three digit rgb triple, from <b>000</b> to <b>222</b>.</p>
<p>See <i><a href="http://www.piborg.com/ledborg/install" target="_new">the PiBorg site</a></i> for more information.</p>
<p>You can also now use a <b>msg.payload</b> in the standard hex format "#rrggbb". The clip levels are :</p>
<p>You can also use a <b>msg.payload</b> in the standard hex format "#rrggbb". The clip levels are :</p>
<p><pre>0x00 - 0x57 = off<br/>0x58 - 0xA7 = 50%<br/>0xA8 - 0xFF = fully on</pre></p>
<p>You can also use the @cheerlight colour names - red, amber, green, blue, cyan, magenta, yellow, orange, pink, purple,
white, warmwhite, black</p>
@ -33,7 +33,7 @@
<script type="text/javascript">
RED.nodes.registerType('ledborg',{
category: 'output',
category: 'Rapsberry Pi',
color:"GoldenRod",
defaults: {
name: {value:""}

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-ledborg",
"version" : "0.0.1",
"version" : "0.0.2",
"description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.",
"dependencies" : {
},

View File

@ -1,5 +1,5 @@
<!--
Copyright 2013 IBM Corp.
Copyright 2013,2014 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@
<script type="text/x-red" data-template-name="rpi-piface in">
<div class="form-row">
<label for="node-input-pin"><i class="fa fa-asterisk"></i> GPIO Pin</label>
<label for="node-input-pin"><i class="fa fa-circle"></i> GPIO Pin</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="-" disabled>select pin</option>
<option value='' disabled selected style='display:none;'>select input</option>
<option value="Button S1">Button S1</option>
<option value="Button S2">Button S2</option>
<option value="Button S3">Button S3</option>
@ -38,12 +38,18 @@
</select>
</div>
<div class="form-row">
<label for="node-input-intype"><i class="fa fa-expand"></i> Resistor?</label>
<label for="node-input-intype"><i class="fa fa-level-up"></i> Resistor ?</label>
<select type="text" id="node-input-intype" style="width: 150px;">
<option value="up">pullup</option>
<option value="tri">none</option>
</select>
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-read" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-read" style="width: 70%;">Read initial state of pin on deploy/restart ?</label>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@ -61,12 +67,13 @@
<script type="text/javascript">
RED.nodes.registerType('rpi-piface in',{
category: 'advanced-input',
category: 'Raspberry Pi',
color:"#c6dbef",
defaults: {
name: { value:"" },
intype: { value: "up" },
pin: { value:"",required:true},
intype: { value: "up" },
read: { value:false }
},
inputs:0,
outputs:1,
@ -83,9 +90,9 @@
<script type="text/x-red" data-template-name="rpi-piface out">
<div class="form-row">
<label for="node-input-pin"><i class="fa fa-asterisk"></i> GPIO Pin</label>
<label for="node-input-pin"><i class="fa fa-circle"></i> GPIO Pin</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="-" disabled>select pin</option>
<option value='' disabled selected style='display:none;'>select output</option>
<option value="LED 0 / Relay 0">LED 0 / Relay 0</option>
<option value="LED 1 / Relay 1">LED 1 / Relay 1</option>
<option value="LED 2">LED 2</option>
@ -96,6 +103,19 @@
<option value="LED 7">LED 7</option>
</select>
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-set" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-set" style="width: 70%;">Initialise output state ?</label>
</div>
<div class="form-row" id="node-set-state">
<label for="node-input-level">&nbsp;</label>
<select id="node-input-level" style="width: 300px;">
<option value="0">initial level of output - off - low - 0</option>
<option value="1">initial level of output - on - high - 1</option>
</select>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@ -111,11 +131,13 @@
<script type="text/javascript">
RED.nodes.registerType('rpi-piface out',{
category: 'advanced-output',
category: 'Raspberry Pi',
color:"#c6dbef",
defaults: {
name: { value:"" },
pin: { value:"",required:true},
set: { value:false },
level: { value:"0" }
},
inputs:1,
outputs:0,
@ -126,6 +148,15 @@
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
$("#node-input-set").change(function() {
if ($('#node-input-set').is(":checked")) {
$("#node-set-state").show();
} else {
$("#node-set-state").hide();
}
});
}
});
</script>

View File

@ -1,5 +1,5 @@
/**
* Copyright 2013 IBM Corp.
* Copyright 2013,2014 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -63,6 +63,8 @@ module.exports = function(RED) {
this.npin = n.pin;
this.pin = pintable[n.pin];
this.intype = n.intype;
this.read = n.read || false;
if (this.read) { this.buttonState = -2; }
var node = this;
if (node.pin) {
exec("gpio -p mode "+node.pin+" "+node.intype, function(err,stdout,stderr) {
@ -99,6 +101,11 @@ module.exports = function(RED) {
this.pin = pintable[n.pin];
var node = this;
if (node.pin) {
if (node.set) {
exec("gpio -p write "+node.pin+" "+node.level, function(err,stdout,stderr) {
if (err) { node.error(err); }
});
}
node.on("input", function(msg) {
if (msg.payload === "true") { msg.payload = true; }
if (msg.payload === "false") { msg.payload = false; }

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-piface",
"version" : "0.0.1",
"version" : "0.0.2",
"description" : "Node-RED nodes to read from and write to a PiFace Digital Raspberry Pi add-on board",
"dependencies" : {
},

View File

@ -16,8 +16,9 @@
<script type="text/x-red" data-template-name="rpi-liter">
<div class="form-row">
<label for="node-input-pin"><i class="fa fa-asterisk"></i> Mode</label>
<label for="node-input-pin"><i class="fa fa-cog"></i> Mode</label>
<select type="text" id="node-input-pin" style="width: 350px;">
<option value='' disabled selected style='display:none;'>select mode</option>
<option value="pi-liter">0-255 : one bit per led</option>
<option value="meter">0-8 : turns on led indicated - needle</option>
<option value="bar">0-8 : turns on leds up to value - bar</option>
@ -36,26 +37,26 @@
<p>Raspberry Pi-LITEr output node. The Pi-LITEr must be fitted.</p>
<p>Operates in one of 5 different modes :</p>
<ul>
<li>Byte Mode - expects a value between 0 and 255, and each of the LEDs represent 1 bit.</li>
<li>Meter Mode - expects a value between 0 and 8, the led lit corresponds to the input value - like a meter needle.</li>
<li>Bar Mode - expects a value between 0 and 8, similar to meter - but all the leds up to the value are turned on - like a mini bar chart.</li>
<li>Object Mode - expects a object specifying the LED and state eg. <code>{led:3,state:0}</code> to set LED3 off.</li>
<li>All LEDs Mode - expects a 1 or 0 - turns on and off ALL the LEDs.</li>
<li><b>Byte Mode</b> - expects a value between 0 and 255, and each of the LEDs represent 1 bit.</li>
<li><b>Meter Mode</b> - expects a value between 0 and 8, the led lit corresponds to the input value - like a meter needle.</li>
<li><b>Bar Mode</b> - expects a value between 0 and 8, similar to meter - but all the leds up to the value are turned on - like a mini bar chart.</li>
<li><b>Object Mode</b> - expects a object specifying the LED and state eg. <code>{led:3,state:0}</code> to set LED3 off.</li>
<li><b>All LEDs Mode</b> - expects a 1 or 0 - turns on and off ALL the LEDs.</li>
</ul>
<p>Requires the WiringPi gpio command in order to work.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('rpi-liter',{
category: 'advanced-output',
color:"#c6dbef",
category: 'Raspberry Pi',
color:"GoldenRod",
defaults: {
name: { value:"" },
pin: { value:"" }
pin: { value:"",required:true }
},
inputs:1,
outputs:0,
icon: "rpi.png",
icon: "light.png",
align: "right",
label: function() {
return this.name||"Pi-LITEr";

View File

@ -19,9 +19,9 @@ module.exports = function(RED) {
var exec = require('child_process').exec;
var fs = require('fs');
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
throw "Info : Ignoring Raspberry Pi specific node.";
}
//if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
//throw "Info : Ignoring Raspberry Pi specific node.";
//}
if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed
throw "Info : Can't find Raspberry Pi wiringPi gpio command.";

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-piliter",
"version" : "0.0.1",
"version" : "0.0.2",
"description" : "A Node-RED node to drive a Raspberry Pi Pi-LITEr 8 LED board.",
"dependencies" : {
},

View File

@ -16,9 +16,9 @@
<script type="text/x-red" data-template-name="rpi-pibrella in">
<div class="form-row">
<label for="node-input-pin"><i class="fa fa-asterisk"></i> Input</label>
<label for="node-input-pin"><i class="fa fa-circle"></i> Input</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="-">select input</option>
<option value='' disabled selected style='display:none;'>select input</option>
<option value="Red Button">Red Button</option>
<option value="In A">In A</option>
<option value="In B">In B</option>
@ -26,6 +26,12 @@
<option value="In D">In D</option>
</select>
</div>
<div class="form-row">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-read" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-read" style="width: 70%;">Read initial state of pin on deploy/restart ?</label>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
@ -41,11 +47,12 @@
<script type="text/javascript">
RED.nodes.registerType('rpi-pibrella in',{
category: 'advanced-input',
category: 'Raspberry Pi',
color:"#c6dbef",
defaults: {
name: { value:"" },
pin: { value:"",required:true,validate:RED.validators.regex(/ /) }
pin: { value:"",required:true,validate:RED.validators.regex(/ /) },
read: { value:false }
},
inputs:0,
outputs:1,
@ -62,9 +69,9 @@
<script type="text/x-red" data-template-name="rpi-pibrella out">
<div class="form-row">
<label for="node-input-pin"><i class="fa fa-asterisk"></i> Output</label>
<label for="node-input-pin"><i class="fa fa-circle"></i> Output</label>
<select type="text" id="node-input-pin" style="width: 150px;">
<option value="-">select output</option>
<option value='' disabled selected style='display:none;'>select output</option>
<option value="Red LED">Red LED</option>
<option value="Amber LED">Amber LED</option>
<option value="Green LED">Green LED</option>
@ -75,11 +82,24 @@
<option value="Buzzer ">Buzzer</option>
</select>
</div>
<div class="form-row" id="node-set-check">
<label>&nbsp;</label>
<input type="checkbox" id="node-input-set" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-set" style="width: 70%;">Initialise output state ?</label>
</div>
<div class="form-row" id="node-set-state" hidden>
<label for="node-input-level">&nbsp;</label>
<select id="node-input-level" style="width: 300px;">
<option value="0">initial level of output - off - low - 0</option>
<option value="1">initial level of output - on - high - 1</option>
</select>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Buzzer takes <b>msg.payload</b> between 2 (high) and 512 (low), or 0 for off.</div>
<div class="form-tips" id="node-buzz-tip">Buzzer takes <b>msg.payload</b> between 2 (high) and 512 (low), or 0 for off.</div>
</script>
<script type="text/x-red" data-help-name="rpi-pibrella out">
@ -91,11 +111,13 @@
<script type="text/javascript">
RED.nodes.registerType('rpi-pibrella out',{
category: 'advanced-output',
category: 'Raspberry Pi',
color:"#c6dbef",
defaults: {
name: { value:"" },
pin: { value:"",required:true,validate:RED.validators.regex(/ /) }
pin: { value:"",required:true,validate:RED.validators.regex(/ /) },
set: { value:false },
level: { value:"0" }
},
inputs:1,
outputs:0,
@ -106,6 +128,25 @@
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
$("#node-input-set").change(function() {
if ($('#node-input-set').is(":checked")) {
$("#node-set-state").show();
} else {
$("#node-set-state").hide();
}
});
$("#node-input-pin").change(function() {
if ($('#node-input-pin').val() !== "Buzzer ") {
$("#node-set-check").show();
$("#node-buzz-tip").hide();
} else {
$("#node-set-check").hide();
$("#node-buzz-tip").show();
}
$("#node-input-set").change();
});
}
});
</script>

View File

@ -66,6 +66,8 @@ module.exports = function(RED) {
RED.nodes.createNode(this,n);
this.buttonState = -1;
this.pin = pintable[n.pin];
this.read = n.read || false;
if (this.read) { this.buttonState = -2; }
var node = this;
if (node.pin) {
@ -102,6 +104,8 @@ module.exports = function(RED) {
function PibrellaOut(n) {
RED.nodes.createNode(this,n);
this.pin = pintable[n.pin];
this.set = n.set || false;
this.level = n.level || 0;
var node = this;
if (node.pin == "1") {
@ -123,23 +127,26 @@ module.exports = function(RED) {
});
}
else if (node.pin) {
process.nextTick(function() {
exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) {
if (err) { node.error(err); }
else {
node.on("input", function(msg) {
if (msg.payload === "true") { msg.payload = true; }
if (msg.payload === "false") { msg.payload = false; }
var out = Number(msg.payload);
if ((out === 0)|(out === 1)) {
exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) {
if (err) { node.error(err); }
});
}
else { node.warn("Invalid input - not 0 or 1"); }
exec("gpio mode "+node.pin+" out", function(err,stdout,stderr) {
if (err) { node.error(err); }
else {
if (node.set) {
exec("gpio write "+node.pin+" "+node.level, function(err,stdout,stderr) {
if (err) { node.error(err); }
});
}
});
node.on("input", function(msg) {
if (msg.payload === "true") { msg.payload = true; }
if (msg.payload === "false") { msg.payload = false; }
var out = Number(msg.payload);
if ((out === 0)|(out === 1)) {
exec("gpio write "+node.pin+" "+out, function(err,stdout,stderr) {
if (err) { node.error(err); }
});
}
else { node.warn("Invalid input - not 0 or 1"); }
});
}
});
}
else {

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-pibrella",
"version" : "0.0.2",
"version" : "0.0.3",
"description" : "A Node-RED node to read from and write to a Pibrella Raspberry Pi add-on board",
"dependencies" : {
},