mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Handle users of old Blinkstick npm a bit more nicely.
Don't barf (quite so badly) on new API calls if they don't exist yet.
This commit is contained in:
parent
74a470c22e
commit
317aaa1b64
@ -60,9 +60,7 @@
|
||||
<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 either hex "#rrggbb" or decimal "red,green,blue" string.</div>
|
||||
|
||||
</script>
|
||||
<div class="form-tips">Expects a msg.payload with either hex "#rrggbb" or decimal "red,green,blue" string, or HTML color name.</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="blinkstick">
|
||||
@ -81,7 +79,7 @@
|
||||
{ 'task': 'pulse', 'color': 'gree', 'duration': 500 }
|
||||
{ 'task': 'morph', 'color': 'orange', 'duration': 500, 'steps': 20 }
|
||||
</pre>
|
||||
<p>For more info see <i><a href="http://www.blinkstick.com/help/tutorials" target="_new">BlinkStick tutorials</a></i>
|
||||
<p>For more info see <i><a href="http://www.blinkstick.com/help/tutorials" target="_new">BlinkStick tutorials</a></i>
|
||||
or the <i><a href="https://github.com/arvydas/blinkstick-node" target="_new">node module</a></i> documentation.</p>
|
||||
</script>
|
||||
|
||||
|
@ -165,7 +165,14 @@ module.exports = function(RED) {
|
||||
node.led.setColor(node.color, blinkstickAnimationComplete);
|
||||
}
|
||||
} catch (err) {
|
||||
node.warn("BlinkStick missing ? " + err);
|
||||
if (err.toString().indexOf("setColor") !== -1) {
|
||||
node.led.setColour(node.color, blinkstickAnimationComplete);
|
||||
node.warn("Old version - please upgrade Blinkstick npm");
|
||||
}
|
||||
else {
|
||||
node.warn("BlinkStick missing ? " + err);
|
||||
}
|
||||
console.log(err);
|
||||
//Reset animation
|
||||
animationComplete = true;
|
||||
//Clear color
|
||||
@ -233,7 +240,8 @@ module.exports = function(RED) {
|
||||
|
||||
if (Object.size(node.led) !== 0) {
|
||||
//Close device and stop animations
|
||||
this.led.close();
|
||||
if (typeof this.led.close === "function") { this.led.close(); }
|
||||
else { node.warn("Please upgrade blinkstick npm"); }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-blinkstick",
|
||||
"version" : "0.1.0",
|
||||
"version" : "0.1.1",
|
||||
"description" : "A Node-RED node to control a Blinkstick",
|
||||
"dependencies" : {
|
||||
"blinkstick" : "1.1.*"
|
||||
|
Loading…
x
Reference in New Issue
Block a user