added static color update animation and random color per led
Signed-off-by: Ebbe Baß <ebbe@ping-mee.de>master
parent
386d81fc09
commit
5871608510
14
main.py
14
main.py
|
@ -56,7 +56,8 @@ def rainbowCycle(strip, wait_ms=5, iterations=10):
|
||||||
def setColor(strip, color, wait_ms=10):
|
def setColor(strip, color, wait_ms=10):
|
||||||
for i in range(strip.numPixels()):
|
for i in range(strip.numPixels()):
|
||||||
strip.setPixelColor(i, color)
|
strip.setPixelColor(i, color)
|
||||||
strip.show()
|
strip.show()
|
||||||
|
time.sleep(float(0.01))
|
||||||
time.sleep(wait_ms/1000.0)
|
time.sleep(wait_ms/1000.0)
|
||||||
|
|
||||||
def strobe(strip, color):
|
def strobe(strip, color):
|
||||||
|
@ -75,6 +76,13 @@ def randomColor(strip):
|
||||||
strip.show()
|
strip.show()
|
||||||
time.sleep(1)
|
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):
|
def mqtt_on_connect(client, userdata, flags, rc):
|
||||||
client.subscribe("server-rack-led/power")
|
client.subscribe("server-rack-led/power")
|
||||||
client.subscribe("server-rack-led/mode")
|
client.subscribe("server-rack-led/mode")
|
||||||
|
@ -110,6 +118,8 @@ if __name__ == '__main__':
|
||||||
mode = 2
|
mode = 2
|
||||||
elif payload == "Random Color":
|
elif payload == "Random Color":
|
||||||
mode = 3
|
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 = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
||||||
strip.begin()
|
strip.begin()
|
||||||
|
@ -146,6 +156,8 @@ if __name__ == '__main__':
|
||||||
strobe(strip, Color(int(r), int(g), int(b)))
|
strobe(strip, Color(int(r), int(g), int(b)))
|
||||||
elif mode == 3:
|
elif mode == 3:
|
||||||
randomColor(strip)
|
randomColor(strip)
|
||||||
|
elif mode == 4:
|
||||||
|
randomColorPerLED(strip)
|
||||||
else:
|
else:
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue