parent
5024761a27
commit
a75b2e15d9
12
main.py
12
main.py
|
@ -29,7 +29,7 @@ def debug_print(message: str):
|
||||||
current_time = now.strftime("%H:%M:%S")
|
current_time = now.strftime("%H:%M:%S")
|
||||||
print('[DEBUG]['+current_time+'] '+message)
|
print('[DEBUG]['+current_time+'] '+message)
|
||||||
|
|
||||||
def wheel(pos):
|
def wheel(client, pos):
|
||||||
if pos < 85:
|
if pos < 85:
|
||||||
return Color(pos * 3, 255 - pos * 3, 0)
|
return Color(pos * 3, 255 - pos * 3, 0)
|
||||||
elif pos < 170:
|
elif pos < 170:
|
||||||
|
@ -39,14 +39,14 @@ def wheel(pos):
|
||||||
pos -= 170
|
pos -= 170
|
||||||
return Color(0, pos * 3, 255 - pos * 3)
|
return Color(0, pos * 3, 255 - pos * 3)
|
||||||
|
|
||||||
def rainbowCycle(strip, wait_ms=5, iterations=10):
|
def rainbowCycle(client, strip, wait_ms=5, iterations=10):
|
||||||
for j in range(256*iterations):
|
for j in range(256*iterations):
|
||||||
if mode > 0:
|
if mode > 0:
|
||||||
break
|
break
|
||||||
elif power == "False":
|
elif power == "False":
|
||||||
break
|
break
|
||||||
for i in range(strip.numPixels()):
|
for i in range(strip.numPixels()):
|
||||||
strip.setPixelColor(i, wheel((int(i * 256 / strip.numPixels()) + j) & 255))
|
strip.setPixelColor(i, wheel(client, (int(i * 256 / strip.numPixels()) + j) & 255))
|
||||||
strip.show()
|
strip.show()
|
||||||
time.sleep(wait_ms/1000.0)
|
time.sleep(wait_ms/1000.0)
|
||||||
|
|
||||||
|
@ -117,11 +117,7 @@ if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
if power == "True":
|
if power == "True":
|
||||||
if mode == 0:
|
if mode == 0:
|
||||||
rainbowCycle(strip)
|
rainbowCycle(client, strip)
|
||||||
animation_r = 255
|
|
||||||
animation_g = 0
|
|
||||||
animation_b = 0
|
|
||||||
client.publish("server-rack-led/rgb", str(animation_r)+","+str(animation_g)+","+str(animation_b))
|
|
||||||
elif mode == 1:
|
elif mode == 1:
|
||||||
setColor(strip, Color(int(r), int(g), int(b)))
|
setColor(strip, Color(int(r), int(g), int(b)))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
Loading…
Reference in New Issue