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);
|
||||
var p1 = /^\#[A-Za-z0-9]{6}$/
|
||||
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;
|
||||
|
||||
node.log("started");
|
||||
@ -40,14 +40,18 @@ function BlinkStick(n) {
|
||||
var rgb = msg.payload.split(",");
|
||||
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);
|
||||
}
|
||||
// TODO - need to handle colour strings...
|
||||
else {
|
||||
try {
|
||||
node.led.setColor(msg.payload);
|
||||
}
|
||||
catch (err) {
|
||||
node.error("Incorrect format: "+msg.payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
node.error("No BlinkStick found");
|
||||
}
|
||||
|
@ -29,13 +29,13 @@
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('blink',{
|
||||
category: 'output',
|
||||
color:"cornsilk",
|
||||
color:"GoldenRod",
|
||||
defaults: {
|
||||
name: {value:""}
|
||||
},
|
||||
inputs:1,
|
||||
outputs:0,
|
||||
icon: "arrow-in.png",
|
||||
icon: "light.png",
|
||||
align: "right",
|
||||
label: function() {
|
||||
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