Bump up libraries for "old" blinkstick

This commit is contained in:
Dave Conway-Jones 2021-01-17 17:29:15 +00:00
parent 54be2e679e
commit 3bc16fbd55
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 118 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<script type="text/x-red" data-template-name="blinkstick">
<script type="text/html" data-template-name="blinkstick">
<div class="form-row">
<div class="form-row" id="node-input-row-payload">
<label for="node-input-serial">Serial</label>
@ -55,7 +55,7 @@
<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">
<script type="text/html" data-help-name="blinkstick">
<p><i><a href="http://www.blinkstick.com" target="_new">BlinkStick</a></i> output node. Expects a <code>msg.payload</code> with one of:</p>
<ul>
<li>A hex string <b>"#rrggbb"</b> triple</li>

View File

@ -0,0 +1,50 @@
<!--
Copyright 2013 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/html" data-template-name="blinkstick">
<div class="form-row">
<label for="node-input-name"><i class="icon-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.</div>
</script>
<script type="text/html" data-help-name="blinkstick">
<p>BlinkStick output node. Expects a <b>msg.payload</b> with either a hex string #rrggbb triple or red,green,blue as three 0-255 values.
It can also accept <i><a href="http://www.w3schools.com/html/html_colornames.asp" target="_new">standard HTML colour</a></i> names</p>
<p><b>NOTE:</b> currently only works with a single BlinkStick. (As it uses the findFirst() function to attach).</p>
<p>For more info see the <i><a href="http://blinkstick.com/" target="_new">BlinkStick website</a></i> or the <i><a href="https://github.com/arvydas/blinkstick-node" target="_new">node module</a></i> documentation.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('blinkstick',{
category: 'output',
color:"GoldenRod",
defaults: {
name: {value:""}
},
inputs:1,
outputs:0,
icon: "light.png",
align: "right",
label: function() {
return this.name||"blinkstick";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>

View File

@ -0,0 +1,64 @@
/**
* Copyright 2013 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
module.exports = function(RED) {
"use strict";
var blinkstick = require("blinkstick");
Object.size = function(obj) {
var size = 0;
for (var key in obj) { if (obj.hasOwnProperty(key)) { size++; } }
return size;
};
function BlinkStick(n) {
RED.nodes.createNode(this,n);
var p1 = /^\#[A-Fa-f0-9]{6}$/
var p2 = /[0-9]+,[0-9]+,[0-9]+/
this.led = blinkstick.findFirst(); // maybe try findAll() (one day)
var node = this;
this.on("input", function(msg) {
if (msg != null) {
if (Object.size(node.led) !== 0) {
try {
if (p2.test(msg.payload)) {
var rgb = msg.payload.split(",");
node.led.setColor(parseInt(rgb[0])&255, parseInt(rgb[1])&255, parseInt(rgb[2])&255);
}
else {
node.led.setColor(msg.payload.toLowerCase().replace(/\s+/g,''));
}
}
catch (err) {
node.warn("BlinkStick missing ?");
node.led = blinkstick.findFirst();
}
}
else {
//node.warn("No BlinkStick found");
node.led = blinkstick.findFirst();
}
}
});
if (Object.size(node.led) === 0) {
node.error("No BlinkStick found");
}
}
RED.nodes.registerType("blinkstick",BlinkStick);
}

View File

@ -1,9 +1,9 @@
{
"name" : "node-red-node-blinkstick",
"version" : "0.1.16",
"version" : "0.1.7",
"description" : "A Node-RED node to control a Blinkstick",
"dependencies" : {
"blinkstick" : "1.1.3"
"blinkstick" : "1.2.0"
},
"repository" : {
"type":"git",