diff --git a/hardware/neopixel/neopix.py b/hardware/neopixel/neopix.py index f5f66484..83756f0f 100755 --- a/hardware/neopixel/neopix.py +++ b/hardware/neopixel/neopix.py @@ -166,39 +166,39 @@ if __name__ == '__main__': else: strip = PixelStrip(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_GAMMA)# Intialize the library (must be called once before other functions). - strip.begin() + strip.begin() - ## Color wipe animations. - colorWipe(strip, Color(127, 0, 0), WAIT_MS) # Red wipe - colorWipe(strip, Color(0, 127, 0), WAIT_MS) # Green wipe - colorWipe(strip, Color(0, 0, 127), WAIT_MS) # Blue wipe - colorWipe(strip, Color(0, 0, 0), WAIT_MS) # Off wipe + ## Color wipe animations. + colorWipe(strip, Color(127, 0, 0), WAIT_MS) # Red wipe + colorWipe(strip, Color(0, 127, 0), WAIT_MS) # Green wipe + colorWipe(strip, Color(0, 0, 127), WAIT_MS) # Blue wipe + colorWipe(strip, Color(0, 0, 0), WAIT_MS) # Off wipe - ## Rainbow animations. - #rainbow(strip) - #rainbowCycle(strip) - #colorWipe(strip, Color(0, 0, 0)) # Off wipe + ## Rainbow animations. + #rainbow(strip) + #rainbowCycle(strip) + #colorWipe(strip, Color(0, 0, 0)) # Off wipe - while True: - try: - data = raw_input() - bits = data.split(',') - if len(bits) == 2: - if bits[0] == "brightness": - setBrightness(strip, min(255,max(0,int(bits[1]))), WAIT_MS) - if len(bits) == 3: - if MODE == "shiftu": - shiftUp(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) - elif MODE == "shiftd": - shiftDown(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) - else: - colorWipe(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) - if (MODE[0] == 'p' and len(bits) == 4): - setPixel(strip, int(bits[0]), Color(int(bits[1]), int(bits[2]), int(bits[3]) )) - if (MODE[0] == 'p' and len(bits) == 5): - setPixels(strip, int(bits[0]), int(bits[1]), Color(int(bits[2]), int(bits[3]), int(bits[4]) ), WAIT_MS) - except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program - sys.exit(0) - except Exception as ex: - print("bad data: "+data) - print(ex) + while True: + try: + data = raw_input() + bits = data.split(',') + if len(bits) == 2: + if bits[0] == "brightness": + setBrightness(strip, min(255,max(0,int(bits[1]))), WAIT_MS) + if len(bits) == 3: + if MODE == "shiftu": + shiftUp(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) + elif MODE == "shiftd": + shiftDown(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) + else: + colorWipe(strip, Color(int(bits[0]), int(bits[1]), int(bits[2])), WAIT_MS) + if (MODE[0] == 'p' and len(bits) == 4): + setPixel(strip, int(bits[0]), Color(int(bits[1]), int(bits[2]), int(bits[3]) )) + if (MODE[0] == 'p' and len(bits) == 5): + setPixels(strip, int(bits[0]), int(bits[1]), Color(int(bits[2]), int(bits[3]), int(bits[4]) ), WAIT_MS) + except (EOFError, SystemExit): # hopefully always caused by us sigint'ing the program + sys.exit(0) + except Exception as ex: + print("bad data: "+data) + print(ex) diff --git a/hardware/neopixel/package.json b/hardware/neopixel/package.json index bd4530ed..795bfec3 100644 --- a/hardware/neopixel/package.json +++ b/hardware/neopixel/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-neopixel", - "version" : "0.0.23", + "version" : "0.0.24", "description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.", "dependencies" : { },