diff --git a/hardware/blinkstick/76-blinkstick.html b/hardware/blinkstick/76-blinkstick.html
index c70c0316..9ea14601 100644
--- a/hardware/blinkstick/76-blinkstick.html
+++ b/hardware/blinkstick/76-blinkstick.html
@@ -22,6 +22,15 @@
+
+
+
+
+
-
@@ -120,6 +128,7 @@
defaults: { // defines the default editable properties of the node
name: {value:""}, // along with default values.
serial: {value:""},
+ mode: {value:"normal", validate:function(v) {return ((v === undefined)||v=="normal"||v=="inverted"||v=="neopixel"); }},
task: {value:"set_color", validate:function(v) {return ((v === undefined)||v=="set_color"||v=="blink"||v=="morph"||v=="pulse"); }},
delay: {value:"500", validate:function(v) {return ((v === undefined)||(/^\d+$/).test(v)); }},
repeats: {value:"1", validate:function(v) {return ((v === undefined)||(/^\d+$/).test(v)); }},
@@ -138,6 +147,10 @@
return this.name?"node_label_italic":"";
},
oneditprepare: function() {
+ if (!$("#node-input-mode").val()) {
+ $("#node-input-mode").val("normal");
+ }
+
if (!$("#node-input-task").val()) {
$("#node-input-task").val("set_color");
}
diff --git a/hardware/blinkstick/76-blinkstick.js b/hardware/blinkstick/76-blinkstick.js
index 933fb8f7..3acb9804 100644
--- a/hardware/blinkstick/76-blinkstick.js
+++ b/hardware/blinkstick/76-blinkstick.js
@@ -19,6 +19,7 @@ module.exports = function(RED) {
"use strict";
var blinkstick = require("blinkstick");
+ var availableModes = ["normal", "inverted", "neopixel"];
var availableTasks = ["set_color", "blink", "pulse", "morph"];
Object.size = function(obj) {
@@ -74,6 +75,7 @@ module.exports = function(RED) {
this.name = n.name;
this.serial = n.serial;
+ this.mode = n.mode || "normal";
this.task = n.task || "set_color";
this.delay = n.delay || 500;
this.repeats = n.repeats || 1;
@@ -101,6 +103,9 @@ module.exports = function(RED) {
node.error("BlinkStick with serial number " + node.serial + " not found");
} else {
node.status({fill:"green",shape:"dot",text:"connected"});
+ if(node.mode == "normal"){node.led.setMode(0);}
+ else if(node.mode == "inverted"){node.led.setMode(1);}
+ else if(node.mode == "neopixel"){node.led.setMode(2);}
if (callback) { callback(); }
}
});
@@ -112,6 +117,9 @@ module.exports = function(RED) {
node.error("No BlinkStick found");
} else {
node.status({fill:"green",shape:"dot",text:"connected"});
+ if(node.mode == "normal"){node.led.setMode(0);}
+ else if(node.mode == "inverted"){node.led.setMode(1);}
+ else if(node.mode == "neopixel"){node.led.setMode(2);}
if (callback) { callback(); }
}
}
@@ -196,7 +204,6 @@ module.exports = function(RED) {
// if it's an array then hopefully it's r,g,b,r,g,b or name,name,name
if (Array.isArray(msg.payload)) {
if (Object.size(node.led) !== 0) {
- node.led.setMode(2); // put it into ws2812B LED mode
var dat = [];
for (var i = 0; i < msg.payload.length; i++) {
if (typeof msg.payload[i] === "string") { // if string then assume must be colour names
diff --git a/hardware/blinkstick/README.md b/hardware/blinkstick/README.md
index 4eaeecc4..3f38f1d5 100644
--- a/hardware/blinkstick/README.md
+++ b/hardware/blinkstick/README.md
@@ -16,7 +16,7 @@ For more information see