2019-12-01 14:21:01 +01:00
|
|
|
#!/usr/bin/env python3
|
2012-12-27 02:06:36 +01:00
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
import sk6812
|
2012-12-27 02:06:36 +01:00
|
|
|
import time
|
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
num_modules = 300
|
2012-12-27 02:06:36 +01:00
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
interval = 0.05
|
2012-12-27 02:06:36 +01:00
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
w = sk6812.SK6812("zybot", 2703)
|
|
|
|
w.set_fadestep(0.05/interval)
|
|
|
|
w.set_num_modules(num_modules)
|
2012-12-27 02:06:36 +01:00
|
|
|
|
|
|
|
# dictionary which maps {module: [r, g, b]}
|
|
|
|
set_colors = {}
|
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
curModule = [0, 0, 0, 0]
|
|
|
|
speed = [0.49, 0.65, 1, 0.81]
|
2012-12-27 02:06:36 +01:00
|
|
|
#countUp = [True, True, False]
|
|
|
|
while True:
|
|
|
|
set_colors = {}
|
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
set_colors[int(curModule[0])] = [0, 0, 0, 0]
|
|
|
|
set_colors[int(curModule[1])] = [0, 0, 0, 0]
|
|
|
|
set_colors[num_modules-1-int(curModule[2])] = [0, 0, 0, 0]
|
|
|
|
set_colors[num_modules-1-int(curModule[3])] = [0, 0, 0, 0]
|
2012-12-27 02:06:36 +01:00
|
|
|
|
|
|
|
set_colors[int(curModule[0])][0] = 255
|
|
|
|
set_colors[int(curModule[1])][1] = 255
|
|
|
|
set_colors[num_modules-1-int(curModule[2])][2] = 255
|
2019-12-01 14:21:01 +01:00
|
|
|
set_colors[num_modules-1-int(curModule[3])][3] = 255
|
2012-12-27 02:06:36 +01:00
|
|
|
|
|
|
|
for k in set_colors.keys():
|
2019-12-01 14:21:01 +01:00
|
|
|
w.add_color(k, set_colors[k][0], set_colors[k][1], set_colors[k][2], set_colors[k][3])
|
2012-12-27 02:06:36 +01:00
|
|
|
|
|
|
|
for i in range(num_modules):
|
2019-12-01 14:21:01 +01:00
|
|
|
w.fade_color(i, 0, 0, 0, 0)
|
2012-12-27 02:06:36 +01:00
|
|
|
|
|
|
|
w.commit()
|
|
|
|
|
2019-12-01 14:21:01 +01:00
|
|
|
for i in range(4):
|
2012-12-27 02:06:36 +01:00
|
|
|
curModule[i] += speed[i]
|
|
|
|
if curModule[i] >= num_modules:
|
|
|
|
curModule[i] -= num_modules
|
|
|
|
|
|
|
|
time.sleep(interval)
|