running_dots.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import hyperion, time
  2. # get options from args
  3. sleepTime = float(hyperion.args.get('speed', 1.5)) * 0.005
  4. whiteLevel = int(hyperion.args.get('whiteLevel', 0))
  5. lvl = int(hyperion.args.get('colorLevel', 220))
  6. # check value
  7. whiteLevel = min( whiteLevel, 254 )
  8. lvl = min( lvl, 255 )
  9. if whiteLevel >= lvl:
  10. lvl = 255
  11. # Initialize the led data
  12. ledData = bytearray()
  13. for unused in range(hyperion.ledCount):
  14. ledData += bytearray((0,0,0))
  15. runners = [
  16. { "pos":0, "step": 4, "lvl":lvl},
  17. { "pos":1, "step": 5, "lvl":lvl},
  18. { "pos":2, "step": 6, "lvl":lvl},
  19. { "pos":0, "step": 7, "lvl":lvl},
  20. { "pos":1, "step": 8, "lvl":lvl},
  21. { "pos":2, "step": 9, "lvl":lvl},
  22. #{ "pos":0, "step":10, "lvl":lvl},
  23. #{ "pos":1, "step":11, "lvl":lvl},
  24. #{ "pos":2, "step":12, "lvl":lvl},
  25. ]
  26. # Start the write data loop
  27. counter = 0
  28. while not hyperion.abort():
  29. counter += 1
  30. for r in runners:
  31. if counter % r["step"] == 0:
  32. ledData[r["pos"]] = whiteLevel
  33. r["pos"] = (r["pos"]+3) % (hyperion.ledCount*3)
  34. ledData[r["pos"]] = r["lvl"]
  35. hyperion.setColor(ledData)
  36. time.sleep(sleepTime)