2017-04-09 22:28:32 +02:00
|
|
|
import hyperion, time, random, math
|
2014-10-30 17:02:30 +01:00
|
|
|
|
|
|
|
# Initialize the led data
|
|
|
|
ledData = bytearray()
|
|
|
|
for i in range(hyperion.ledCount):
|
|
|
|
ledData += bytearray((0,0,0))
|
|
|
|
|
2017-04-09 22:28:32 +02:00
|
|
|
sleepTime = float(hyperion.args.get('speed', 1.0)) * 0.004
|
|
|
|
minStepTime = float(hyperion.latchTime)/1000.0
|
2020-04-13 12:00:10 +02:00
|
|
|
if minStepTime == 0: minStepTime = 0.001
|
2017-04-09 22:28:32 +02:00
|
|
|
factor = 1 if sleepTime > minStepTime else int(math.ceil(minStepTime/sleepTime))
|
2014-10-30 17:02:30 +01:00
|
|
|
|
|
|
|
runners = [
|
2017-04-09 22:28:32 +02:00
|
|
|
{ "i":0, "pos":0, "c":0, "step":9, "lvl":255},
|
|
|
|
{ "i":1, "pos":0, "c":0, "step":8, "lvl":255},
|
|
|
|
{ "i":2, "pos":0, "c":0, "step":7, "lvl":255},
|
|
|
|
{ "i":0, "pos":0, "c":0, "step":6, "lvl":100},
|
|
|
|
{ "i":1, "pos":0, "c":0, "step":5, "lvl":100},
|
|
|
|
{ "i":2, "pos":0, "c":0, "step":4, "lvl":100},
|
2014-10-30 17:02:30 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
# Start the write data loop
|
2017-04-09 22:28:32 +02:00
|
|
|
i = 0
|
2014-10-30 17:02:30 +01:00
|
|
|
while not hyperion.abort():
|
|
|
|
for r in runners:
|
|
|
|
if r["c"] == 0:
|
|
|
|
#ledData[r["pos"]*3+r["i"]] = 0
|
|
|
|
r["c"] = r["step"]
|
|
|
|
r["pos"] = (r["pos"]+1)%hyperion.ledCount
|
|
|
|
ledData[r["pos"]*3+r["i"]] = int(r["lvl"]*(0.2+0.8*random.random()))
|
|
|
|
else:
|
|
|
|
r["c"] -= 1
|
|
|
|
|
2017-04-09 22:28:32 +02:00
|
|
|
i += 1
|
|
|
|
if i % factor == 0:
|
|
|
|
hyperion.setColor(ledData)
|
|
|
|
i = 0
|
|
|
|
|
2014-10-30 17:02:30 +01:00
|
|
|
time.sleep(sleepTime)
|