From 0e955ea120505c2c03fffa9465f5da5a400b201b Mon Sep 17 00:00:00 2001 From: Dave C-J Date: Tue, 7 Jan 2014 16:00:55 +0000 Subject: [PATCH] Add @cheerlights colour handling to LEDBorg node for Pi... (just because) --- hardware/Pi/78-ledborg.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hardware/Pi/78-ledborg.js b/hardware/Pi/78-ledborg.js index 6108e7bd..31141b66 100644 --- a/hardware/Pi/78-ledborg.js +++ b/hardware/Pi/78-ledborg.js @@ -45,7 +45,19 @@ function LedBorgNode(n) { }); } else { - node.warn("Invalid LedBorg colour code"); + // you can add fancy colours by name here if you want... + // these are the @cheerlight ones. + var colors = {"red":"200","green":"020","blue":"002","cyan":"022","white":"222","pink":"201", + "warmwhite":"221","purple":"101","magenta":"202","yellow":"220","orange":"210","black":"000"} + if (msg.payload.toLowerCase() in colors) { + var c = colors[msg.payload.toLowerCase()]; + fs.writeFile('/dev/ledborg', c, function (err) { + if (err) node.warn(msg.payload+" : No LedBorg found"); + }); + } + else { + node.warn("Invalid LedBorg colour code"); + } } }); }