Last active
November 26, 2024 22:39
-
-
Save mveinot/31889131d4e2656c6cf82152e5313149 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os,time | |
# {"seg":{"i":[0,"FF0000",1,"00FF00",2,"FFFFFF",3,"FF0000"]}} | |
led_count = 200 | |
wled_ip = '192.168.10.11' | |
#curl --header "Content-Type: application/json" \ | |
#--request POST \ | |
#--data "$DATA" \ | |
#http://$IP_ADDRESS/json | |
color_array = ['"FF0000"', '"00FF00"', '"FFFFFF"'] | |
while True: | |
output_prefix = '{"seg":{"i":[' | |
output_suffix = ']}}' | |
output_colors = '' | |
for led in range(0,led_count): | |
if led > 0: | |
output_colors = output_colors+"," | |
output_colors = output_colors+str(led)+","+color_array[led % 3] | |
output_string = (output_prefix+output_colors+output_suffix).replace('"','\\"') | |
os.system('curl -s -o /dev/null --header "Content-Type: application/json" --request POST --data "'+output_string+'" http://'+wled_ip+'/json') | |
color_array = color_array[1:] + color_array[: 1] | |
time.sleep (1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment