diff --git a/hardware/neopixel/README.md b/hardware/neopixel/README.md index 723ac84f..9a5e83b5 100644 --- a/hardware/neopixel/README.md +++ b/hardware/neopixel/README.md @@ -29,6 +29,7 @@ Usage ----- Defaults to a bar chart style mode using configured foreground and background colours. +It can also display a needle (single pixel) type gauge. It can accept a number in **msg.payload** that can be either the number of pixels, or a percentage of the total length. diff --git a/hardware/neopixel/neopix.py b/hardware/neopixel/neopix.py index cad5a96a..a926279e 100755 --- a/hardware/neopixel/neopix.py +++ b/hardware/neopixel/neopix.py @@ -62,21 +62,29 @@ def colorWipe(strip, color, wait_ms=30): def shiftUp(strip, color, wait_ms=30): """Shift all pixels one way.""" - for i in range(strip.numPixels()): - strip.setPixelColor(LED_COUNT-i, strip.getPixelColor(LED_COUNT-i-1)) + oldcolour = strip.getPixelColor(0) + strip.setPixelColor(0, color) + strip.show() + time.sleep(wait_ms/1000.0) + for i in range(1,LED_COUNT): + newcolour = oldcolour + oldcolour = strip.getPixelColor(i) + strip.setPixelColor(i, newcolour) strip.show() time.sleep(wait_ms/1000.0) - strip.setPixelColor(0,color) - strip.show() def shiftDown(strip, color, wait_ms=30): """Shift all pixels the other way.""" - for i in range(strip.numPixels()): - strip.setPixelColor(i, strip.getPixelColor(i+1)) + oldcolour = strip.getPixelColor(LED_COUNT-1) + strip.setPixelColor(LED_COUNT-1, color) + strip.show() + time.sleep(wait_ms/1000.0) + for i in range(LED_COUNT-2,-1,-1): + newcolour = oldcolour + oldcolour = strip.getPixelColor(i) + strip.setPixelColor(i, newcolour) strip.show() time.sleep(wait_ms/1000.0) - strip.setPixelColor(LED_COUNT-1,color) - strip.show() def wheel(pos): """Generate rainbow colors across 0-255 positions.""" diff --git a/hardware/neopixel/neopixel.html b/hardware/neopixel/neopixel.html index 2e5beb65..a8454547 100644 --- a/hardware/neopixel/neopixel.html +++ b/hardware/neopixel/neopixel.html @@ -30,8 +30,10 @@
@@ -50,7 +52,9 @@