rainbow-mood.py 751 B

123456789101112131415161718192021222324
  1. import hyperion, time, colorsys
  2. # Get the parameters
  3. rotationTime = float(hyperion.args.get('rotation-time', 30.0))
  4. brightness = float(hyperion.args.get('brightness', 100))/100.0
  5. saturation = float(hyperion.args.get('saturation', 100))/100.0
  6. reverse = bool(hyperion.args.get('reverse', False))
  7. # Calculate the sleep time and hue increment
  8. sleepTime = 0.1
  9. hueIncrement = sleepTime / rotationTime
  10. # Switch direction if needed
  11. if reverse:
  12. hueIncrement = -hueIncrement
  13. # Start the write data loop
  14. hue = 0.0
  15. while not hyperion.abort():
  16. rgb = colorsys.hsv_to_rgb(hue, saturation, brightness)
  17. hyperion.setColor(int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2]))
  18. hue = (hue + hueIncrement) % 1.0
  19. time.sleep(sleepTime)