mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Neopixel Add 0mS timeout option for instant updates
Thanks @cymplecy
This commit is contained in:
parent
f1066285ae
commit
7f44a2af3d
@ -62,10 +62,15 @@ def setPixel(strip, i, color):
|
||||
|
||||
def setPixels(strip, s, e, color, wait_ms=30):
|
||||
"""Set pixels from s(tart) to e(nd)"""
|
||||
if (wait_ms > 0):
|
||||
for i in range(s, e+1):
|
||||
strip.setPixelColor(i, color)
|
||||
strip.show()
|
||||
time.sleep(wait_ms/1000.0)
|
||||
else:
|
||||
for i in range(s, e+1):
|
||||
strip.setPixelColor(i, color)
|
||||
strip.show()
|
||||
|
||||
def setBrightness(strip, brightness, wait_ms=30):
|
||||
"""Set overall brighness"""
|
||||
@ -75,16 +80,22 @@ def setBrightness(strip, brightness, wait_ms=30):
|
||||
|
||||
def colorWipe(strip, color, wait_ms=30):
|
||||
"""Wipe color across display a pixel at a time."""
|
||||
if (wait_ms > 0):
|
||||
for i in range(strip.numPixels()):
|
||||
strip.setPixelColor(i, color)
|
||||
strip.show()
|
||||
time.sleep(wait_ms/1000.0)
|
||||
else:
|
||||
for i in range(strip.numPixels()):
|
||||
strip.setPixelColor(i, color)
|
||||
strip.show()
|
||||
|
||||
def shiftUp(strip, color, wait_ms=30):
|
||||
"""Shift all pixels one way."""
|
||||
oldcolour = strip.getPixelColor(0)
|
||||
strip.setPixelColor(0, color)
|
||||
strip.show()
|
||||
if (wait_ms > 0):
|
||||
time.sleep(wait_ms/1000.0)
|
||||
for i in range(1,LED_COUNT):
|
||||
newcolour = oldcolour
|
||||
@ -92,12 +103,19 @@ def shiftUp(strip, color, wait_ms=30):
|
||||
strip.setPixelColor(i, newcolour)
|
||||
strip.show()
|
||||
time.sleep(wait_ms/1000.0)
|
||||
else:
|
||||
for i in range(1,LED_COUNT):
|
||||
newcolour = oldcolour
|
||||
oldcolour = strip.getPixelColor(i)
|
||||
strip.setPixelColor(i, newcolour)
|
||||
strip.show()
|
||||
|
||||
def shiftDown(strip, color, wait_ms=30):
|
||||
"""Shift all pixels the other way."""
|
||||
oldcolour = strip.getPixelColor(LED_COUNT-1)
|
||||
strip.setPixelColor(LED_COUNT-1, color)
|
||||
strip.show()
|
||||
if (wait_ms > 0):
|
||||
time.sleep(wait_ms/1000.0)
|
||||
for i in range(LED_COUNT-2,-1,-1):
|
||||
newcolour = oldcolour
|
||||
@ -105,6 +123,12 @@ def shiftDown(strip, color, wait_ms=30):
|
||||
strip.setPixelColor(i, newcolour)
|
||||
strip.show()
|
||||
time.sleep(wait_ms/1000.0)
|
||||
else:
|
||||
for i in range(LED_COUNT-2,-1,-1):
|
||||
newcolour = oldcolour
|
||||
oldcolour = strip.getPixelColor(i)
|
||||
strip.setPixelColor(i, newcolour)
|
||||
strip.show()
|
||||
|
||||
def wheel(pos):
|
||||
"""Generate rainbow colors across 0-255 positions."""
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name" : "node-red-node-pi-neopixel",
|
||||
"version" : "0.0.22",
|
||||
"version" : "0.0.23",
|
||||
"description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.",
|
||||
"dependencies" : {
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user