diff --git a/main.py b/main.py index 7cb52f4..4396a73 100644 --- a/main.py +++ b/main.py @@ -56,7 +56,8 @@ def rainbowCycle(strip, wait_ms=5, iterations=10): def setColor(strip, color, wait_ms=10): for i in range(strip.numPixels()): strip.setPixelColor(i, color) - strip.show() + strip.show() + time.sleep(float(0.01)) time.sleep(wait_ms/1000.0) def strobe(strip, color): @@ -75,6 +76,13 @@ def randomColor(strip): strip.show() time.sleep(1) +def randomColorPerLED(strip): + color = Color(randint(0, 255), randint(0, 255), randint(0, 255)) + for i in range(strip.numPixels()): + strip.setPixelColor(i, color) + strip.show() + time.sleep(1) + def mqtt_on_connect(client, userdata, flags, rc): client.subscribe("server-rack-led/power") client.subscribe("server-rack-led/mode") @@ -110,6 +118,8 @@ if __name__ == '__main__': mode = 2 elif payload == "Random Color": mode = 3 + elif payload == "Random Color per LED": + mode = 4 strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL) strip.begin() @@ -146,6 +156,8 @@ if __name__ == '__main__': strobe(strip, Color(int(r), int(g), int(b))) elif mode == 3: randomColor(strip) + elif mode == 4: + randomColorPerLED(strip) else: setColor(strip, Color(0,0,0))