parent
ff00a9c77d
commit
7c18a6e1c3
8
main.py
8
main.py
|
@ -35,20 +35,18 @@ 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(client, pos):
|
def wheel(pos):
|
||||||
if pos < 85:
|
if pos < 85:
|
||||||
# client.publish("server-rack-led/rgb", str(pos * 3)+","+str(255 - pos * 3)+","+str(0))
|
|
||||||
return Color(pos * 3, 255 - pos * 3, 0)
|
return Color(pos * 3, 255 - pos * 3, 0)
|
||||||
elif pos < 170:
|
elif pos < 170:
|
||||||
pos -= 85
|
pos -= 85
|
||||||
# client.publish("server-rack-led/rgb", str(255 - pos * 3)+","+str(0)+","+str(pos * 3))
|
|
||||||
return Color(255 - pos * 3, 0, pos * 3)
|
return Color(255 - pos * 3, 0, pos * 3)
|
||||||
else:
|
else:
|
||||||
pos -= 170
|
pos -= 170
|
||||||
client.publish("server-rack-led/rgb", str(0)+","+str(pos * 3)+","+str(255 - pos * 3))
|
client.publish("server-rack-led/rgb", str(0)+","+str(pos * 3)+","+str(255 - pos * 3))
|
||||||
return Color(0, pos * 3, 255 - pos * 3)
|
return Color(0, pos * 3, 255 - pos * 3)
|
||||||
|
|
||||||
def rainbowCycle(client, strip, wait_ms=5, iterations=10):
|
def rainbowCycle( 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
|
||||||
|
@ -126,7 +124,7 @@ if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
if power == "True":
|
if power == "True":
|
||||||
if mode == 0:
|
if mode == 0:
|
||||||
rainbowCycle(client, strip)
|
rainbowCycle(strip)
|
||||||
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