From 39fd3b85cd74caa48f54131a011462023bf0047c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 31 Aug 2017 11:25:44 +0100 Subject: [PATCH] update neo-pixel and unicorn hat nodes to use later libs --- hardware/neopixel/neopix.py | 6 +++++- hardware/neopixel/neopixel.js | 2 +- hardware/neopixel/package.json | 2 +- hardware/neopixel/scripts/checklib.js | 2 +- hardware/unicorn/package.json | 2 +- hardware/unicorn/scripts/checklib.js | 2 +- hardware/unicorn/unicorn.js | 2 +- 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/hardware/neopixel/neopix.py b/hardware/neopixel/neopix.py index f80e4bd8..0fbee6d0 100755 --- a/hardware/neopixel/neopix.py +++ b/hardware/neopixel/neopix.py @@ -3,7 +3,11 @@ # Import library functions we need import sys import time -from neopixel import * +try: + from rpi_ws281x import __version__, PixelStrip, Adafruit_NeoPixel, Color +except ImportError: + from neopixel import Adafruit_NeoPixel as PixelStrip, Color + __version__ = "legacy" # LED strip configuration: LED_COUNT = 8 # Number of LED pixels. diff --git a/hardware/neopixel/neopixel.js b/hardware/neopixel/neopixel.js index 8d146703..e31ceb8c 100644 --- a/hardware/neopixel/neopixel.js +++ b/hardware/neopixel/neopixel.js @@ -15,7 +15,7 @@ module.exports = function(RED) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } - if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel.py')) { + if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel/')) { RED.log.warn("Can't find neopixel.py python library"); throw "Warning : Can't find neopixel.py python library"; } diff --git a/hardware/neopixel/package.json b/hardware/neopixel/package.json index 0a09c765..3080b15e 100644 --- a/hardware/neopixel/package.json +++ b/hardware/neopixel/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-neopixel", - "version" : "0.0.14", + "version" : "0.0.15", "description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.", "dependencies" : { }, diff --git a/hardware/neopixel/scripts/checklib.js b/hardware/neopixel/scripts/checklib.js index bdd3bf0f..353f9695 100755 --- a/hardware/neopixel/scripts/checklib.js +++ b/hardware/neopixel/scripts/checklib.js @@ -1,7 +1,7 @@ #!/usr/bin/env node var fs = require('fs'); -if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel.py')) { +if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel/')) { console.warn("WARNING : Can't find neopixel.py python library"); console.warn("WARNING : Please install using the following command"); console.warn("WARNING : Note: this uses root..."); diff --git a/hardware/unicorn/package.json b/hardware/unicorn/package.json index cd1f4241..6b6dfb01 100644 --- a/hardware/unicorn/package.json +++ b/hardware/unicorn/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-unicorn-hat", - "version" : "0.0.14", + "version" : "0.0.15", "description" : "A Node-RED node to output to a Raspberry Pi Unicorn HAT from Pimorini.", "dependencies" : { "pngjs": "2.2.*" diff --git a/hardware/unicorn/scripts/checklib.js b/hardware/unicorn/scripts/checklib.js index bd19f8c0..bce456ff 100755 --- a/hardware/unicorn/scripts/checklib.js +++ b/hardware/unicorn/scripts/checklib.js @@ -1,7 +1,7 @@ #!/usr/bin/env node var fs = require('fs'); -if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/unicornhat.py')) { +if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel')) { console.warn("WARNING : Can't find unicorn.py python library"); console.warn("WARNING : Please install using the following command"); console.warn("WARNING : Note: this uses root..."); diff --git a/hardware/unicorn/unicorn.js b/hardware/unicorn/unicorn.js index 139ddf1d..acbbe5d4 100644 --- a/hardware/unicorn/unicorn.js +++ b/hardware/unicorn/unicorn.js @@ -12,7 +12,7 @@ module.exports = function(RED) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } - if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/unicornhat.py')) { + if (!fs.existsSync('/usr/local/lib/python2.7/dist-packages/neopixel')) { RED.log.warn("Can't find Unicorn HAT python libraries"); throw "Warning : Can't find Unicorn HAT python libraries"; }