parent
be6f16f968
commit
4134a4f0a3
13
main.py
13
main.py
|
@ -41,7 +41,7 @@ def wheel(pos):
|
|||
pos -= 170
|
||||
return Color(0, pos * 3, 255 - pos * 3)
|
||||
|
||||
def rainbowCycle( strip, wait_ms=5, iterations=10):
|
||||
def rainbowCycle(strip, wait_ms=5, iterations=10):
|
||||
for j in range(256*iterations):
|
||||
if mode > 0:
|
||||
break
|
||||
|
@ -58,6 +58,15 @@ def setColor(strip, color, wait_ms=10):
|
|||
strip.show()
|
||||
time.sleep(wait_ms/1000.0)
|
||||
|
||||
def strobe(strip, color):
|
||||
for i in range(strip.numPixels()):
|
||||
strip.setPixelColor(i, color)
|
||||
strip.show()
|
||||
time.sleep(float(0.01))
|
||||
for i in range(strip.numPixels()):
|
||||
strip.setPixelColor(i, Color(0, 0, 0))
|
||||
strip.show()
|
||||
|
||||
def mqtt_on_connect(client, userdata, flags, rc):
|
||||
client.subscribe("server-rack-led/power")
|
||||
client.subscribe("server-rack-led/mode")
|
||||
|
@ -121,6 +130,8 @@ if __name__ == '__main__':
|
|||
rainbowCycle(strip)
|
||||
elif mode == 1:
|
||||
setColor(strip, Color(int(r), int(g), int(b)))
|
||||
elif mode == 2:
|
||||
strobe(strip, Color(int(r), int(g), int(b)))
|
||||
else:
|
||||
setColor(strip, Color(0,0,0))
|
||||
|
||||
|
|
Loading…
Reference in New Issue