Let blinkstick handle strings of neopixels

This commit is contained in:
dceejay 2015-03-25 08:33:02 +00:00
parent 24394c4b18
commit 63abf0a8c3
2 changed files with 75 additions and 70 deletions

View File

@ -97,7 +97,7 @@ module.exports = function(RED) {
node.led = device;
if (Object.size(node.led) === 0) {
node.status({fill:"red",shape:"ring",text:"disconnected"});
node.status({fill:"red",shape:"ring",text:"not found"});
node.error("BlinkStick with serial number " + node.serial + " not found");
} else {
node.status({fill:"green",shape:"dot",text:"connected"});
@ -108,7 +108,7 @@ module.exports = function(RED) {
node.led = blinkstick.findFirst();
if (Object.size(node.led) === 0) {
node.status({fill:"red",shape:"ring",text:"disconnected"});
node.status({fill:"red",shape:"ring",text:"not found"});
node.error("No BlinkStick found");
} else {
node.status({fill:"green",shape:"dot",text:"connected"});
@ -172,7 +172,7 @@ module.exports = function(RED) {
else {
node.warn("BlinkStick missing ? " + err);
}
console.log(err);
node.log(err);
//Reset animation
animationComplete = true;
//Clear color
@ -191,6 +191,7 @@ module.exports = function(RED) {
findBlinkStick();
this.on("input", function(msg) {
if (typeof(node.led) !== "undefined") {
if (typeof(msg.payload) === 'object' ) {
// if it's an array then hopefully it's r,g,b,r,g,b or name,name,name
if (Array.isArray(msg.payload)) {
@ -241,7 +242,6 @@ module.exports = function(RED) {
return;
}
}
} else if (p1.test(msg.payload)) {
//Color value is represented as "red,green,blue" string of bytes
var rgb = msg.payload.split(",");
@ -267,6 +267,11 @@ module.exports = function(RED) {
}
});
}
}
else {
node.status({fill:"red",shape:"ring",text:"not found"});
node.error("BlinkStick not found",msg);
}
});
this.on("close", function() {

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-blinkstick",
"version" : "0.1.3",
"version" : "0.1.5",
"description" : "A Node-RED node to control a Blinkstick",
"dependencies" : {
"blinkstick" : "1.1.*"