Skip to content

Commit 9347ef2

Browse files
committed
Revert "close fix" - seems to cause more hangs on redeploy than before.
1 parent 1fd5e80 commit 9347ef2

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

hardware/blink/77-blink1.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ function Blink1Node(n) {
4444
else {
4545
// you can add fancy colours by name here if you want...
4646
// these are the @cheerlight ones.
47-
var result = msg.payload.toLowerCase().match(/red|green|blue|cyan|white|warmwhite|purple|magenta|yellow|orange|black/g);
4847
var colors = {"red":"#FF0000","green":"#008000","blue":"#0000FF","cyan":"#00FFFF","white":"#FFFFFF",
4948
"warmwhite":"#FDF5E6","purple":"#800080","magenta":"#FF00FF","yellow":"#FFFF00","orange":"#FFA500","black":"#000000"}
50-
if (result != null) {
51-
for (var colour in result) {
52-
var c = colors[result[colour]];
53-
var r = parseInt(c.slice(1,3),16);
54-
var g = parseInt(c.slice(3,5),16);
55-
var b = parseInt(c.slice(5),16);
56-
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
57-
else { blink1.fadeToRGB(node.fade, r, g, b ); }
58-
}
49+
if (msg.payload.toLowerCase() in colors) {
50+
var c = colors[msg.payload.toLowerCase()];
51+
var r = parseInt(c.slice(1,3),16);
52+
var g = parseInt(c.slice(3,5),16);
53+
var b = parseInt(c.slice(5),16);
54+
if (node.fade == 0) { blink1.setRGB( r, g, b ); }
55+
else { blink1.fadeToRGB(node.fade, r, g, b ); }
5956
}
6057
else {
6158
node.warn("Blink1 : invalid msg : "+msg.payload);
@@ -66,11 +63,12 @@ function Blink1Node(n) {
6663
node.warn("No Blink1 found");
6764
}
6865
});
69-
this.on("close", function() {
70-
if (blink1 && typeof blink1.close == "function") {
71-
blink1.close();
72-
}
73-
});
66+
// This ought to work but seems to cause more hangs on closing than not...
67+
//this.on("close", function() {
68+
//if (blink1 && typeof blink1.close == "function") {
69+
//blink1.close();
70+
//}
71+
//});
7472
var blink1 = new Blink1.Blink1();
7573
}
7674
catch(e) {

0 commit comments

Comments
 (0)