mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
added/allowed text colour names for BlinkStick
This commit is contained in:
parent
8300952254
commit
36ae1dd0ef
@ -29,7 +29,7 @@ function BlinkStick(n) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
var p1 = /^\#[A-Za-z0-9]{6}$/
|
var p1 = /^\#[A-Za-z0-9]{6}$/
|
||||||
var p2 = /[0-9]+,[0-9]+,[0-9]+/
|
var p2 = /[0-9]+,[0-9]+,[0-9]+/
|
||||||
this.led = blinkstick.findFirst(); // maybe try findAll() ?
|
this.led = blinkstick.findFirst(); // maybe try findAll() (one day)
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
node.log("started");
|
node.log("started");
|
||||||
@ -40,12 +40,16 @@ function BlinkStick(n) {
|
|||||||
var rgb = msg.payload.split(",");
|
var rgb = msg.payload.split(",");
|
||||||
node.led.setColor(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
|
node.led.setColor(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
|
||||||
}
|
}
|
||||||
if ((p1.test(msg.payload))|(p2.test(msg.payload))) {
|
else if ((p1.test(msg.payload))|(p2.test(msg.payload))) {
|
||||||
node.led.setColor(msg.payload);
|
node.led.setColor(msg.payload);
|
||||||
}
|
}
|
||||||
// TODO - need to handle colour strings...
|
|
||||||
else {
|
else {
|
||||||
node.error("Incorrect format: "+msg.payload);
|
try {
|
||||||
|
node.led.setColor(msg.payload);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
node.error("Incorrect format: "+msg.payload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -29,13 +29,13 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('blink',{
|
RED.nodes.registerType('blink',{
|
||||||
category: 'output',
|
category: 'output',
|
||||||
color:"cornsilk",
|
color:"GoldenRod",
|
||||||
defaults: {
|
defaults: {
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
outputs:0,
|
outputs:0,
|
||||||
icon: "arrow-in.png",
|
icon: "light.png",
|
||||||
align: "right",
|
align: "right",
|
||||||
label: function() {
|
label: function() {
|
||||||
return this.name||"blink1";
|
return this.name||"blink1";
|
||||||
|
BIN
public/icons/light.png
Normal file
BIN
public/icons/light.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 288 B |
Loading…
Reference in New Issue
Block a user